shaders 2.0.649 → 2.0.650

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.
@@ -426,7 +426,7 @@ struct ${t} {
426
426
  ${e}
427
427
  };`}_getWGSLStructBinding(t,e,r,s=0,i=0){let n=t+"Struct";return`${this._getWGSLStruct(n,e)}
428
428
  @binding( ${s} ) @group( ${i} )
429
- var<${r}> ${t} : ${n};`}},t7=class{constructor(t){this.backend=t}getCurrentDepthStencilFormat(t){let e;return t.depthTexture===null?t.depth&&t.stencil?e=P.Depth24PlusStencil8:t.depth&&(e=P.Depth24Plus):e=this.getTextureFormatGPU(t.depthTexture),e}getTextureFormatGPU(t){return this.backend.get(t).format}getTextureSampleData(t){let e;if(t.isFramebufferTexture)e=1;else if(t.isDepthTexture&&!t.renderTarget){let i=this.backend.renderer,n=i.getRenderTarget();e=n?n.samples:i.samples}else t.renderTarget&&(e=t.renderTarget.samples);e||(e=1);let r=e>1&&t.renderTarget!==null&&t.isDepthTexture!==!0&&t.isFramebufferTexture!==!0;return{samples:e,primarySamples:r?1:e,isMSAA:r}}getCurrentColorFormat(t){let e;return e=t.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(t.textures[0]),e}getCurrentColorSpace(t){return t.textures===null?this.backend.renderer.outputColorSpace:t.textures[0].colorSpace}getPrimitiveTopology(t,e){if(t.isPoints)return Uu.PointList;if(t.isLineSegments||t.isMesh&&e.wireframe===!0)return Uu.LineList;if(t.isLine)return Uu.LineStrip;if(t.isMesh)return Uu.TriangleList}getSampleCount(t){let e=1;return t>1&&(e=2**Math.floor(Math.log2(t)),e===2&&(e=4)),e}getSampleCountRenderContext(t){return t.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(t.sampleCount)}getPreferredCanvasFormat(){let t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===ms)return P.BGRA8Unorm;if(t===Ss)return P.RGBA16Float;throw Error("Unsupported outputType")}};const r7=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),s7=new Map([[h2,["float16"]]]),i7=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);var n7=class{constructor(t){this.backend=t}createAttribute(t,e){let r=this._getBufferAttribute(t),s=this.backend,i=s.get(r),n=i.buffer;if(n===void 0){let a=s.device,o=r.array;if(t.normalized===!1){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),e&GPUBufferUsage.INDEX))for(let u=0;u<o.length;u++)o[u]===65535&&(o[u]=4294967295)}if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&r.itemSize===3){o=new o.constructor(r.count*4);for(let u=0;u<r.count;u++)o.set(r.array.subarray(u*3,u*3+3),u*4);r.itemSize=4,r.array=o,i._force3to4BytesAlignment=!0}let l=o.byteLength,h=l+(4-l%4)%4;n=a.createBuffer({label:r.name,size:h,usage:e,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),i.buffer=n}}updateAttribute(t){let e=this._getBufferAttribute(t),r=this.backend,s=r.device,i=r.get(e),n=r.get(e).buffer,a=e.array;if(i._force3to4BytesAlignment===!0){a=new a.constructor(e.count*4);for(let h=0;h<e.count;h++)a.set(e.array.subarray(h*3,h*3+3),h*4);e.array=a}let o=this._isTypedArray(a),l=e.updateRanges;if(l.length===0)s.queue.writeBuffer(n,0,a,0);else{let h=o?1:a.BYTES_PER_ELEMENT;for(let u=0,c=l.length;u<c;u++){let d=l[u],p,m;if(i._force3to4BytesAlignment===!0){let g=Math.floor(d.start/3),b=Math.ceil(d.count/3);p=g*4*h,m=b*4*h}else p=d.start*h,m=d.count*h;let f=p*(o?a.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(n,f,a,p,m)}e.clearUpdateRanges()}}createShaderVertexBuffers(t){let e=t.getAttributes(),r=new Map;for(let s=0;s<e.length;s++){let i=e[s],n=i.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(i),o=r.get(a);if(o===void 0){let u,c;i.isInterleavedBufferAttribute===!0?(u=i.data.stride*n,c=i.data.isInstancedInterleavedBuffer?um.Instance:um.Vertex):(u=i.itemSize*n,c=i.isInstancedBufferAttribute?um.Instance:um.Vertex),i.normalized===!1&&(i.array.constructor===Int16Array||i.array.constructor===Uint16Array)&&(u=4),o={arrayStride:u,attributes:[],stepMode:c},r.set(a,o)}let l=this._getVertexFormat(i),h=i.isInterleavedBufferAttribute===!0?i.offset*n:0;o.attributes.push({shaderLocation:s,offset:h,format:l})}return Array.from(r.values())}destroyAttribute(t){let e=this.backend;e.get(this._getBufferAttribute(t)).buffer.destroy(),e.delete(t)}async getArrayBufferAsync(t){let e=this.backend,r=e.device,s=e.get(this._getBufferAttribute(t)),i=s.buffer,n=i.size,a=r.createBuffer({label:`${t.name}_readback`,size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),o=r.createCommandEncoder({label:`readback_encoder_${t.name}`});o.copyBufferToBuffer(i,0,a,0,n);let l=o.finish();r.queue.submit([l]),await a.mapAsync(GPUMapMode.READ);let h=a.getMappedRange(),u=new t.array.constructor(h.slice(0));return a.unmap(),u.buffer}_getVertexFormat(t){let{itemSize:e,normalized:r}=t,s=t.array.constructor,i=t.constructor,n;if(e===1)n=i7.get(s);else{let a=s7.get(i)||r7.get(s),o=a[r?1:0];if(o){let l=s.BYTES_PER_ELEMENT*e,h=Math.floor((l+3)/4)*4,u=h/s.BYTES_PER_ELEMENT;if(u%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${o}x${u}`}}return n||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),n}_isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}_getBufferAttribute(t){return t.isInterleavedBufferAttribute&&(t=t.data),t}},a7=class{constructor(t){this.backend=t,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(t){let e=this.backend,r=e.device,s=[],i=0;for(let n of t.bindings){let a={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let o={};n.isStorageBuffer&&(n.visibility&4&&(n.access===Qr.READ_WRITE||n.access===Qr.WRITE_ONLY)?o.type=HS.Storage:o.type=HS.ReadOnlyStorage),a.buffer=o}else if(n.isSampler){let o={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?e.compatibilityMode&&(o.type=qS.NonFiltering):o.type=qS.Comparison),a.sampler=o}else if(n.isSampledTexture&&n.texture.isVideoTexture)a.externalTexture={};else if(n.isSampledTexture&&n.store){let o={};o.format=this.backend.get(n.texture).texture.format;let l=n.access;l===Qr.READ_WRITE?o.access=Sx.ReadWrite:l===Qr.WRITE_ONLY?o.access=Sx.WriteOnly:o.access=Sx.ReadOnly,a.storageTexture=o}else if(n.isSampledTexture){let o={},{primarySamples:l}=e.utils.getTextureSampleData(n.texture);if(l>1&&(o.multisampled=!0,n.texture.isDepthTexture||(o.sampleType=$o.UnfilterableFloat)),n.texture.isDepthTexture)e.compatibilityMode&&n.texture.compareFunction===null?o.sampleType=$o.UnfilterableFloat:o.sampleType=$o.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let h=n.texture.type;h===ds?o.sampleType=$o.SInt:h===Yt?o.sampleType=$o.UInt:h===Hs&&(this.backend.hasFeature("float32-filterable")?o.sampleType=$o.Float:o.sampleType=$o.UnfilterableFloat)}n.isSampledCubeTexture?o.viewDimension=Br.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?o.viewDimension=Br.TwoDArray:n.isSampledTexture3D&&(o.viewDimension=Br.ThreeD),a.texture=o}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);s.push(a)}return r.createBindGroupLayout({entries:s})}createBindings(t,e,r,s=0){let{backend:i,bindGroupLayoutCache:n}=this,a=i.get(t),o=n.get(t.bindingsReference);o===void 0&&(o=this.createBindingsLayout(t),n.set(t.bindingsReference,o));let l;r>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(l=a.groups[r])),l===void 0&&(l=this.createBindGroup(t,o),r>0&&(a.groups[r]=l,a.versions[r]=s)),a.group=l,a.layout=o}updateBinding(t){let e=this.backend,r=e.device,s=t.buffer,i=e.get(t).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(t,e){let r=this.backend,s=r.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=t[0],a=s.createBuffer({label:"bindingCameraIndex_"+n,size:16,usage:i});s.queue.writeBuffer(a,0,t,0);let o=[{binding:0,resource:{buffer:a}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+n,layout:e,entries:o})}createBindGroup(t,e){let r=this.backend,s=r.device,i=0,n=[];for(let a of t.bindings){if(a.isUniformBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.byteLength,h=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,u=s.createBuffer({label:"bindingBuffer_"+a.name,size:l,usage:h});o.buffer=u}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isStorageBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.attribute;o.buffer=r.get(l).buffer}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isSampler){let o=r.get(a.texture);n.push({binding:i,resource:o.sampler})}else if(a.isSampledTexture){let o=r.get(a.texture),l;if(o.externalTexture!==void 0)l=s.importExternalTexture({source:o.externalTexture});else{let h=a.store?1:o.texture.mipLevelCount,u=`view-${o.texture.width}-${o.texture.height}-${h}`;if(l=o[u],l===void 0){let c=B$.All,d;d=a.isSampledCubeTexture?Br.Cube:a.isSampledTexture3D?Br.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?Br.TwoDArray:Br.TwoD,l=o[u]=o.texture.createView({aspect:c,dimension:d,mipLevelCount:h})}}n.push({binding:i,resource:l})}i++}return s.createBindGroup({label:"bindGroup_"+t.name,layout:e,entries:n})}},o7=class{constructor(t){this.backend=t,this._activePipelines=new WeakMap}setPipeline(t,e){this._activePipelines.get(t)!==e&&(t.setPipeline(e),this._activePipelines.set(t,e))}_getSampleCount(t){return this.backend.utils.getSampleCountRenderContext(t)}createRenderPipeline(t,e){let{object:r,material:s,geometry:i,pipeline:n}=t,{vertexProgram:a,fragmentProgram:o}=n,l=this.backend,h=l.device,u=l.utils,c=l.get(n),d=[];for(let re of t.getBindings()){let te=l.get(re);d.push(te.layout)}let p=l.attributeUtils.createShaderVertexBuffers(t),m;s.blending!==Ph&&(s.blending!==oa||s.transparent!==!1)&&(m=this._getBlending(s));let f={};s.stencilWrite===!0&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let g=this._getColorWriteMask(s),b=[];if(t.context.textures!==null){let re=t.context.textures;for(let te=0;te<re.length;te++){let oe=u.getTextureFormatGPU(re[te]);b.push({format:oe,blend:m,writeMask:g})}}else{let re=u.getCurrentColorFormat(t.context);b.push({format:re,blend:m,writeMask:g})}let v=l.get(a).module,w=l.get(o).module,T=this._getPrimitiveState(r,i,s),N=this._getDepthCompare(s),S=u.getCurrentDepthStencilFormat(t.context),_=this._getSampleCount(t.context),A={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},w,{targets:b}),primitive:T,multisample:{count:_,alphaToCoverageEnabled:s.alphaToCoverage&&_>1},layout:h.createPipelineLayout({bindGroupLayouts:d})},D={},K=t.context.depth,J=t.context.stencil;if((K===!0||J===!0)&&(K===!0&&(D.format=S,D.depthWriteEnabled=s.depthWrite,D.depthCompare=N),J===!0&&(D.stencilFront=f,D.stencilBack={},D.stencilReadMask=s.stencilFuncMask,D.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(D.depthBias=s.polygonOffsetUnits,D.depthBiasSlopeScale=s.polygonOffsetFactor,D.depthBiasClamp=0),A.depthStencil=D),e===null)c.pipeline=h.createRenderPipeline(A);else{let re=new Promise(te=>{h.createRenderPipelineAsync(A).then(oe=>{c.pipeline=oe,te()})});e.push(re)}}createBundleEncoder(t,e="renderBundleEncoder"){let r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(t),a=s.getCurrentColorFormat(t),o=this._getSampleCount(t),l={label:e,colorFormats:[a],depthStencilFormat:n,sampleCount:o};return i.createRenderBundleEncoder(l)}createComputePipeline(t,e){let r=this.backend,s=r.device,i=r.get(t.computeProgram).module,n=r.get(t),a=[];for(let o of e){let l=r.get(o);a.push(l.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(t){let e,r,s=t.blending,i=t.blendSrc,n=t.blendDst,a=t.blendEquation;if(s===Wc){let o=t.blendSrcAlpha===null?i:t.blendSrcAlpha,l=t.blendDstAlpha===null?n:t.blendDstAlpha,h=t.blendEquationAlpha===null?a:t.blendEquationAlpha;e={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=t.premultipliedAlpha,l=(h,u,c,d)=>{e={srcFactor:h,dstFactor:u,operation:Do.Add},r={srcFactor:c,dstFactor:d,operation:Do.Add}};if(o)switch(s){case oa:l(ze.One,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.One,ze.One,ze.One,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.SrcAlpha);break}else switch(s){case oa:l(ze.SrcAlpha,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.SrcAlpha,ze.One,ze.SrcAlpha,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.Src);break}}if(e!==void 0&&r!==void 0)return{color:e,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(t){let e;switch(t){case Ja:e=ze.Zero;break;case EN:e=ze.One;break;case PN:e=ze.Src;break;case FN:e=ze.OneMinusSrc;break;case Af:e=ze.SrcAlpha;break;case Cf:e=ze.OneMinusSrcAlpha;break;case zN:e=ze.Dst;break;case BN:e=ze.OneMinusDst;break;case LN:e=ze.DstAlpha;break;case IN:e=ze.OneMinusDstAlpha;break;case VN:e=ze.SrcAlphaSaturated;break;case oU:e=ze.Constant;break;case lU:e=ze.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",t)}return e}_getStencilCompare(t){let e,r=t.stencilFunc;switch(r){case Dz:e=kr.Never;break;case D0:e=kr.Always;break;case $z:e=kr.Less;break;case jz:e=kr.LessEqual;break;case Gz:e=kr.Equal;break;case qz:e=kr.GreaterEqual;break;case Wz:e=kr.Greater;break;case Hz:e=kr.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return e}_getStencilOperation(t){let e;switch(t){case Zo:e=Ua.Keep;break;case Iz:e=Ua.Zero;break;case zz:e=Ua.Replace;break;case Uz:e=Ua.Invert;break;case Bz:e=Ua.IncrementClamp;break;case Vz:e=Ua.DecrementClamp;break;case Oz:e=Ua.IncrementWrap;break;case kz:e=Ua.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",e)}return e}_getBlendOperation(t){let e;switch(t){case Hi:e=Do.Add;break;case CN:e=Do.Subtract;break;case RN:e=Do.ReverseSubtract;break;case yz:e=Do.Min;break;case xz:e=Do.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",t)}return e}_getPrimitiveState(t,e,r){let s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(t,r),e.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(s.stripIndexFormat=e.index.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32),r.side){case aa:s.frontFace=vx.CCW,s.cullMode=Tx.Back;break;case gs:s.frontFace=vx.CCW,s.cullMode=Tx.Front;break;case Hu:s.frontFace=vx.CCW,s.cullMode=Tx.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side);break}return s}_getColorWriteMask(t){return t.colorWrite===!0?WS.All:WS.None}_getDepthCompare(t){let e;if(t.depthTest===!1)e=kr.Always;else{let r=t.depthFunc;switch(r){case ON:e=kr.Never;break;case kN:e=kr.Always;break;case UN:e=kr.Less;break;case Rf:e=kr.LessEqual;break;case DN:e=kr.Equal;break;case $N:e=kr.GreaterEqual;break;case GN:e=kr.Greater;break;case jN:e=kr.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return e}},l7=class extends g3{constructor(t,e,r=2048){super(r),this.device=t,this.type=e,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${e}`});let s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${e}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${e}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(t){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ba(`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 e=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(t.id,e),e}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let t=new Map(this.queryOffsets),e=this.currentQueryIndex,r=e*8;this.currentQueryIndex=0,this.queryOffsets.clear();let s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,e,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let i=s.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a=0;for(let[,o]of t){let l=n[o],h=n[o+1],u=Number(h-l)/1e6;a+=u}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(t){return console.error("Error resolving queries:",t),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(t){console.error("Error waiting for pending resolve:",t)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(t){console.error("Error unmapping buffer:",t)}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}}},u7=class extends f3{constructor(t={}){super(t),this.isWebGPUBackend=!0,this.parameters.alpha=t.alpha===void 0?!0:t.alpha,this.parameters.compatibilityMode=t.compatibilityMode===void 0?!1:t.compatibilityMode,this.parameters.requiredLimits=t.requiredLimits===void 0?{}:t.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new t7(this),this.attributeUtils=new n7(this),this.bindingUtils=new a7(this),this.pipelineUtils=new o7(this),this.textureUtils=new W$(this),this.occludedResolveCache=new Map}async init(t){await super.init(t);let e=this.parameters,r;if(e.device===void 0){let n={powerPreference:e.powerPreference,featureLevel:e.compatibilityMode?"compatibility":void 0},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(n):null;if(a===null)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let o=Object.values(cb),l=[];for(let u of o)a.features.has(u)&&l.push(u);let h={requiredFeatures:l,requiredLimits:e.requiredLimits};r=await a.requestDevice(h)}else r=e.device;r.lost.then(n=>{let a={api:"WebGPU",message:n.message||"Unknown reason",reason:n.reason||null,originalEvent:n};t.onDeviceLost(a)});let s=e.context===void 0?t.domElement.getContext("webgpu"):e.context;this.device=r,this.context=s;let i=e.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(cb.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 Mn}async getArrayBufferAsync(t){return await this.attributeUtils.getArrayBufferAsync(t)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let t=this.defaultRenderPassdescriptor;if(t===null){let r=this.renderer;t={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(t.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(r.depth,r.stencil).createView()});let s=t.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=t}let e=t.colorAttachments[0];return this.renderer.samples>0?e.resolveTarget=this.context.getCurrentTexture().createView():e.view=this.context.getCurrentTexture().createView(),t}_isRenderCameraDepthArray(t){return t.depthTexture&&t.depthTexture.image.depth>1&&t.camera.isArrayCamera}_getRenderPassDescriptor(t,e={}){let r=t.renderTarget,s=this.get(r),i=s.descriptors;if(i===void 0||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==t.activeMipmapLevel||s.activeCubeFace!==t.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;let l=()=>{r.removeEventListener("dispose",l),this.delete(r)};r.hasEventListener("dispose",l)===!1&&r.addEventListener("dispose",l)}let n=t.getCacheKey(),a=i[n];if(a===void 0){let l=t.textures,h=[],u,c=this._isRenderCameraDepthArray(t);for(let d=0;d<l.length;d++){let p=this.get(l[d]),m={label:`colorAttachment_${d}`,baseMipLevel:t.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:t.activeCubeFace,arrayLayerCount:1,dimension:Br.TwoD};if(r.isRenderTarget3D)u=t.activeCubeFace,m.baseArrayLayer=0,m.dimension=Br.ThreeD,m.depthOrArrayLayers=l[d].image.depth;else if(r.isRenderTarget&&l[d].image.depth>1)if(c===!0){let f=t.camera.cameras;for(let g=0;g<f.length;g++){let b={...m,baseArrayLayer:g,arrayLayerCount:1,dimension:Br.TwoD},v=p.texture.createView(b);h.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Br.TwoDArray,m.depthOrArrayLayers=l[d].image.depth;if(c!==!0){let f=p.texture.createView(m),g,b;p.msaaTexture===void 0?(g=f,b=void 0):(g=p.msaaTexture.createView(),b=f),h.push({view:g,resolveTarget:b,depthSlice:u})}}if(a={textureViews:h},t.depth){let d=this.get(t.depthTexture),p={};t.depthTexture.isArrayTexture&&(p.dimension=Br.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=t.activeCubeFace),a.depthStencilView=d.texture.createView(p)}i[n]=a,s.width=r.width,s.height=r.height,s.samples=r.samples,s.activeMipmapLevel=t.activeMipmapLevel,s.activeCubeFace=t.activeCubeFace,s.dimensions=r.dimensions}let o={colorAttachments:[]};for(let l=0;l<a.textureViews.length;l++){let h=a.textureViews[l],u={r:0,g:0,b:0,a:1};l===0&&e.clearValue&&(u=e.clearValue),o.colorAttachments.push({view:h.view,depthSlice:h.depthSlice,resolveTarget:h.resolveTarget,loadOp:e.loadOp||tt.Load,storeOp:e.storeOp||cs.Store,clearValue:u})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(t){let e=this.get(t),r=this.device,s=t.occlusionQueryCount,i;s>0&&(e.currentOcclusionQuerySet&&e.currentOcclusionQuerySet.destroy(),e.currentOcclusionQueryBuffer&&e.currentOcclusionQueryBuffer.destroy(),e.currentOcclusionQuerySet=e.occlusionQuerySet,e.currentOcclusionQueryBuffer=e.occlusionQueryBuffer,e.currentOcclusionQueryObjects=e.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${t.id}`}),e.occlusionQuerySet=i,e.occlusionQueryIndex=0,e.occlusionQueryObjects=Array(s),e.lastOcclusionObject=null);let n;n=t.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(t,{loadOp:tt.Load}),this.initTimestampQuery(t,n),n.occlusionQuerySet=i;let a=n.depthStencilAttachment;if(t.textures!==null){let l=n.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];t.clearColor?(u.clearValue=h===0?t.clearColorValue:{r:0,g:0,b:0,a:1},u.loadOp=tt.Clear):u.loadOp=tt.Load,u.storeOp=cs.Store}}else{let l=n.colorAttachments[0];t.clearColor?(l.clearValue=t.clearColorValue,l.loadOp=tt.Clear):l.loadOp=tt.Load,l.storeOp=cs.Store}t.depth&&(t.clearDepth?(a.depthClearValue=t.clearDepthValue,a.depthLoadOp=tt.Clear):a.depthLoadOp=tt.Load,a.depthStoreOp=cs.Store),t.stencil&&(t.clearStencil?(a.stencilClearValue=t.clearStencilValue,a.stencilLoadOp=tt.Clear):a.stencilLoadOp=tt.Load,a.stencilStoreOp=cs.Store);let o=r.createCommandEncoder({label:"renderContext_"+t.id});if(this._isRenderCameraDepthArray(t)===!0){let l=t.camera.cameras;!e.layerDescriptors||e.layerDescriptors.length!==l.length?this._createDepthLayerDescriptors(t,e,n,l):this._updateDepthLayerDescriptors(t,e,l),e.bundleEncoders=[],e.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(t,"renderBundleArrayCamera_"+h),c={attributes:{},bindingGroups:[],pipeline:null,index:null};e.bundleEncoders.push(u),e.bundleSets.push(c)}e.currentPass=null}else{let l=o.beginRenderPass(n);if(e.currentPass=l,t.viewport&&this.updateViewport(t),t.scissor){let{x:h,y:u,width:c,height:d}=t.scissorValue;l.setScissorRect(h,u,c,d)}}e.descriptor=n,e.encoder=o,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.renderBundles=[]}_createDepthLayerDescriptors(t,e,r,s){let i=r.depthStencilAttachment;e.layerDescriptors=[];let n=this.get(t.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<s.length;a++){let o={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){let l=a;n.viewCache[l]||(n.viewCache[l]=n.texture.createView({dimension:Br.TwoD,baseArrayLayer:a,arrayLayerCount:1})),o.depthStencilAttachment={view:n.viewCache[l],depthLoadOp:i.depthLoadOp||tt.Clear,depthStoreOp:i.depthStoreOp||cs.Store,depthClearValue:i.depthClearValue||1},t.stencil&&(o.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,o.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,o.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else o.depthStencilAttachment={...i};e.layerDescriptors.push(o)}}_updateDepthLayerDescriptors(t,e,r){for(let s=0;s<r.length;s++){let i=e.layerDescriptors[s];if(i.depthStencilAttachment){let n=i.depthStencilAttachment;t.depth&&(t.clearDepth?(n.depthClearValue=t.clearDepthValue,n.depthLoadOp=tt.Clear):n.depthLoadOp=tt.Load),t.stencil&&(t.clearStencil?(n.stencilClearValue=t.clearStencilValue,n.stencilLoadOp=tt.Clear):n.stencilLoadOp=tt.Load)}}}finishRender(t){let e=this.get(t),r=t.occlusionQueryCount;e.renderBundles.length>0&&e.currentPass.executeBundles(e.renderBundles),r>e.occlusionQueryIndex&&e.currentPass.endOcclusionQuery();let s=e.encoder;if(this._isRenderCameraDepthArray(t)===!0){let i=[];for(let n=0;n<e.bundleEncoders.length;n++){let a=e.bundleEncoders[n];i.push(a.finish())}for(let n=0;n<e.layerDescriptors.length;n++)if(n<i.length){let a=e.layerDescriptors[n],o=s.beginRenderPass(a);if(t.viewport){let{x:l,y:h,width:u,height:c,minDepth:d,maxDepth:p}=t.viewportValue;o.setViewport(l,h,u,c,d,p)}if(t.scissor){let{x:l,y:h,width:u,height:c}=t.scissorValue;o.setScissorRect(l,h,u,c)}o.executeBundles([i[n]]),o.end()}}else e.currentPass&&e.currentPass.end();if(r>0){let i=r*8,n=this.occludedResolveCache.get(i);n===void 0&&(n=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,n));let a=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});e.encoder.resolveQuerySet(e.occlusionQuerySet,0,r,n,0),e.encoder.copyBufferToBuffer(n,0,a,0,i),e.occlusionQueryBuffer=a,this.resolveOccludedAsync(t)}if(this.device.queue.submit([e.encoder.finish()]),t.textures!==null){let i=t.textures;for(let n=0;n<i.length;n++){let a=i[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(t,e){let r=this.get(t);return r.occluded&&r.occluded.has(e)}async resolveOccludedAsync(t){let e=this.get(t),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:s}=e;if(r&&s){let i=new WeakSet;e.currentOcclusionQueryObjects=null,e.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);let n=r.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<s.length;o++)a[o]===BigInt(0)&&i.add(s[o]);r.destroy(),e.occluded=i}}updateViewport(t){let{currentPass:e}=this.get(t),{x:r,y:s,width:i,height:n,minDepth:a,maxDepth:o}=t.viewportValue;e.setViewport(r,s,i,n,a,o)}getClearColor(){let t=super.getClearColor();return this.renderer.alpha===!0&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}clear(t,e,r,s=null){let i=this.device,n=this.renderer,a=[],o,l,h,u;if(t){let p=this.getClearColor();l={r:p.r,g:p.g,b:p.b,a:p.a}}if(s===null){h=n.depth,u=n.stencil;let p=this._getDefaultRenderPassDescriptor();if(t){a=p.colorAttachments;let m=a[0];m.clearValue=l,m.loadOp=tt.Clear,m.storeOp=cs.Store}(h||u)&&(o=p.depthStencilAttachment)}else{h=s.depth,u=s.stencil;let p={loadOp:t?tt.Clear:tt.Load,clearValue:t?l:void 0};h&&(p.depthLoadOp=e?tt.Clear:tt.Load,p.depthClearValue=e?n.getClearDepth():void 0,p.depthStoreOp=cs.Store),u&&(p.stencilLoadOp=r?tt.Clear:tt.Load,p.stencilClearValue=r?n.getClearStencil():void 0,p.stencilStoreOp=cs.Store);let m=this._getRenderPassDescriptor(s,p);a=m.colorAttachments,o=m.depthStencilAttachment}h&&o&&o.depthLoadOp===void 0&&(e?(o.depthLoadOp=tt.Clear,o.depthClearValue=n.getClearDepth(),o.depthStoreOp=cs.Store):(o.depthLoadOp=tt.Load,o.depthStoreOp=cs.Store)),u&&o&&o.stencilLoadOp===void 0&&(r?(o.stencilLoadOp=tt.Clear,o.stencilClearValue=n.getClearStencil(),o.stencilStoreOp=cs.Store):(o.stencilLoadOp=tt.Load,o.stencilStoreOp=cs.Store));let c=i.createCommandEncoder({label:"clear"});c.beginRenderPass({colorAttachments:a,depthStencilAttachment:o}).end(),i.queue.submit([c.finish()])}beginCompute(t){let e=this.get(t),r={label:"computeGroup_"+t.id};this.initTimestampQuery(t,r),e.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+t.id}),e.passEncoderGPU=e.cmdEncoderGPU.beginComputePass(r)}compute(t,e,r,s){let{passEncoderGPU:i}=this.get(t),n=this.get(s).pipeline;this.pipelineUtils.setPipeline(i,n);for(let h=0,u=r.length;h<u;h++){let c=r[h],d=this.get(c);i.setBindGroup(h,d.group)}let a=this.device.limits.maxComputeWorkgroupsPerDimension,o=this.get(e);o.dispatchSize===void 0&&(o.dispatchSize={x:0,y:1,z:1});let{dispatchSize:l}=o;e.dispatchCount>a?(l.x=Math.min(e.dispatchCount,a),l.y=Math.ceil(e.dispatchCount/a)):l.x=e.dispatchCount,i.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(t){let e=this.get(t);e.passEncoderGPU.end(),this.device.queue.submit([e.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(t,e){let{object:r,material:s,context:i,pipeline:n}=t,a=t.getBindings(),o=this.get(i),l=this.get(n).pipeline,h=t.getIndex(),u=h!==null,c=t.getDrawParameters();if(c===null)return;let d=(m,f)=>{this.pipelineUtils.setPipeline(m,l),f.pipeline=l;let g=f.bindingGroups;for(let v=0,w=a.length;v<w;v++){let T=a[v],N=this.get(T);g[T.index]!==T.id&&(m.setBindGroup(T.index,N.group),g[T.index]=T.id)}if(u===!0&&f.index!==h){let v=this.get(h).buffer,w=h.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32;m.setIndexBuffer(v,w),f.index=h}let b=t.getVertexBuffers();for(let v=0,w=b.length;v<w;v++){let T=b[v];if(f.attributes[v]!==T){let N=this.get(T).buffer;m.setVertexBuffer(v,N),f.attributes[v]=T}}i.stencil===!0&&s.stencilWrite===!0&&o.currentStencilRef!==s.stencilRef&&(m.setStencilReference(s.stencilRef),o.currentStencilRef=s.stencilRef)},p=(m,f)=>{if(d(m,f),r.isBatchedMesh===!0){let g=r._multiDrawStarts,b=r._multiDrawCounts,v=r._multiDrawCount,w=r._multiDrawInstances;w!==null&&ba("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let T=0;T<v;T++){let N=w?w[T]:1,S=N>1?0:T;u===!0?m.drawIndexed(b[T],N,g[T]/h.array.BYTES_PER_ELEMENT,0,S):m.draw(b[T],N,g[T],S),e.update(r,b[T],N)}}else if(u===!0){let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndexedIndirect(T,0)}else m.drawIndexed(g,b,v,0,0);e.update(r,g,b)}else{let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndirect(T,0)}else m.draw(g,b,v,0);e.update(r,g,b)}};if(t.camera.isArrayCamera&&t.camera.cameras.length>0){let m=this.get(t.camera),f=t.camera.cameras,g=t.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==f.length){let v=this.get(g),w=[],T=new Uint32Array([0,0,0,0]);for(let N=0,S=f.length;N<S;N++){T[0]=N;let _=this.bindingUtils.createBindGroupIndex(T,v.layout);w.push(_)}m.indexesGPU=w}let b=this.renderer.getPixelRatio();for(let v=0,w=f.length;v<w;v++){let T=f[v];if(r.layers.test(T.layers)){let N=T.viewport,S=o.currentPass,_=o.currentSets;if(o.bundleEncoders){let A=o.bundleEncoders[v],D=o.bundleSets[v];S=A,_=D}N&&S.setViewport(Math.floor(N.x*b),Math.floor(N.y*b),Math.floor(N.width*b),Math.floor(N.height*b),i.viewportValue.minDepth,i.viewportValue.maxDepth),g&&m.indexesGPU&&(S.setBindGroup(g.index,m.indexesGPU[v]),_.bindingGroups[g.index]=g.id),p(S,_)}}}else if(o.currentPass){if(o.occlusionQuerySet!==void 0){let m=o.lastOcclusionObject;m!==r&&(m!==null&&m.occlusionTest===!0&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),r.occlusionTest===!0&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}p(o.currentPass,o.currentSets)}}needsRenderUpdate(t){let e=this.get(t),{object:r,material:s}=t,i=this.utils,n=i.getSampleCountRenderContext(t.context),a=i.getCurrentColorSpace(t.context),o=i.getCurrentColorFormat(t.context),l=i.getCurrentDepthStencilFormat(t.context),h=i.getPrimitiveTopology(r,s),u=!1;return(e.material!==s||e.materialVersion!==s.version||e.transparent!==s.transparent||e.blending!==s.blending||e.premultipliedAlpha!==s.premultipliedAlpha||e.blendSrc!==s.blendSrc||e.blendDst!==s.blendDst||e.blendEquation!==s.blendEquation||e.blendSrcAlpha!==s.blendSrcAlpha||e.blendDstAlpha!==s.blendDstAlpha||e.blendEquationAlpha!==s.blendEquationAlpha||e.colorWrite!==s.colorWrite||e.depthWrite!==s.depthWrite||e.depthTest!==s.depthTest||e.depthFunc!==s.depthFunc||e.stencilWrite!==s.stencilWrite||e.stencilFunc!==s.stencilFunc||e.stencilFail!==s.stencilFail||e.stencilZFail!==s.stencilZFail||e.stencilZPass!==s.stencilZPass||e.stencilFuncMask!==s.stencilFuncMask||e.stencilWriteMask!==s.stencilWriteMask||e.side!==s.side||e.alphaToCoverage!==s.alphaToCoverage||e.sampleCount!==n||e.colorSpace!==a||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.material=s,e.materialVersion=s.version,e.transparent=s.transparent,e.blending=s.blending,e.premultipliedAlpha=s.premultipliedAlpha,e.blendSrc=s.blendSrc,e.blendDst=s.blendDst,e.blendEquation=s.blendEquation,e.blendSrcAlpha=s.blendSrcAlpha,e.blendDstAlpha=s.blendDstAlpha,e.blendEquationAlpha=s.blendEquationAlpha,e.colorWrite=s.colorWrite,e.depthWrite=s.depthWrite,e.depthTest=s.depthTest,e.depthFunc=s.depthFunc,e.stencilWrite=s.stencilWrite,e.stencilFunc=s.stencilFunc,e.stencilFail=s.stencilFail,e.stencilZFail=s.stencilZFail,e.stencilZPass=s.stencilZPass,e.stencilFuncMask=s.stencilFuncMask,e.stencilWriteMask=s.stencilWriteMask,e.side=s.side,e.alphaToCoverage=s.alphaToCoverage,e.sampleCount=n,e.colorSpace=a,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.clippingContextCacheKey=t.clippingContextCacheKey,u=!0),u}getRenderCacheKey(t){let{object:e,material:r}=t,s=this.utils,i=t.context;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,s.getSampleCountRenderContext(i),s.getCurrentColorSpace(i),s.getCurrentColorFormat(i),s.getCurrentDepthStencilFormat(i),s.getPrimitiveTopology(e,r),t.getGeometryCacheKey(),t.clippingContextCacheKey].join()}createSampler(t){this.textureUtils.createSampler(t)}destroySampler(t){this.textureUtils.destroySampler(t)}createDefaultTexture(t){this.textureUtils.createDefaultTexture(t)}createTexture(t,e){this.textureUtils.createTexture(t,e)}updateTexture(t,e){this.textureUtils.updateTexture(t,e)}generateMipmaps(t){this.textureUtils.generateMipmaps(t)}destroyTexture(t){this.textureUtils.destroyTexture(t)}async copyTextureToBuffer(t,e,r,s,i,n){return this.textureUtils.copyTextureToBuffer(t,e,r,s,i,n)}initTimestampQuery(t,e){if(!this.trackTimestamp)return;let r=t.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new l7(this.device,r,2048));let s=this.timestampQueryPool[r],i=s.allocateQueriesForContext(t);e.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(t,e){return new e7(t,e)}createProgram(t){let e=this.get(t);e.module={module:this.device.createShaderModule({code:t.code,label:t.stage+(t.name===""?"":`_${t.name}`)}),entryPoint:"main"}}destroyProgram(t){this.delete(t)}createRenderPipeline(t,e){this.pipelineUtils.createRenderPipeline(t,e)}createComputePipeline(t,e){this.pipelineUtils.createComputePipeline(t,e)}beginBundle(t){let e=this.get(t);e._currentPass=e.currentPass,e._currentSets=e.currentSets,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentPass=this.pipelineUtils.createBundleEncoder(t)}finishBundle(t,e){let r=this.get(t),s=r.currentPass,i=s.finish();this.get(e).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(t,e){this.get(t).renderBundles.push(this.get(e).bundleGPU)}createBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBinding(t){this.bindingUtils.updateBinding(t)}createIndexAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(t){return this.device.features.has(t)}copyTextureToTexture(t,e,r=null,s=null,i=0,n=0){let a=0,o=0,l=0,h=0,u=0,c=0,d=t.image.width,p=t.image.height,m=1;r!==null&&(r.isBox3===!0?(h=r.min.x,u=r.min.y,c=r.min.z,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=r.max.z-r.min.z):(h=r.min.x,u=r.min.y,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=1)),s!==null&&(a=s.x,o=s.y,l=s.z||0);let f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+t.id+"_"+e.id}),g=this.get(t).texture,b=this.get(e).texture;f.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:h,y:u,z:c}},{texture:b,mipLevel:n,origin:{x:a,y:o,z:l}},[d,p,m]),this.device.queue.submit([f.finish()]),n===0&&e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}copyFramebufferToTexture(t,e,r){let s=this.get(e),i=null;i=e.renderTarget?t.isDepthTexture?this.get(e.depthTexture).texture:this.get(e.textures[0]).texture:t.isDepthTexture?this.textureUtils.getDepthBuffer(e.depth,e.stencil):this.context.getCurrentTexture();let n=this.get(t).texture;if(i.format!==n.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,n.format);return}let a;if(s.currentPass?(s.currentPass.end(),a=s.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+t.id}),a.copyTextureToTexture({texture:i,origin:[r.x,r.y,0]},{texture:n},[r.z,r.w]),s.currentPass){let{descriptor:o}=s;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=tt.Load;if(e.depth&&(o.depthStencilAttachment.depthLoadOp=tt.Load),e.stencil&&(o.depthStencilAttachment.stencilLoadOp=tt.Load),s.currentPass=a.beginRenderPass(o),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.viewport&&this.updateViewport(e),e.scissor){let{x:l,y:h,width:u,height:c}=e.scissorValue;s.currentPass.setScissorRect(l,h,u,c)}}else this.device.queue.submit([a.finish()]);t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}},h7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}},c7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}},d7=class extends l3{constructor(){super(),this.addMaterial(rk,"MeshPhongMaterial"),this.addMaterial(QR,"MeshStandardMaterial"),this.addMaterial(Dk,"MeshPhysicalMaterial"),this.addMaterial(Wk,"MeshToonMaterial"),this.addMaterial(VR,"MeshBasicMaterial"),this.addMaterial(ek,"MeshLambertMaterial"),this.addMaterial(j4,"MeshNormalMaterial"),this.addMaterial(Xk,"MeshMatcapMaterial"),this.addMaterial(V4,"LineBasicMaterial"),this.addMaterial(k4,"LineDashedMaterial"),this.addMaterial(Qk,"PointsMaterial"),this.addMaterial(eE,"SpriteMaterial"),this.addMaterial(tU,"ShadowMaterial"),this.addLight(t8,iV),this.addLight($9,aV),this.addLight(G9,lV),this.addLight(Ev,f1),this.addLight(q9,oV),this.addLight(X9,tV),this.addLight(Y9,hV),this.addLight(j9,h7),this.addLight(H9,c7),this.addToneMapping(SE,Tz),this.addToneMapping(ME,wz),this.addToneMapping(_E,Sz),this.addToneMapping(NE,Mz),this.addToneMapping(AE,_z),this.addToneMapping(CE,Nz)}},KS=class extends m${constructor(t={}){let e;t.forceWebGL?e=jS:(e=u7,t.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new jS(t)));let r=new e(t);super(r,t),this.library=new d7,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},_t={};cz(_t,{BRDF_GGX:()=>p7,BRDF_Lambert:()=>m7,BasicShadowFilter:()=>f7,Break:()=>g7,Const:()=>wj,Continue:()=>y7,DFGApprox:()=>x7,D_GGX:()=>b7,Discard:()=>v7,EPSILON:()=>T7,F_Schlick:()=>w7,Fn:()=>S7,INFINITY:()=>M7,If:()=>_7,Loop:()=>A7,NodeAccess:()=>P7,NodeShaderStage:()=>C7,NodeType:()=>R7,NodeUpdateType:()=>E7,PCFShadowFilter:()=>F7,PCFSoftShadowFilter:()=>L7,PI:()=>I7,PI2:()=>z7,Return:()=>B7,Schlick_to_F0:()=>V7,ScriptableNodeResources:()=>O7,ShaderNode:()=>k7,Switch:()=>N7,TBNViewMatrix:()=>U7,VSMShadowFilter:()=>D7,V_GGX_SmithCorrelated:()=>$7,Var:()=>CJ,abs:()=>G7,acesFilmicToneMapping:()=>j7,acos:()=>W7,add:()=>pb,addNodeElement:()=>H7,agxToneMapping:()=>q7,all:()=>X7,alphaT:()=>Y7,and:()=>Z7,anisotropy:()=>J7,anisotropyB:()=>Q7,anisotropyT:()=>K7,any:()=>eG,append:()=>tG,array:()=>rG,arrayBuffer:()=>sG,asin:()=>iG,assign:()=>nG,atan:()=>aG,atan2:()=>oG,atomicAdd:()=>lG,atomicAnd:()=>uG,atomicFunc:()=>hG,atomicLoad:()=>yG,atomicMax:()=>cG,atomicMin:()=>dG,atomicOr:()=>pG,atomicStore:()=>mG,atomicSub:()=>fG,atomicXor:()=>gG,attenuationColor:()=>xG,attenuationDistance:()=>bG,attribute:()=>vG,attributeArray:()=>TG,backgroundBlurriness:()=>wG,backgroundIntensity:()=>SG,backgroundRotation:()=>MG,batch:()=>_G,billboarding:()=>NG,bitAnd:()=>AG,bitNot:()=>CG,bitOr:()=>RG,bitXor:()=>EG,bitangentGeometry:()=>PG,bitangentLocal:()=>FG,bitangentView:()=>LG,bitangentWorld:()=>IG,bitcast:()=>zG,blendBurn:()=>BG,blendColor:()=>VG,blendDodge:()=>OG,blendOverlay:()=>kG,blendScreen:()=>UG,blur:()=>DG,bool:()=>$G,buffer:()=>GG,bufferAttribute:()=>jG,bumpMap:()=>WG,burn:()=>HG,bvec2:()=>qG,bvec3:()=>XG,bvec4:()=>YG,bypass:()=>ZG,cache:()=>JG,call:()=>QG,cameraFar:()=>KG,cameraIndex:()=>ej,cameraNear:()=>tj,cameraNormalMatrix:()=>rj,cameraPosition:()=>sj,cameraProjectionMatrix:()=>ij,cameraProjectionMatrixInverse:()=>nj,cameraViewMatrix:()=>aj,cameraWorldMatrix:()=>oj,cbrt:()=>lj,cdl:()=>uj,ceil:()=>hj,checker:()=>cj,cineonToneMapping:()=>dj,clamp:()=>x3,clearcoat:()=>pj,clearcoatRoughness:()=>mj,code:()=>fj,color:()=>gj,colorSpaceToWorking:()=>yj,colorToDirection:()=>xj,compute:()=>bj,computeSkinning:()=>vj,cond:()=>Tj,context:()=>Sj,convert:()=>Mj,convertColorSpace:()=>_j,convertToTexture:()=>Nj,cos:()=>ff,cross:()=>Aj,cubeTexture:()=>Cj,dFdx:()=>Rj,dFdy:()=>Ej,dashSize:()=>Pj,debug:()=>Fj,decrement:()=>Lj,decrementBefore:()=>Ij,defaultBuildStages:()=>zj,defaultShaderStages:()=>Bj,defined:()=>Vj,degrees:()=>Oj,deltaTime:()=>kj,densityFog:()=>Uj,densityFogFactor:()=>Dj,depth:()=>$j,depthPass:()=>Gj,difference:()=>jj,diffuseColor:()=>Wj,directPointLight:()=>Hj,directionToColor:()=>qj,dispersion:()=>Xj,distance:()=>Yj,div:()=>Zj,dodge:()=>Jj,dot:()=>wd,drawIndex:()=>Qj,dynamicBufferAttribute:()=>Kj,element:()=>eW,emissive:()=>tW,equal:()=>rW,equals:()=>sW,equirectUV:()=>iW,exp:()=>nW,exp2:()=>aW,expression:()=>oW,faceDirection:()=>lW,faceForward:()=>uW,faceforward:()=>hW,float:()=>mb,floor:()=>cW,fog:()=>dW,fract:()=>fb,frameGroup:()=>pW,frameId:()=>mW,frontFacing:()=>fW,fwidth:()=>b3,gain:()=>gW,gapSize:()=>yW,getConstNodeType:()=>xW,getCurrentStack:()=>bW,getDirection:()=>vW,getDistanceAttenuation:()=>TW,getGeometryRoughness:()=>wW,getNormalFromDepth:()=>SW,getParallaxCorrectNormal:()=>MW,getRoughness:()=>_W,getScreenPosition:()=>NW,getShIrradianceAt:()=>AW,getShadowMaterial:()=>EW,getShadowRenderObjectFunction:()=>PW,getTextureIndex:()=>CW,getViewPosition:()=>RW,globalId:()=>SH,glsl:()=>FW,glslFn:()=>LW,grayscale:()=>IW,greaterThan:()=>zW,greaterThanEqual:()=>BW,hash:()=>VW,highpModelNormalViewMatrix:()=>OW,highpModelViewMatrix:()=>kW,hue:()=>UW,increment:()=>DW,incrementBefore:()=>$W,instance:()=>GW,instanceIndex:()=>jW,instancedArray:()=>WW,instancedBufferAttribute:()=>HW,instancedDynamicBufferAttribute:()=>qW,instancedMesh:()=>XW,int:()=>YW,inverseSqrt:()=>ZW,inversesqrt:()=>JW,invocationLocalIndex:()=>QW,invocationSubgroupIndex:()=>KW,ior:()=>eH,iridescence:()=>tH,iridescenceIOR:()=>rH,iridescenceThickness:()=>sH,ivec2:()=>iH,ivec3:()=>nH,ivec4:()=>aH,js:()=>oH,label:()=>lH,length:()=>uH,lengthSq:()=>hH,lessThan:()=>cH,lessThanEqual:()=>dH,lightPosition:()=>pH,lightProjectionUV:()=>xY,lightShadowMatrix:()=>mH,lightTargetDirection:()=>fH,lightTargetPosition:()=>gH,lightViewPosition:()=>yH,lightingContext:()=>xH,lights:()=>bH,linearDepth:()=>vH,linearToneMapping:()=>TH,localId:()=>wH,log:()=>MH,log2:()=>_H,logarithmicDepthToViewZ:()=>NH,loop:()=>AH,luminance:()=>CH,mat2:()=>EH,mat3:()=>PH,mat4:()=>FH,matcapUV:()=>LH,materialAO:()=>IH,materialAlphaTest:()=>zH,materialAnisotropy:()=>BH,materialAnisotropyVector:()=>VH,materialAttenuationColor:()=>OH,materialAttenuationDistance:()=>kH,materialClearcoat:()=>UH,materialClearcoatNormal:()=>DH,materialClearcoatRoughness:()=>$H,materialColor:()=>GH,materialDispersion:()=>jH,materialEmissive:()=>WH,materialIOR:()=>HH,materialIridescence:()=>qH,materialIridescenceIOR:()=>XH,materialIridescenceThickness:()=>YH,materialLightMap:()=>ZH,materialLineDashOffset:()=>JH,materialLineDashSize:()=>QH,materialLineGapSize:()=>KH,materialLineScale:()=>eq,materialLineWidth:()=>tq,materialMetalness:()=>rq,materialNormal:()=>sq,materialOpacity:()=>iq,materialPointSize:()=>nq,materialReference:()=>aq,materialReflectivity:()=>oq,materialRefractionRatio:()=>lq,materialRotation:()=>uq,materialRoughness:()=>hq,materialSheen:()=>cq,materialSheenRoughness:()=>dq,materialShininess:()=>pq,materialSpecular:()=>mq,materialSpecularColor:()=>fq,materialSpecularIntensity:()=>gq,materialSpecularStrength:()=>yq,materialThickness:()=>xq,materialTransmission:()=>bq,max:()=>v3,maxMipLevel:()=>vq,mediumpModelViewMatrix:()=>RH,metalness:()=>Tq,min:()=>wq,mix:()=>ml,mixElement:()=>Sq,mod:()=>Mq,modInt:()=>_q,modelDirection:()=>Nq,modelNormalMatrix:()=>Aq,modelPosition:()=>Cq,modelRadius:()=>Rq,modelScale:()=>Eq,modelViewMatrix:()=>Pq,modelViewPosition:()=>Fq,modelViewProjection:()=>Lq,modelWorldMatrix:()=>Iq,modelWorldMatrixInverse:()=>zq,morphReference:()=>Bq,mrt:()=>Vq,mul:()=>qs,mx_aastep:()=>Oq,mx_cell_noise_float:()=>kq,mx_contrast:()=>Uq,mx_fractal_noise_float:()=>Dq,mx_fractal_noise_vec2:()=>$q,mx_fractal_noise_vec3:()=>Gq,mx_fractal_noise_vec4:()=>jq,mx_hsvtorgb:()=>Wq,mx_noise_float:()=>Hq,mx_noise_vec3:()=>qq,mx_noise_vec4:()=>Xq,mx_ramplr:()=>Yq,mx_ramptb:()=>Zq,mx_rgbtohsv:()=>Jq,mx_safepower:()=>Qq,mx_splitlr:()=>Kq,mx_splittb:()=>eX,mx_srgb_texture_to_lin_rec709:()=>tX,mx_transform_uv:()=>rX,mx_worley_noise_float:()=>sX,mx_worley_noise_vec2:()=>iX,mx_worley_noise_vec3:()=>nX,namespace:()=>aX,negate:()=>oX,neutralToneMapping:()=>lX,nodeArray:()=>uX,nodeImmutable:()=>hX,nodeObject:()=>cX,nodeObjects:()=>dX,nodeProxy:()=>pX,normalFlat:()=>mX,normalGeometry:()=>fX,normalLocal:()=>gX,normalMap:()=>yX,normalView:()=>xX,normalWorld:()=>bX,normalize:()=>vX,not:()=>TX,notEqual:()=>wX,numWorkgroups:()=>SX,objectDirection:()=>MX,objectGroup:()=>_X,objectPosition:()=>NX,objectRadius:()=>AX,objectScale:()=>CX,objectViewPosition:()=>RX,objectWorldMatrix:()=>EX,oneMinus:()=>PX,or:()=>FX,orthographicDepthToViewZ:()=>LX,oscSawtooth:()=>IX,oscSine:()=>zX,oscSquare:()=>BX,oscTriangle:()=>VX,output:()=>OX,outputStruct:()=>kX,overlay:()=>UX,overloadingFn:()=>DX,parabola:()=>$X,parallaxDirection:()=>GX,parallaxUV:()=>jX,parameter:()=>WX,pass:()=>HX,passTexture:()=>qX,pcurve:()=>XX,perspectiveDepthToViewZ:()=>YX,pmremTexture:()=>ZX,pointShadow:()=>rZ,pointUV:()=>JX,pointWidth:()=>QX,positionGeometry:()=>KX,positionLocal:()=>eY,positionPrevious:()=>tY,positionView:()=>rY,positionViewDirection:()=>sY,positionWorld:()=>iY,positionWorldDirection:()=>nY,posterize:()=>aY,pow:()=>T3,pow2:()=>oY,pow3:()=>lY,pow4:()=>uY,premult:()=>hY,property:()=>cY,radians:()=>dY,rand:()=>pY,range:()=>mY,rangeFog:()=>fY,rangeFogFactor:()=>gY,reciprocal:()=>yY,reference:()=>bY,referenceBuffer:()=>vY,reflect:()=>TY,reflectVector:()=>wY,reflectView:()=>SY,reflector:()=>MY,refract:()=>_Y,refractVector:()=>NY,refractView:()=>AY,reinhardToneMapping:()=>CY,remainder:()=>RY,remap:()=>EY,remapClamp:()=>PY,renderGroup:()=>FY,renderOutput:()=>LY,rendererReference:()=>IY,rotate:()=>zY,rotateUV:()=>BY,roughness:()=>VY,round:()=>OY,rtt:()=>kY,sRGBTransferEOTF:()=>UY,sRGBTransferOETF:()=>DY,sampler:()=>$Y,samplerComparison:()=>GY,saturate:()=>jY,saturation:()=>WY,screen:()=>HY,screenCoordinate:()=>qY,screenSize:()=>XY,screenUV:()=>YY,scriptable:()=>ZY,scriptableValue:()=>JY,select:()=>QY,setCurrentStack:()=>KY,shaderStages:()=>eZ,shadow:()=>tZ,shadowPositionWorld:()=>sZ,shapeCircle:()=>nZ,sharedUniformGroup:()=>iZ,sheen:()=>aZ,sheenRoughness:()=>oZ,shiftLeft:()=>lZ,shiftRight:()=>uZ,shininess:()=>hZ,sign:()=>cZ,sin:()=>no,sinc:()=>dZ,skinning:()=>pZ,smoothstep:()=>gb,smoothstepElement:()=>mZ,specularColor:()=>fZ,specularF90:()=>gZ,spherizeUV:()=>yZ,split:()=>xZ,spritesheetUV:()=>bZ,sqrt:()=>vZ,stack:()=>TZ,step:()=>wZ,storage:()=>SZ,storageBarrier:()=>MZ,storageObject:()=>_Z,storageTexture:()=>NZ,string:()=>AZ,struct:()=>CZ,sub:()=>Sd,subgroupIndex:()=>RZ,subgroupSize:()=>EZ,tan:()=>PZ,tangentGeometry:()=>FZ,tangentLocal:()=>LZ,tangentView:()=>IZ,tangentWorld:()=>zZ,temp:()=>BZ,texture:()=>VZ,texture3D:()=>OZ,textureBarrier:()=>kZ,textureBicubic:()=>UZ,textureCubeUV:()=>DZ,textureLoad:()=>$Z,textureSize:()=>GZ,textureStore:()=>jZ,thickness:()=>WZ,time:()=>Lv,timerDelta:()=>HZ,timerGlobal:()=>qZ,timerLocal:()=>XZ,toneMapping:()=>YZ,toneMappingExposure:()=>ZZ,toonOutlinePass:()=>JZ,transformDirection:()=>QZ,transformNormal:()=>KZ,transformNormalToView:()=>eJ,transformedBentNormalView:()=>tJ,transformedBitangentView:()=>rJ,transformedBitangentWorld:()=>sJ,transformedClearcoatNormalView:()=>iJ,transformedNormalView:()=>nJ,transformedNormalWorld:()=>aJ,transformedTangentView:()=>oJ,transformedTangentWorld:()=>lJ,transmission:()=>uJ,transpose:()=>hJ,triNoise3D:()=>cJ,triplanarTexture:()=>dJ,triplanarTextures:()=>pJ,trunc:()=>mJ,tslFn:()=>fJ,uint:()=>gJ,uniform:()=>yJ,uniformArray:()=>bJ,uniformCubeTexture:()=>xJ,uniformGroup:()=>vJ,uniformTexture:()=>TJ,uniforms:()=>wJ,unpremult:()=>SJ,userData:()=>MJ,uv:()=>Iv,uvec2:()=>_J,uvec3:()=>NJ,uvec4:()=>AJ,varying:()=>RJ,varyingProperty:()=>EJ,vec2:()=>zv,vec3:()=>Bv,vec4:()=>Ur,vectorComponents:()=>PJ,velocity:()=>FJ,vertexColor:()=>LJ,vertexIndex:()=>IJ,vibrance:()=>zJ,viewZToLogarithmicDepth:()=>BJ,viewZToOrthographicDepth:()=>VJ,viewZToPerspectiveDepth:()=>OJ,viewport:()=>kJ,viewportBottomLeft:()=>UJ,viewportCoordinate:()=>DJ,viewportDepthTexture:()=>$J,viewportLinearDepth:()=>GJ,viewportMipTexture:()=>jJ,viewportResolution:()=>WJ,viewportSafeUV:()=>HJ,viewportSharedTexture:()=>qJ,viewportSize:()=>XJ,viewportTexture:()=>YJ,viewportTopLeft:()=>ZJ,viewportUV:()=>JJ,wgsl:()=>QJ,wgslFn:()=>KJ,workgroupArray:()=>eQ,workgroupBarrier:()=>tQ,workgroupId:()=>rQ,workingToColorSpace:()=>sQ,xor:()=>iQ});const p7=y.BRDF_GGX,m7=y.BRDF_Lambert,f7=y.BasicShadowFilter,g7=y.Break,y7=y.Continue,x7=y.DFGApprox,b7=y.D_GGX,v7=y.Discard,T7=y.EPSILON,w7=y.F_Schlick,S7=y.Fn,M7=y.INFINITY,_7=y.If,N7=y.Switch,A7=y.Loop,C7=y.NodeShaderStage,R7=y.NodeType,E7=y.NodeUpdateType,P7=y.NodeAccess,F7=y.PCFShadowFilter,L7=y.PCFSoftShadowFilter,I7=y.PI,z7=y.PI2,B7=y.Return,V7=y.Schlick_to_F0,O7=y.ScriptableNodeResources,k7=y.ShaderNode,U7=y.TBNViewMatrix,D7=y.VSMShadowFilter,$7=y.V_GGX_SmithCorrelated,G7=y.abs,j7=y.acesFilmicToneMapping,W7=y.acos,pb=y.add,H7=y.addNodeElement,q7=y.agxToneMapping,X7=y.all,Y7=y.alphaT,Z7=y.and,J7=y.anisotropy,Q7=y.anisotropyB,K7=y.anisotropyT,eG=y.any,tG=y.append,rG=y.array,sG=y.arrayBuffer,iG=y.asin,nG=y.assign,aG=y.atan,oG=y.atan2,lG=y.atomicAdd,uG=y.atomicAnd,hG=y.atomicFunc,cG=y.atomicMax,dG=y.atomicMin,pG=y.atomicOr,mG=y.atomicStore,fG=y.atomicSub,gG=y.atomicXor,yG=y.atomicLoad,xG=y.attenuationColor,bG=y.attenuationDistance,vG=y.attribute,TG=y.attributeArray,wG=y.backgroundBlurriness,SG=y.backgroundIntensity,MG=y.backgroundRotation,_G=y.batch,NG=y.billboarding,AG=y.bitAnd,CG=y.bitNot,RG=y.bitOr,EG=y.bitXor,PG=y.bitangentGeometry,FG=y.bitangentLocal,LG=y.bitangentView,IG=y.bitangentWorld,zG=y.bitcast,BG=y.blendBurn,VG=y.blendColor,OG=y.blendDodge,kG=y.blendOverlay,UG=y.blendScreen,DG=y.blur,$G=y.bool,GG=y.buffer,jG=y.bufferAttribute,WG=y.bumpMap,HG=y.burn,qG=y.bvec2,XG=y.bvec3,YG=y.bvec4,ZG=y.bypass,JG=y.cache,QG=y.call,KG=y.cameraFar,ej=y.cameraIndex,tj=y.cameraNear,rj=y.cameraNormalMatrix,sj=y.cameraPosition,ij=y.cameraProjectionMatrix,nj=y.cameraProjectionMatrixInverse,aj=y.cameraViewMatrix,oj=y.cameraWorldMatrix,lj=y.cbrt,uj=y.cdl,hj=y.ceil,cj=y.checker,dj=y.cineonToneMapping,x3=y.clamp,pj=y.clearcoat,mj=y.clearcoatRoughness,fj=y.code,gj=y.color,yj=y.colorSpaceToWorking,xj=y.colorToDirection,bj=y.compute,vj=y.computeSkinning,Tj=y.cond,wj=y.Const,Sj=y.context,Mj=y.convert,_j=y.convertColorSpace,Nj=y.convertToTexture,ff=y.cos,Aj=y.cross,Cj=y.cubeTexture,Rj=y.dFdx,Ej=y.dFdy,Pj=y.dashSize,Fj=y.debug,Lj=y.decrement,Ij=y.decrementBefore,zj=y.defaultBuildStages,Bj=y.defaultShaderStages,Vj=y.defined,Oj=y.degrees,kj=y.deltaTime,Uj=y.densityFog,Dj=y.densityFogFactor,$j=y.depth,Gj=y.depthPass,jj=y.difference,Wj=y.diffuseColor,Hj=y.directPointLight,qj=y.directionToColor,Xj=y.dispersion,Yj=y.distance,Zj=y.div,Jj=y.dodge,wd=y.dot,Qj=y.drawIndex,Kj=y.dynamicBufferAttribute,eW=y.element,tW=y.emissive,rW=y.equal,sW=y.equals,iW=y.equirectUV,nW=y.exp,aW=y.exp2,oW=y.expression,lW=y.faceDirection,uW=y.faceForward,hW=y.faceforward,mb=y.float,cW=y.floor,dW=y.fog,fb=y.fract,pW=y.frameGroup,mW=y.frameId,fW=y.frontFacing,b3=y.fwidth,gW=y.gain,yW=y.gapSize,xW=y.getConstNodeType,bW=y.getCurrentStack,vW=y.getDirection,TW=y.getDistanceAttenuation,wW=y.getGeometryRoughness,SW=y.getNormalFromDepth,MW=y.getParallaxCorrectNormal,_W=y.getRoughness,NW=y.getScreenPosition,AW=y.getShIrradianceAt,CW=y.getTextureIndex,RW=y.getViewPosition,EW=y.getShadowMaterial,PW=y.getShadowRenderObjectFunction,FW=y.glsl,LW=y.glslFn,IW=y.grayscale,zW=y.greaterThan,BW=y.greaterThanEqual,VW=y.hash,OW=y.highpModelNormalViewMatrix,kW=y.highpModelViewMatrix,UW=y.hue,DW=y.increment,$W=y.incrementBefore,GW=y.instance,jW=y.instanceIndex,WW=y.instancedArray,HW=y.instancedBufferAttribute,qW=y.instancedDynamicBufferAttribute,XW=y.instancedMesh,YW=y.int,ZW=y.inverseSqrt,JW=y.inversesqrt,QW=y.invocationLocalIndex,KW=y.invocationSubgroupIndex,eH=y.ior,tH=y.iridescence,rH=y.iridescenceIOR,sH=y.iridescenceThickness,iH=y.ivec2,nH=y.ivec3,aH=y.ivec4,oH=y.js,lH=y.label,uH=y.length,hH=y.lengthSq,cH=y.lessThan,dH=y.lessThanEqual,pH=y.lightPosition,mH=y.lightShadowMatrix,fH=y.lightTargetDirection,gH=y.lightTargetPosition,yH=y.lightViewPosition,xH=y.lightingContext,bH=y.lights,vH=y.linearDepth,TH=y.linearToneMapping,wH=y.localId,SH=y.globalId,MH=y.log,_H=y.log2,NH=y.logarithmicDepthToViewZ,AH=y.loop,CH=y.luminance,RH=y.mediumpModelViewMatrix,EH=y.mat2,PH=y.mat3,FH=y.mat4,LH=y.matcapUV,IH=y.materialAO,zH=y.materialAlphaTest,BH=y.materialAnisotropy,VH=y.materialAnisotropyVector,OH=y.materialAttenuationColor,kH=y.materialAttenuationDistance,UH=y.materialClearcoat,DH=y.materialClearcoatNormal,$H=y.materialClearcoatRoughness,GH=y.materialColor,jH=y.materialDispersion,WH=y.materialEmissive,HH=y.materialIOR,qH=y.materialIridescence,XH=y.materialIridescenceIOR,YH=y.materialIridescenceThickness,ZH=y.materialLightMap,JH=y.materialLineDashOffset,QH=y.materialLineDashSize,KH=y.materialLineGapSize,eq=y.materialLineScale,tq=y.materialLineWidth,rq=y.materialMetalness,sq=y.materialNormal,iq=y.materialOpacity,nq=y.materialPointSize,aq=y.materialReference,oq=y.materialReflectivity,lq=y.materialRefractionRatio,uq=y.materialRotation,hq=y.materialRoughness,cq=y.materialSheen,dq=y.materialSheenRoughness,pq=y.materialShininess,mq=y.materialSpecular,fq=y.materialSpecularColor,gq=y.materialSpecularIntensity,yq=y.materialSpecularStrength,xq=y.materialThickness,bq=y.materialTransmission,v3=y.max,vq=y.maxMipLevel,Tq=y.metalness,wq=y.min,ml=y.mix,Sq=y.mixElement,Mq=y.mod,_q=y.modInt,Nq=y.modelDirection,Aq=y.modelNormalMatrix,Cq=y.modelPosition,Rq=y.modelRadius,Eq=y.modelScale,Pq=y.modelViewMatrix,Fq=y.modelViewPosition,Lq=y.modelViewProjection,Iq=y.modelWorldMatrix,zq=y.modelWorldMatrixInverse,Bq=y.morphReference,Vq=y.mrt,qs=y.mul,Oq=y.mx_aastep,kq=y.mx_cell_noise_float,Uq=y.mx_contrast,Dq=y.mx_fractal_noise_float,$q=y.mx_fractal_noise_vec2,Gq=y.mx_fractal_noise_vec3,jq=y.mx_fractal_noise_vec4,Wq=y.mx_hsvtorgb,Hq=y.mx_noise_float,qq=y.mx_noise_vec3,Xq=y.mx_noise_vec4,Yq=y.mx_ramplr,Zq=y.mx_ramptb,Jq=y.mx_rgbtohsv,Qq=y.mx_safepower,Kq=y.mx_splitlr,eX=y.mx_splittb,tX=y.mx_srgb_texture_to_lin_rec709,rX=y.mx_transform_uv,sX=y.mx_worley_noise_float,iX=y.mx_worley_noise_vec2,nX=y.mx_worley_noise_vec3,aX=y.namespace,oX=y.negate,lX=y.neutralToneMapping,uX=y.nodeArray,hX=y.nodeImmutable,cX=y.nodeObject,dX=y.nodeObjects,pX=y.nodeProxy,mX=y.normalFlat,fX=y.normalGeometry,gX=y.normalLocal,yX=y.normalMap,xX=y.normalView,bX=y.normalWorld,vX=y.normalize,TX=y.not,wX=y.notEqual,SX=y.numWorkgroups,MX=y.objectDirection,_X=y.objectGroup,NX=y.objectPosition,AX=y.objectRadius,CX=y.objectScale,RX=y.objectViewPosition,EX=y.objectWorldMatrix,PX=y.oneMinus,FX=y.or,LX=y.orthographicDepthToViewZ,IX=y.oscSawtooth,zX=y.oscSine,BX=y.oscSquare,VX=y.oscTriangle,OX=y.output,kX=y.outputStruct,UX=y.overlay,DX=y.overloadingFn,$X=y.parabola,GX=y.parallaxDirection,jX=y.parallaxUV,WX=y.parameter,HX=y.pass,qX=y.passTexture,XX=y.pcurve,YX=y.perspectiveDepthToViewZ,ZX=y.pmremTexture,JX=y.pointUV,QX=y.pointWidth,KX=y.positionGeometry,eY=y.positionLocal,tY=y.positionPrevious,rY=y.positionView,sY=y.positionViewDirection,iY=y.positionWorld,nY=y.positionWorldDirection,aY=y.posterize,T3=y.pow,oY=y.pow2,lY=y.pow3,uY=y.pow4,hY=y.premult,cY=y.property,dY=y.radians,pY=y.rand,mY=y.range,fY=y.rangeFog,gY=y.rangeFogFactor,yY=y.reciprocal,xY=y.lightProjectionUV,bY=y.reference,vY=y.referenceBuffer,TY=y.reflect,wY=y.reflectVector,SY=y.reflectView,MY=y.reflector,_Y=y.refract,NY=y.refractVector,AY=y.refractView,CY=y.reinhardToneMapping,RY=y.remainder,EY=y.remap,PY=y.remapClamp,FY=y.renderGroup,LY=y.renderOutput,IY=y.rendererReference,zY=y.rotate,BY=y.rotateUV,VY=y.roughness,OY=y.round,kY=y.rtt,UY=y.sRGBTransferEOTF,DY=y.sRGBTransferOETF,$Y=y.sampler,GY=y.samplerComparison,jY=y.saturate,WY=y.saturation,HY=y.screen,qY=y.screenCoordinate,XY=y.screenSize,YY=y.screenUV,ZY=y.scriptable,JY=y.scriptableValue,QY=y.select,KY=y.setCurrentStack,eZ=y.shaderStages,tZ=y.shadow,rZ=y.pointShadow,sZ=y.shadowPositionWorld,iZ=y.sharedUniformGroup,nZ=y.shapeCircle,aZ=y.sheen,oZ=y.sheenRoughness,lZ=y.shiftLeft,uZ=y.shiftRight,hZ=y.shininess,cZ=y.sign,no=y.sin,dZ=y.sinc,pZ=y.skinning,gb=y.smoothstep,mZ=y.smoothstepElement,fZ=y.specularColor,gZ=y.specularF90,yZ=y.spherizeUV,xZ=y.split,bZ=y.spritesheetUV,vZ=y.sqrt,TZ=y.stack,wZ=y.step,SZ=y.storage,MZ=y.storageBarrier,_Z=y.storageObject,NZ=y.storageTexture,AZ=y.string,CZ=y.struct,Sd=y.sub,RZ=y.subgroupIndex,EZ=y.subgroupSize,PZ=y.tan,FZ=y.tangentGeometry,LZ=y.tangentLocal,IZ=y.tangentView,zZ=y.tangentWorld,BZ=y.temp,VZ=y.texture,OZ=y.texture3D,kZ=y.textureBarrier,UZ=y.textureBicubic,DZ=y.textureCubeUV,$Z=y.textureLoad,GZ=y.textureSize,jZ=y.textureStore,WZ=y.thickness,Lv=y.time,HZ=y.timerDelta,qZ=y.timerGlobal,XZ=y.timerLocal,YZ=y.toneMapping,ZZ=y.toneMappingExposure,JZ=y.toonOutlinePass,QZ=y.transformDirection,KZ=y.transformNormal,eJ=y.transformNormalToView,tJ=y.transformedBentNormalView,rJ=y.transformedBitangentView,sJ=y.transformedBitangentWorld,iJ=y.transformedClearcoatNormalView,nJ=y.transformedNormalView,aJ=y.transformedNormalWorld,oJ=y.transformedTangentView,lJ=y.transformedTangentWorld,uJ=y.transmission,hJ=y.transpose,cJ=y.triNoise3D,dJ=y.triplanarTexture,pJ=y.triplanarTextures,mJ=y.trunc,fJ=y.tslFn,gJ=y.uint,yJ=y.uniform,xJ=y.uniformCubeTexture,bJ=y.uniformArray,vJ=y.uniformGroup,TJ=y.uniformTexture,wJ=y.uniforms,SJ=y.unpremult,MJ=y.userData,Iv=y.uv,_J=y.uvec2,NJ=y.uvec3,AJ=y.uvec4,CJ=y.Var,RJ=y.varying,EJ=y.varyingProperty,zv=y.vec2,Bv=y.vec3,Ur=y.vec4,PJ=y.vectorComponents,FJ=y.velocity,LJ=y.vertexColor,IJ=y.vertexIndex,zJ=y.vibrance,BJ=y.viewZToLogarithmicDepth,VJ=y.viewZToOrthographicDepth,OJ=y.viewZToPerspectiveDepth,kJ=y.viewport,UJ=y.viewportBottomLeft,DJ=y.viewportCoordinate,$J=y.viewportDepthTexture,GJ=y.viewportLinearDepth,jJ=y.viewportMipTexture,WJ=y.viewportResolution,HJ=y.viewportSafeUV,qJ=y.viewportSharedTexture,XJ=y.viewportSize,YJ=y.viewportTexture,ZJ=y.viewportTopLeft,JJ=y.viewportUV,QJ=y.wgsl,KJ=y.wgslFn,eQ=y.workgroupArray,tQ=y.workgroupBarrier,rQ=y.workgroupId,sQ=y.workingToColorSpace,iQ=y.xor;function nQ(t,e,r=1){let s=t.rgb,i=e.rgb,n=qs(s,i),a=qs(e.a,r),o=ml(s,n,a),l=v3(t.a,qs(e.a,r));return Ur(o,l)}function aQ(t,e,r=1){let s=qs(e.a,r),i=pb(s,qs(t.a,Sd(1,s))),n=pb(qs(e.rgb,s),qs(t.rgb,qs(t.a,Sd(1,s))));return Ur(n,i)}const eM={normal:aQ,multiply:nQ};function au(t,e,r="normal",s=1){return(eM[r]||eM.normal)(t,e,s)}function oQ(t,e){let r=qs(t.a,e.a);return Ur(t.rgb,r)}function lQ(t,e){let r=Sd(1,e.a),s=qs(t.a,r);return Ur(t.rgb,s)}function uQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=qs(t.a,s);return Ur(t.rgb,i)}function hQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=Sd(1,s),n=qs(t.a,i);return Ur(t.rgb,n)}const tM={alpha:oQ,alphaInverted:lQ,luminance:uQ,luminanceInverted:hQ};function cQ(t,e,r="alpha"){return(tM[r]||tM.alpha)(t,e)}const rM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};let sM=!1;const dQ=()=>{try{if(rM!==void 0){let{MODE:t,DEV:e}=rM;return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function pQ(){let t=`renderer_${Math.random().toString(36).substring(2,11)}`,e=null,r,s,i,n,a,o={nodes:new Map,rootId:null,idToNodeId:new Map},l=null,h=null,u=null,c=!1,d=!1,p=!1,m=null,f=!1,g=!0,b=0,v=0,w=0,T=0,N=8,S=.5,_=.5,A=!1,D=!1,K=!1,J=[],re=!1,te=[],oe=!1,ae=()=>{var le;return(le=window).matchMedia?.call(le,"(prefers-reduced-motion: reduce)").matches??!1},ge=(le,pe)=>{if(le===b&&pe===v)return;let ye=performance.now();if(ye-w<N)return;b=le,v=pe,w=ye,r.setSize(le,pe,!1);let Re=le/pe,bt=2,or=bt*Re;s.left=-or/2,s.right=or/2,s.top=bt/2,s.bottom=-2/2,s.updateProjectionMatrix(),n.scale.set(or,bt,1),o.rootId&&p&&me(),qt().catch(console.warn)},fe=le=>{if(!r||!s||!n)return;let pe=le[0];if(!pe)return;let{width:ye,height:Re}=pe.contentRect,bt=Math.round(ye),or=Math.round(Re);ge(bt,or)},ve=le=>{let pe=le[0];pe&&(f=pe.isIntersecting,f?(a&&c&&o.rootId&&me(),g&&br()):Pi())},me=()=>{if(!o.rootId||!a||D)return;if(o.nodes.get(o.rootId)){D=!0;try{let pe=ft(o.rootId);pe&&a&&(a.fragmentNode=pe,a.needsUpdate=!0)}catch(pe){console.error("Error composing shader tree:",pe)}finally{D=!1}f&&qt().catch(console.warn)}},he=le=>{let pe=[];return o.nodes.forEach(ye=>{ye.parentId===le&&pe.push(ye)}),pe},Te=le=>{for(let[pe,ye]of o.nodes.entries())if(ye.metadata.id===le)return pe;return null},Ge=(le,pe,ye,Re)=>{if(!pe.metadata.mask?.source)return le;let bt=pe.metadata.mask.source,or=Te(bt);if(!or)return le;if(Re.has(or))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),le;let Lo=new Set(Re);Lo.add(ye);let os=ft(or,Lo),kl=pe.metadata.mask.type||"alpha";return cQ(le,os,kl)},He=le=>{let pe=o.nodes.get(le);if(!pe||!pe.metadata.id)return!1;let ye=pe.metadata.id;for(let Re of o.nodes.values())if(Re.metadata.mask?.source===ye)return!0;return!1},ft=(le,pe=new Set)=>{let ye=o.nodes.get(le);if(!ye)return Ur(0,0,0,0);let Re=os=>{ye.cleanupCallbacks.push(os)},bt=os=>{ye.beforeRenderCallbacks.push(os)},or=os=>{ye.afterRenderCallbacks.push(os)},Lo=he(le);if(Lo.length===0){let os=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:void 0,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(os,ye,le,pe)}else{let os=[...Lo].sort((Li,rc)=>Li.metadata.renderOrder-rc.metadata.renderOrder);if(ye.parentId===null){let Li;for(let vr of os){if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let _p=ft(vr.id,pe),Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),_p,"normal",1):au(Ur(1,1,1,0),_p,vr.metadata.blendMode,Dn):au(Li,_p,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}else{let Li;for(let vr of os){let Mp=ft(vr.id,pe);if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),Mp,"normal",1):au(Ur(1,1,1,0),Mp,vr.metadata.blendMode,Dn):au(Li,Mp,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}}},ht=(le,pe,ye,Re,bt={})=>{let or=0;if(ye!==null){let os=Array.from(o.nodes.values()).filter(kl=>kl.parentId===ye);os.length>0&&(or=Math.max(...os.map(kl=>kl.metadata.renderOrder))+1)}let Lo={id:le,fragmentNodeFunc:pe,parentId:ye,metadata:{blendMode:Re?.blendMode||"normal",opacity:Re?.opacity,id:Re?.id,mask:Re?.mask,renderOrder:Re?.renderOrder===void 0?or:Re?.renderOrder},uniforms:bt,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};o.nodes.set(le,Lo),ye===null&&(o.rootId=le),a&&c&&(J.includes(le)||J.push(le),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],me()})))},Ft=(le,pe,ye)=>{let Re=o.nodes.get(le);if(!Re||!Re.uniforms){console.warn(`Node or uniforms not found for ID: ${le}`);return}let bt=Re.uniforms[pe];if(!bt||!bt.uniform){console.warn(`Uniform ${pe} not found in node: ${le}`);return}bt.uniform.value=ye,f&&qt()},ri=(le,pe)=>{let ye=o.nodes.get(le);if(!ye)return;let Re=!1;pe.blendMode!==void 0&&ye.metadata.blendMode!==pe.blendMode&&(ye.metadata.blendMode=pe.blendMode,Re=!0),pe.opacity!==void 0&&ye.metadata.opacity!==pe.opacity&&(ye.metadata.opacity=pe.opacity,Re=!0),pe.renderOrder!==void 0&&ye.metadata.renderOrder!==pe.renderOrder&&(ye.metadata.renderOrder=pe.renderOrder,Re=!0),pe.id!==void 0&&ye.metadata.id!==pe.id&&(ye.metadata.id=pe.id,Re=!0),pe.mask!==void 0&&(ye.metadata.mask?.source!==pe.mask?.source||ye.metadata.mask?.type!==pe.mask?.type)&&(ye.metadata.mask=pe.mask,Re=!0),Re&&a&&c?(te.includes(le)||te.push(le),oe||(oe=!0,queueMicrotask(()=>{oe=!1,te=[],me()}))):f&&qt()},ar=le=>{if(!o.nodes.has(le))return;let pe=o.nodes.get(le);if(pe&&pe.cleanupCallbacks.length>0)for(let Re of pe.cleanupCallbacks)try{Re()}catch(bt){console.error(`Error executing cleanup callback for node ${le}:`,bt)}let ye=he(le);for(let Re of ye)ar(Re.id);o.rootId===le&&(o.rootId=null),o.nodes.delete(le),a&&c&&me()},et=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.beforeRenderCallbacks.length>0)for(let Re of ye.beforeRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing before render callback for node ${ye.id}:`,bt)}},Wr=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.afterRenderCallbacks.length>0)for(let Re of ye.afterRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing after render callback for node ${ye.id}:`,bt)}},qt=async()=>{if(!c||!r||!i||!s||!a)return;let le=performance.now(),pe=T>0?(le-T)/1e3:.016,ye=Math.min(pe,.1);T=le,et(ye);try{if(D)return;r instanceof KS?await r.renderAsync(i,s).then(()=>{c&&Wr(ye)}).catch(Re=>{console.error("WebGPU render error:",Re)}):(r.render(i,s),Wr(ye))}catch(Re){console.error("Render frame error:",Re)}},br=()=>{if(l||!g||!f)return;let le=()=>{l=requestAnimationFrame(le),qt().catch(console.warn)};le()},Pi=()=>{l&&(cancelAnimationFrame(l),l=null)},ns=le=>{if(!e){console.log(`[${t}] No canvas element in updatePointerCoords`);return}let pe,ye;if("touches"in le){if(le.touches.length===0)return;pe=le.touches[0].clientX,ye=le.touches[0].clientY}else pe=le.clientX,ye=le.clientY;let Re=e.getBoundingClientRect(),bt=(pe-Re.left)/Re.width,or=(ye-Re.top)/Re.height;S=bt,_=or},as=le=>{ns(le)},Fi=le=>{ns(le)},vp=()=>{A=!1,qt().catch(console.warn)},Tp=()=>{A=!1,qt().catch(console.warn)},wp=()=>{A=!0,qt().catch(console.warn)},Sp=()=>{A=!0,qt().catch(console.warn)};return{initialize:async({canvas:le})=>{if(c||d)return;d=!0,m=new AbortController;let pe=m;try{if(e=le,i=new xg,i.background=null,s=new bg(-1,1,1,-1,.1,10),s.position.z=1,s.lookAt(0,0,0),K||(window.addEventListener("mousemove",as),window.addEventListener("touchmove",Fi),window.addEventListener("mouseup",vp),window.addEventListener("touchend",Tp),le.addEventListener("mousedown",wp),le.addEventListener("touchstart",Sp),K=!0,console.log(`[${t}] Added event listeners`)),pe.signal.aborted)return;try{if(r=new KS({canvas:le,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await r.init(),pe.signal.aborted){r.dispose();return}}catch(or){if(pe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",or);return}if(pe.signal.aborted){r&&r.dispose();return}r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.outputColorSpace=ws,a=new VR({transparent:!0}),a.fragmentNode=Ur(0,0,0,0);let ye=new T2(2,2);n=new Nn(ye,a),i.add(n),h=new ResizeObserver(fe),h.observe(le),u=new IntersectionObserver(ve,{threshold:0}),u.observe(le),g=!ae();let{width:Re,height:bt}=le.getBoundingClientRect();ge(Math.round(Re),Math.round(bt)),p=!0,await qt(),g&&f&&br(),pe.signal.aborted||(c=!0)}catch(ye){console.error("[Shaders] Initialization error:",ye)}finally{d=!1,m===pe&&(m=null)}},cleanup:()=>{if(console.log(`[${t}] Cleanup called`),m&&m.abort(),h&&(h.disconnect(),h=null),u&&(u.disconnect(),u=null),K&&(console.log(`[${t}] Removing event listeners`),e&&(e.removeEventListener("mousedown",wp),e.removeEventListener("touchstart",Sp)),window&&(window.removeEventListener("mousemove",as),window.removeEventListener("touchmove",Fi),window.removeEventListener("mouseup",vp),window.removeEventListener("touchend",Tp)),K=!1),Pi(),o.nodes.clear(),o.rootId=null,o.idToNodeId.clear(),J=[],re=!1,te=[],oe=!1,n&&(i&&i.remove(n),n.geometry&&n.geometry.dispose(),n.material instanceof bs&&n.material.dispose()),r)try{r.dispose()}catch(le){console.warn("Error disposing renderer:",le)}e=null,r=null,s=null,i=null,n=null,a=null,c=!1,d=!1,p=!1,m=null,b=0,v=0,f=!1,g=!0,S=.5,_=.5,A=!1},registerNode:ht,removeNode:ar,updateUniformValue:Ft,updateNodeMetadata:ri,showLicenseWarning:()=>{!dQ()||sM||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),sM=!0)}}}const{uniform:mQ}=_t;function Bt(t,e,r){let s={};return Object.entries(t.props).forEach(([i,n])=>{let a=e[i],o=a;n.transform&&(o=n.transform(a)),s[i]={uniform:mQ(o).label(`${i}_${r}`),transform:n.transform||void 0}}),s}const{vec2:Qme,fract:Kme,sin:efe,dot:tfe}=_t,{vec2:rfe}=_t;/**
429
+ var<${r}> ${t} : ${n};`}},t7=class{constructor(t){this.backend=t}getCurrentDepthStencilFormat(t){let e;return t.depthTexture===null?t.depth&&t.stencil?e=P.Depth24PlusStencil8:t.depth&&(e=P.Depth24Plus):e=this.getTextureFormatGPU(t.depthTexture),e}getTextureFormatGPU(t){return this.backend.get(t).format}getTextureSampleData(t){let e;if(t.isFramebufferTexture)e=1;else if(t.isDepthTexture&&!t.renderTarget){let i=this.backend.renderer,n=i.getRenderTarget();e=n?n.samples:i.samples}else t.renderTarget&&(e=t.renderTarget.samples);e||(e=1);let r=e>1&&t.renderTarget!==null&&t.isDepthTexture!==!0&&t.isFramebufferTexture!==!0;return{samples:e,primarySamples:r?1:e,isMSAA:r}}getCurrentColorFormat(t){let e;return e=t.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(t.textures[0]),e}getCurrentColorSpace(t){return t.textures===null?this.backend.renderer.outputColorSpace:t.textures[0].colorSpace}getPrimitiveTopology(t,e){if(t.isPoints)return Uu.PointList;if(t.isLineSegments||t.isMesh&&e.wireframe===!0)return Uu.LineList;if(t.isLine)return Uu.LineStrip;if(t.isMesh)return Uu.TriangleList}getSampleCount(t){let e=1;return t>1&&(e=2**Math.floor(Math.log2(t)),e===2&&(e=4)),e}getSampleCountRenderContext(t){return t.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(t.sampleCount)}getPreferredCanvasFormat(){let t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===ms)return P.BGRA8Unorm;if(t===Ss)return P.RGBA16Float;throw Error("Unsupported outputType")}};const r7=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),s7=new Map([[h2,["float16"]]]),i7=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);var n7=class{constructor(t){this.backend=t}createAttribute(t,e){let r=this._getBufferAttribute(t),s=this.backend,i=s.get(r),n=i.buffer;if(n===void 0){let a=s.device,o=r.array;if(t.normalized===!1){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),e&GPUBufferUsage.INDEX))for(let u=0;u<o.length;u++)o[u]===65535&&(o[u]=4294967295)}if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&r.itemSize===3){o=new o.constructor(r.count*4);for(let u=0;u<r.count;u++)o.set(r.array.subarray(u*3,u*3+3),u*4);r.itemSize=4,r.array=o,i._force3to4BytesAlignment=!0}let l=o.byteLength,h=l+(4-l%4)%4;n=a.createBuffer({label:r.name,size:h,usage:e,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),i.buffer=n}}updateAttribute(t){let e=this._getBufferAttribute(t),r=this.backend,s=r.device,i=r.get(e),n=r.get(e).buffer,a=e.array;if(i._force3to4BytesAlignment===!0){a=new a.constructor(e.count*4);for(let h=0;h<e.count;h++)a.set(e.array.subarray(h*3,h*3+3),h*4);e.array=a}let o=this._isTypedArray(a),l=e.updateRanges;if(l.length===0)s.queue.writeBuffer(n,0,a,0);else{let h=o?1:a.BYTES_PER_ELEMENT;for(let u=0,c=l.length;u<c;u++){let d=l[u],p,m;if(i._force3to4BytesAlignment===!0){let g=Math.floor(d.start/3),b=Math.ceil(d.count/3);p=g*4*h,m=b*4*h}else p=d.start*h,m=d.count*h;let f=p*(o?a.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(n,f,a,p,m)}e.clearUpdateRanges()}}createShaderVertexBuffers(t){let e=t.getAttributes(),r=new Map;for(let s=0;s<e.length;s++){let i=e[s],n=i.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(i),o=r.get(a);if(o===void 0){let u,c;i.isInterleavedBufferAttribute===!0?(u=i.data.stride*n,c=i.data.isInstancedInterleavedBuffer?um.Instance:um.Vertex):(u=i.itemSize*n,c=i.isInstancedBufferAttribute?um.Instance:um.Vertex),i.normalized===!1&&(i.array.constructor===Int16Array||i.array.constructor===Uint16Array)&&(u=4),o={arrayStride:u,attributes:[],stepMode:c},r.set(a,o)}let l=this._getVertexFormat(i),h=i.isInterleavedBufferAttribute===!0?i.offset*n:0;o.attributes.push({shaderLocation:s,offset:h,format:l})}return Array.from(r.values())}destroyAttribute(t){let e=this.backend;e.get(this._getBufferAttribute(t)).buffer.destroy(),e.delete(t)}async getArrayBufferAsync(t){let e=this.backend,r=e.device,s=e.get(this._getBufferAttribute(t)),i=s.buffer,n=i.size,a=r.createBuffer({label:`${t.name}_readback`,size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),o=r.createCommandEncoder({label:`readback_encoder_${t.name}`});o.copyBufferToBuffer(i,0,a,0,n);let l=o.finish();r.queue.submit([l]),await a.mapAsync(GPUMapMode.READ);let h=a.getMappedRange(),u=new t.array.constructor(h.slice(0));return a.unmap(),u.buffer}_getVertexFormat(t){let{itemSize:e,normalized:r}=t,s=t.array.constructor,i=t.constructor,n;if(e===1)n=i7.get(s);else{let a=s7.get(i)||r7.get(s),o=a[r?1:0];if(o){let l=s.BYTES_PER_ELEMENT*e,h=Math.floor((l+3)/4)*4,u=h/s.BYTES_PER_ELEMENT;if(u%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${o}x${u}`}}return n||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),n}_isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}_getBufferAttribute(t){return t.isInterleavedBufferAttribute&&(t=t.data),t}},a7=class{constructor(t){this.backend=t,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(t){let e=this.backend,r=e.device,s=[],i=0;for(let n of t.bindings){let a={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let o={};n.isStorageBuffer&&(n.visibility&4&&(n.access===Qr.READ_WRITE||n.access===Qr.WRITE_ONLY)?o.type=HS.Storage:o.type=HS.ReadOnlyStorage),a.buffer=o}else if(n.isSampler){let o={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?e.compatibilityMode&&(o.type=qS.NonFiltering):o.type=qS.Comparison),a.sampler=o}else if(n.isSampledTexture&&n.texture.isVideoTexture)a.externalTexture={};else if(n.isSampledTexture&&n.store){let o={};o.format=this.backend.get(n.texture).texture.format;let l=n.access;l===Qr.READ_WRITE?o.access=Sx.ReadWrite:l===Qr.WRITE_ONLY?o.access=Sx.WriteOnly:o.access=Sx.ReadOnly,a.storageTexture=o}else if(n.isSampledTexture){let o={},{primarySamples:l}=e.utils.getTextureSampleData(n.texture);if(l>1&&(o.multisampled=!0,n.texture.isDepthTexture||(o.sampleType=$o.UnfilterableFloat)),n.texture.isDepthTexture)e.compatibilityMode&&n.texture.compareFunction===null?o.sampleType=$o.UnfilterableFloat:o.sampleType=$o.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let h=n.texture.type;h===ds?o.sampleType=$o.SInt:h===Yt?o.sampleType=$o.UInt:h===Hs&&(this.backend.hasFeature("float32-filterable")?o.sampleType=$o.Float:o.sampleType=$o.UnfilterableFloat)}n.isSampledCubeTexture?o.viewDimension=Br.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?o.viewDimension=Br.TwoDArray:n.isSampledTexture3D&&(o.viewDimension=Br.ThreeD),a.texture=o}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);s.push(a)}return r.createBindGroupLayout({entries:s})}createBindings(t,e,r,s=0){let{backend:i,bindGroupLayoutCache:n}=this,a=i.get(t),o=n.get(t.bindingsReference);o===void 0&&(o=this.createBindingsLayout(t),n.set(t.bindingsReference,o));let l;r>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(l=a.groups[r])),l===void 0&&(l=this.createBindGroup(t,o),r>0&&(a.groups[r]=l,a.versions[r]=s)),a.group=l,a.layout=o}updateBinding(t){let e=this.backend,r=e.device,s=t.buffer,i=e.get(t).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(t,e){let r=this.backend,s=r.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=t[0],a=s.createBuffer({label:"bindingCameraIndex_"+n,size:16,usage:i});s.queue.writeBuffer(a,0,t,0);let o=[{binding:0,resource:{buffer:a}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+n,layout:e,entries:o})}createBindGroup(t,e){let r=this.backend,s=r.device,i=0,n=[];for(let a of t.bindings){if(a.isUniformBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.byteLength,h=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,u=s.createBuffer({label:"bindingBuffer_"+a.name,size:l,usage:h});o.buffer=u}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isStorageBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.attribute;o.buffer=r.get(l).buffer}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isSampler){let o=r.get(a.texture);n.push({binding:i,resource:o.sampler})}else if(a.isSampledTexture){let o=r.get(a.texture),l;if(o.externalTexture!==void 0)l=s.importExternalTexture({source:o.externalTexture});else{let h=a.store?1:o.texture.mipLevelCount,u=`view-${o.texture.width}-${o.texture.height}-${h}`;if(l=o[u],l===void 0){let c=B$.All,d;d=a.isSampledCubeTexture?Br.Cube:a.isSampledTexture3D?Br.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?Br.TwoDArray:Br.TwoD,l=o[u]=o.texture.createView({aspect:c,dimension:d,mipLevelCount:h})}}n.push({binding:i,resource:l})}i++}return s.createBindGroup({label:"bindGroup_"+t.name,layout:e,entries:n})}},o7=class{constructor(t){this.backend=t,this._activePipelines=new WeakMap}setPipeline(t,e){this._activePipelines.get(t)!==e&&(t.setPipeline(e),this._activePipelines.set(t,e))}_getSampleCount(t){return this.backend.utils.getSampleCountRenderContext(t)}createRenderPipeline(t,e){let{object:r,material:s,geometry:i,pipeline:n}=t,{vertexProgram:a,fragmentProgram:o}=n,l=this.backend,h=l.device,u=l.utils,c=l.get(n),d=[];for(let re of t.getBindings()){let te=l.get(re);d.push(te.layout)}let p=l.attributeUtils.createShaderVertexBuffers(t),m;s.blending!==Ph&&(s.blending!==oa||s.transparent!==!1)&&(m=this._getBlending(s));let f={};s.stencilWrite===!0&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let g=this._getColorWriteMask(s),b=[];if(t.context.textures!==null){let re=t.context.textures;for(let te=0;te<re.length;te++){let oe=u.getTextureFormatGPU(re[te]);b.push({format:oe,blend:m,writeMask:g})}}else{let re=u.getCurrentColorFormat(t.context);b.push({format:re,blend:m,writeMask:g})}let v=l.get(a).module,w=l.get(o).module,T=this._getPrimitiveState(r,i,s),N=this._getDepthCompare(s),S=u.getCurrentDepthStencilFormat(t.context),_=this._getSampleCount(t.context),A={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},w,{targets:b}),primitive:T,multisample:{count:_,alphaToCoverageEnabled:s.alphaToCoverage&&_>1},layout:h.createPipelineLayout({bindGroupLayouts:d})},D={},K=t.context.depth,J=t.context.stencil;if((K===!0||J===!0)&&(K===!0&&(D.format=S,D.depthWriteEnabled=s.depthWrite,D.depthCompare=N),J===!0&&(D.stencilFront=f,D.stencilBack={},D.stencilReadMask=s.stencilFuncMask,D.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(D.depthBias=s.polygonOffsetUnits,D.depthBiasSlopeScale=s.polygonOffsetFactor,D.depthBiasClamp=0),A.depthStencil=D),e===null)c.pipeline=h.createRenderPipeline(A);else{let re=new Promise(te=>{h.createRenderPipelineAsync(A).then(oe=>{c.pipeline=oe,te()})});e.push(re)}}createBundleEncoder(t,e="renderBundleEncoder"){let r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(t),a=s.getCurrentColorFormat(t),o=this._getSampleCount(t),l={label:e,colorFormats:[a],depthStencilFormat:n,sampleCount:o};return i.createRenderBundleEncoder(l)}createComputePipeline(t,e){let r=this.backend,s=r.device,i=r.get(t.computeProgram).module,n=r.get(t),a=[];for(let o of e){let l=r.get(o);a.push(l.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(t){let e,r,s=t.blending,i=t.blendSrc,n=t.blendDst,a=t.blendEquation;if(s===Wc){let o=t.blendSrcAlpha===null?i:t.blendSrcAlpha,l=t.blendDstAlpha===null?n:t.blendDstAlpha,h=t.blendEquationAlpha===null?a:t.blendEquationAlpha;e={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=t.premultipliedAlpha,l=(h,u,c,d)=>{e={srcFactor:h,dstFactor:u,operation:Do.Add},r={srcFactor:c,dstFactor:d,operation:Do.Add}};if(o)switch(s){case oa:l(ze.One,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.One,ze.One,ze.One,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.SrcAlpha);break}else switch(s){case oa:l(ze.SrcAlpha,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.SrcAlpha,ze.One,ze.SrcAlpha,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.Src);break}}if(e!==void 0&&r!==void 0)return{color:e,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(t){let e;switch(t){case Ja:e=ze.Zero;break;case EN:e=ze.One;break;case PN:e=ze.Src;break;case FN:e=ze.OneMinusSrc;break;case Af:e=ze.SrcAlpha;break;case Cf:e=ze.OneMinusSrcAlpha;break;case zN:e=ze.Dst;break;case BN:e=ze.OneMinusDst;break;case LN:e=ze.DstAlpha;break;case IN:e=ze.OneMinusDstAlpha;break;case VN:e=ze.SrcAlphaSaturated;break;case oU:e=ze.Constant;break;case lU:e=ze.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",t)}return e}_getStencilCompare(t){let e,r=t.stencilFunc;switch(r){case Dz:e=kr.Never;break;case D0:e=kr.Always;break;case $z:e=kr.Less;break;case jz:e=kr.LessEqual;break;case Gz:e=kr.Equal;break;case qz:e=kr.GreaterEqual;break;case Wz:e=kr.Greater;break;case Hz:e=kr.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return e}_getStencilOperation(t){let e;switch(t){case Zo:e=Ua.Keep;break;case Iz:e=Ua.Zero;break;case zz:e=Ua.Replace;break;case Uz:e=Ua.Invert;break;case Bz:e=Ua.IncrementClamp;break;case Vz:e=Ua.DecrementClamp;break;case Oz:e=Ua.IncrementWrap;break;case kz:e=Ua.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",e)}return e}_getBlendOperation(t){let e;switch(t){case Hi:e=Do.Add;break;case CN:e=Do.Subtract;break;case RN:e=Do.ReverseSubtract;break;case yz:e=Do.Min;break;case xz:e=Do.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",t)}return e}_getPrimitiveState(t,e,r){let s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(t,r),e.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(s.stripIndexFormat=e.index.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32),r.side){case aa:s.frontFace=vx.CCW,s.cullMode=Tx.Back;break;case gs:s.frontFace=vx.CCW,s.cullMode=Tx.Front;break;case Hu:s.frontFace=vx.CCW,s.cullMode=Tx.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side);break}return s}_getColorWriteMask(t){return t.colorWrite===!0?WS.All:WS.None}_getDepthCompare(t){let e;if(t.depthTest===!1)e=kr.Always;else{let r=t.depthFunc;switch(r){case ON:e=kr.Never;break;case kN:e=kr.Always;break;case UN:e=kr.Less;break;case Rf:e=kr.LessEqual;break;case DN:e=kr.Equal;break;case $N:e=kr.GreaterEqual;break;case GN:e=kr.Greater;break;case jN:e=kr.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return e}},l7=class extends g3{constructor(t,e,r=2048){super(r),this.device=t,this.type=e,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${e}`});let s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${e}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${e}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(t){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ba(`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 e=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(t.id,e),e}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let t=new Map(this.queryOffsets),e=this.currentQueryIndex,r=e*8;this.currentQueryIndex=0,this.queryOffsets.clear();let s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,e,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let i=s.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a=0;for(let[,o]of t){let l=n[o],h=n[o+1],u=Number(h-l)/1e6;a+=u}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(t){return console.error("Error resolving queries:",t),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(t){console.error("Error waiting for pending resolve:",t)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(t){console.error("Error unmapping buffer:",t)}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}}},u7=class extends f3{constructor(t={}){super(t),this.isWebGPUBackend=!0,this.parameters.alpha=t.alpha===void 0?!0:t.alpha,this.parameters.compatibilityMode=t.compatibilityMode===void 0?!1:t.compatibilityMode,this.parameters.requiredLimits=t.requiredLimits===void 0?{}:t.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new t7(this),this.attributeUtils=new n7(this),this.bindingUtils=new a7(this),this.pipelineUtils=new o7(this),this.textureUtils=new W$(this),this.occludedResolveCache=new Map}async init(t){await super.init(t);let e=this.parameters,r;if(e.device===void 0){let n={powerPreference:e.powerPreference,featureLevel:e.compatibilityMode?"compatibility":void 0},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(n):null;if(a===null)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let o=Object.values(cb),l=[];for(let u of o)a.features.has(u)&&l.push(u);let h={requiredFeatures:l,requiredLimits:e.requiredLimits};r=await a.requestDevice(h)}else r=e.device;r.lost.then(n=>{let a={api:"WebGPU",message:n.message||"Unknown reason",reason:n.reason||null,originalEvent:n};t.onDeviceLost(a)});let s=e.context===void 0?t.domElement.getContext("webgpu"):e.context;this.device=r,this.context=s;let i=e.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(cb.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 Mn}async getArrayBufferAsync(t){return await this.attributeUtils.getArrayBufferAsync(t)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let t=this.defaultRenderPassdescriptor;if(t===null){let r=this.renderer;t={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(t.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(r.depth,r.stencil).createView()});let s=t.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=t}let e=t.colorAttachments[0];return this.renderer.samples>0?e.resolveTarget=this.context.getCurrentTexture().createView():e.view=this.context.getCurrentTexture().createView(),t}_isRenderCameraDepthArray(t){return t.depthTexture&&t.depthTexture.image.depth>1&&t.camera.isArrayCamera}_getRenderPassDescriptor(t,e={}){let r=t.renderTarget,s=this.get(r),i=s.descriptors;if(i===void 0||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==t.activeMipmapLevel||s.activeCubeFace!==t.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;let l=()=>{r.removeEventListener("dispose",l),this.delete(r)};r.hasEventListener("dispose",l)===!1&&r.addEventListener("dispose",l)}let n=t.getCacheKey(),a=i[n];if(a===void 0){let l=t.textures,h=[],u,c=this._isRenderCameraDepthArray(t);for(let d=0;d<l.length;d++){let p=this.get(l[d]),m={label:`colorAttachment_${d}`,baseMipLevel:t.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:t.activeCubeFace,arrayLayerCount:1,dimension:Br.TwoD};if(r.isRenderTarget3D)u=t.activeCubeFace,m.baseArrayLayer=0,m.dimension=Br.ThreeD,m.depthOrArrayLayers=l[d].image.depth;else if(r.isRenderTarget&&l[d].image.depth>1)if(c===!0){let f=t.camera.cameras;for(let g=0;g<f.length;g++){let b={...m,baseArrayLayer:g,arrayLayerCount:1,dimension:Br.TwoD},v=p.texture.createView(b);h.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Br.TwoDArray,m.depthOrArrayLayers=l[d].image.depth;if(c!==!0){let f=p.texture.createView(m),g,b;p.msaaTexture===void 0?(g=f,b=void 0):(g=p.msaaTexture.createView(),b=f),h.push({view:g,resolveTarget:b,depthSlice:u})}}if(a={textureViews:h},t.depth){let d=this.get(t.depthTexture),p={};t.depthTexture.isArrayTexture&&(p.dimension=Br.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=t.activeCubeFace),a.depthStencilView=d.texture.createView(p)}i[n]=a,s.width=r.width,s.height=r.height,s.samples=r.samples,s.activeMipmapLevel=t.activeMipmapLevel,s.activeCubeFace=t.activeCubeFace,s.dimensions=r.dimensions}let o={colorAttachments:[]};for(let l=0;l<a.textureViews.length;l++){let h=a.textureViews[l],u={r:0,g:0,b:0,a:1};l===0&&e.clearValue&&(u=e.clearValue),o.colorAttachments.push({view:h.view,depthSlice:h.depthSlice,resolveTarget:h.resolveTarget,loadOp:e.loadOp||tt.Load,storeOp:e.storeOp||cs.Store,clearValue:u})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(t){let e=this.get(t),r=this.device,s=t.occlusionQueryCount,i;s>0&&(e.currentOcclusionQuerySet&&e.currentOcclusionQuerySet.destroy(),e.currentOcclusionQueryBuffer&&e.currentOcclusionQueryBuffer.destroy(),e.currentOcclusionQuerySet=e.occlusionQuerySet,e.currentOcclusionQueryBuffer=e.occlusionQueryBuffer,e.currentOcclusionQueryObjects=e.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${t.id}`}),e.occlusionQuerySet=i,e.occlusionQueryIndex=0,e.occlusionQueryObjects=Array(s),e.lastOcclusionObject=null);let n;n=t.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(t,{loadOp:tt.Load}),this.initTimestampQuery(t,n),n.occlusionQuerySet=i;let a=n.depthStencilAttachment;if(t.textures!==null){let l=n.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];t.clearColor?(u.clearValue=h===0?t.clearColorValue:{r:0,g:0,b:0,a:1},u.loadOp=tt.Clear):u.loadOp=tt.Load,u.storeOp=cs.Store}}else{let l=n.colorAttachments[0];t.clearColor?(l.clearValue=t.clearColorValue,l.loadOp=tt.Clear):l.loadOp=tt.Load,l.storeOp=cs.Store}t.depth&&(t.clearDepth?(a.depthClearValue=t.clearDepthValue,a.depthLoadOp=tt.Clear):a.depthLoadOp=tt.Load,a.depthStoreOp=cs.Store),t.stencil&&(t.clearStencil?(a.stencilClearValue=t.clearStencilValue,a.stencilLoadOp=tt.Clear):a.stencilLoadOp=tt.Load,a.stencilStoreOp=cs.Store);let o=r.createCommandEncoder({label:"renderContext_"+t.id});if(this._isRenderCameraDepthArray(t)===!0){let l=t.camera.cameras;!e.layerDescriptors||e.layerDescriptors.length!==l.length?this._createDepthLayerDescriptors(t,e,n,l):this._updateDepthLayerDescriptors(t,e,l),e.bundleEncoders=[],e.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(t,"renderBundleArrayCamera_"+h),c={attributes:{},bindingGroups:[],pipeline:null,index:null};e.bundleEncoders.push(u),e.bundleSets.push(c)}e.currentPass=null}else{let l=o.beginRenderPass(n);if(e.currentPass=l,t.viewport&&this.updateViewport(t),t.scissor){let{x:h,y:u,width:c,height:d}=t.scissorValue;l.setScissorRect(h,u,c,d)}}e.descriptor=n,e.encoder=o,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.renderBundles=[]}_createDepthLayerDescriptors(t,e,r,s){let i=r.depthStencilAttachment;e.layerDescriptors=[];let n=this.get(t.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<s.length;a++){let o={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){let l=a;n.viewCache[l]||(n.viewCache[l]=n.texture.createView({dimension:Br.TwoD,baseArrayLayer:a,arrayLayerCount:1})),o.depthStencilAttachment={view:n.viewCache[l],depthLoadOp:i.depthLoadOp||tt.Clear,depthStoreOp:i.depthStoreOp||cs.Store,depthClearValue:i.depthClearValue||1},t.stencil&&(o.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,o.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,o.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else o.depthStencilAttachment={...i};e.layerDescriptors.push(o)}}_updateDepthLayerDescriptors(t,e,r){for(let s=0;s<r.length;s++){let i=e.layerDescriptors[s];if(i.depthStencilAttachment){let n=i.depthStencilAttachment;t.depth&&(t.clearDepth?(n.depthClearValue=t.clearDepthValue,n.depthLoadOp=tt.Clear):n.depthLoadOp=tt.Load),t.stencil&&(t.clearStencil?(n.stencilClearValue=t.clearStencilValue,n.stencilLoadOp=tt.Clear):n.stencilLoadOp=tt.Load)}}}finishRender(t){let e=this.get(t),r=t.occlusionQueryCount;e.renderBundles.length>0&&e.currentPass.executeBundles(e.renderBundles),r>e.occlusionQueryIndex&&e.currentPass.endOcclusionQuery();let s=e.encoder;if(this._isRenderCameraDepthArray(t)===!0){let i=[];for(let n=0;n<e.bundleEncoders.length;n++){let a=e.bundleEncoders[n];i.push(a.finish())}for(let n=0;n<e.layerDescriptors.length;n++)if(n<i.length){let a=e.layerDescriptors[n],o=s.beginRenderPass(a);if(t.viewport){let{x:l,y:h,width:u,height:c,minDepth:d,maxDepth:p}=t.viewportValue;o.setViewport(l,h,u,c,d,p)}if(t.scissor){let{x:l,y:h,width:u,height:c}=t.scissorValue;o.setScissorRect(l,h,u,c)}o.executeBundles([i[n]]),o.end()}}else e.currentPass&&e.currentPass.end();if(r>0){let i=r*8,n=this.occludedResolveCache.get(i);n===void 0&&(n=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,n));let a=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});e.encoder.resolveQuerySet(e.occlusionQuerySet,0,r,n,0),e.encoder.copyBufferToBuffer(n,0,a,0,i),e.occlusionQueryBuffer=a,this.resolveOccludedAsync(t)}if(this.device.queue.submit([e.encoder.finish()]),t.textures!==null){let i=t.textures;for(let n=0;n<i.length;n++){let a=i[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(t,e){let r=this.get(t);return r.occluded&&r.occluded.has(e)}async resolveOccludedAsync(t){let e=this.get(t),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:s}=e;if(r&&s){let i=new WeakSet;e.currentOcclusionQueryObjects=null,e.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);let n=r.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<s.length;o++)a[o]===BigInt(0)&&i.add(s[o]);r.destroy(),e.occluded=i}}updateViewport(t){let{currentPass:e}=this.get(t),{x:r,y:s,width:i,height:n,minDepth:a,maxDepth:o}=t.viewportValue;e.setViewport(r,s,i,n,a,o)}getClearColor(){let t=super.getClearColor();return this.renderer.alpha===!0&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}clear(t,e,r,s=null){let i=this.device,n=this.renderer,a=[],o,l,h,u;if(t){let p=this.getClearColor();l={r:p.r,g:p.g,b:p.b,a:p.a}}if(s===null){h=n.depth,u=n.stencil;let p=this._getDefaultRenderPassDescriptor();if(t){a=p.colorAttachments;let m=a[0];m.clearValue=l,m.loadOp=tt.Clear,m.storeOp=cs.Store}(h||u)&&(o=p.depthStencilAttachment)}else{h=s.depth,u=s.stencil;let p={loadOp:t?tt.Clear:tt.Load,clearValue:t?l:void 0};h&&(p.depthLoadOp=e?tt.Clear:tt.Load,p.depthClearValue=e?n.getClearDepth():void 0,p.depthStoreOp=cs.Store),u&&(p.stencilLoadOp=r?tt.Clear:tt.Load,p.stencilClearValue=r?n.getClearStencil():void 0,p.stencilStoreOp=cs.Store);let m=this._getRenderPassDescriptor(s,p);a=m.colorAttachments,o=m.depthStencilAttachment}h&&o&&o.depthLoadOp===void 0&&(e?(o.depthLoadOp=tt.Clear,o.depthClearValue=n.getClearDepth(),o.depthStoreOp=cs.Store):(o.depthLoadOp=tt.Load,o.depthStoreOp=cs.Store)),u&&o&&o.stencilLoadOp===void 0&&(r?(o.stencilLoadOp=tt.Clear,o.stencilClearValue=n.getClearStencil(),o.stencilStoreOp=cs.Store):(o.stencilLoadOp=tt.Load,o.stencilStoreOp=cs.Store));let c=i.createCommandEncoder({label:"clear"});c.beginRenderPass({colorAttachments:a,depthStencilAttachment:o}).end(),i.queue.submit([c.finish()])}beginCompute(t){let e=this.get(t),r={label:"computeGroup_"+t.id};this.initTimestampQuery(t,r),e.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+t.id}),e.passEncoderGPU=e.cmdEncoderGPU.beginComputePass(r)}compute(t,e,r,s){let{passEncoderGPU:i}=this.get(t),n=this.get(s).pipeline;this.pipelineUtils.setPipeline(i,n);for(let h=0,u=r.length;h<u;h++){let c=r[h],d=this.get(c);i.setBindGroup(h,d.group)}let a=this.device.limits.maxComputeWorkgroupsPerDimension,o=this.get(e);o.dispatchSize===void 0&&(o.dispatchSize={x:0,y:1,z:1});let{dispatchSize:l}=o;e.dispatchCount>a?(l.x=Math.min(e.dispatchCount,a),l.y=Math.ceil(e.dispatchCount/a)):l.x=e.dispatchCount,i.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(t){let e=this.get(t);e.passEncoderGPU.end(),this.device.queue.submit([e.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(t,e){let{object:r,material:s,context:i,pipeline:n}=t,a=t.getBindings(),o=this.get(i),l=this.get(n).pipeline,h=t.getIndex(),u=h!==null,c=t.getDrawParameters();if(c===null)return;let d=(m,f)=>{this.pipelineUtils.setPipeline(m,l),f.pipeline=l;let g=f.bindingGroups;for(let v=0,w=a.length;v<w;v++){let T=a[v],N=this.get(T);g[T.index]!==T.id&&(m.setBindGroup(T.index,N.group),g[T.index]=T.id)}if(u===!0&&f.index!==h){let v=this.get(h).buffer,w=h.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32;m.setIndexBuffer(v,w),f.index=h}let b=t.getVertexBuffers();for(let v=0,w=b.length;v<w;v++){let T=b[v];if(f.attributes[v]!==T){let N=this.get(T).buffer;m.setVertexBuffer(v,N),f.attributes[v]=T}}i.stencil===!0&&s.stencilWrite===!0&&o.currentStencilRef!==s.stencilRef&&(m.setStencilReference(s.stencilRef),o.currentStencilRef=s.stencilRef)},p=(m,f)=>{if(d(m,f),r.isBatchedMesh===!0){let g=r._multiDrawStarts,b=r._multiDrawCounts,v=r._multiDrawCount,w=r._multiDrawInstances;w!==null&&ba("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let T=0;T<v;T++){let N=w?w[T]:1,S=N>1?0:T;u===!0?m.drawIndexed(b[T],N,g[T]/h.array.BYTES_PER_ELEMENT,0,S):m.draw(b[T],N,g[T],S),e.update(r,b[T],N)}}else if(u===!0){let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndexedIndirect(T,0)}else m.drawIndexed(g,b,v,0,0);e.update(r,g,b)}else{let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndirect(T,0)}else m.draw(g,b,v,0);e.update(r,g,b)}};if(t.camera.isArrayCamera&&t.camera.cameras.length>0){let m=this.get(t.camera),f=t.camera.cameras,g=t.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==f.length){let v=this.get(g),w=[],T=new Uint32Array([0,0,0,0]);for(let N=0,S=f.length;N<S;N++){T[0]=N;let _=this.bindingUtils.createBindGroupIndex(T,v.layout);w.push(_)}m.indexesGPU=w}let b=this.renderer.getPixelRatio();for(let v=0,w=f.length;v<w;v++){let T=f[v];if(r.layers.test(T.layers)){let N=T.viewport,S=o.currentPass,_=o.currentSets;if(o.bundleEncoders){let A=o.bundleEncoders[v],D=o.bundleSets[v];S=A,_=D}N&&S.setViewport(Math.floor(N.x*b),Math.floor(N.y*b),Math.floor(N.width*b),Math.floor(N.height*b),i.viewportValue.minDepth,i.viewportValue.maxDepth),g&&m.indexesGPU&&(S.setBindGroup(g.index,m.indexesGPU[v]),_.bindingGroups[g.index]=g.id),p(S,_)}}}else if(o.currentPass){if(o.occlusionQuerySet!==void 0){let m=o.lastOcclusionObject;m!==r&&(m!==null&&m.occlusionTest===!0&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),r.occlusionTest===!0&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}p(o.currentPass,o.currentSets)}}needsRenderUpdate(t){let e=this.get(t),{object:r,material:s}=t,i=this.utils,n=i.getSampleCountRenderContext(t.context),a=i.getCurrentColorSpace(t.context),o=i.getCurrentColorFormat(t.context),l=i.getCurrentDepthStencilFormat(t.context),h=i.getPrimitiveTopology(r,s),u=!1;return(e.material!==s||e.materialVersion!==s.version||e.transparent!==s.transparent||e.blending!==s.blending||e.premultipliedAlpha!==s.premultipliedAlpha||e.blendSrc!==s.blendSrc||e.blendDst!==s.blendDst||e.blendEquation!==s.blendEquation||e.blendSrcAlpha!==s.blendSrcAlpha||e.blendDstAlpha!==s.blendDstAlpha||e.blendEquationAlpha!==s.blendEquationAlpha||e.colorWrite!==s.colorWrite||e.depthWrite!==s.depthWrite||e.depthTest!==s.depthTest||e.depthFunc!==s.depthFunc||e.stencilWrite!==s.stencilWrite||e.stencilFunc!==s.stencilFunc||e.stencilFail!==s.stencilFail||e.stencilZFail!==s.stencilZFail||e.stencilZPass!==s.stencilZPass||e.stencilFuncMask!==s.stencilFuncMask||e.stencilWriteMask!==s.stencilWriteMask||e.side!==s.side||e.alphaToCoverage!==s.alphaToCoverage||e.sampleCount!==n||e.colorSpace!==a||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.material=s,e.materialVersion=s.version,e.transparent=s.transparent,e.blending=s.blending,e.premultipliedAlpha=s.premultipliedAlpha,e.blendSrc=s.blendSrc,e.blendDst=s.blendDst,e.blendEquation=s.blendEquation,e.blendSrcAlpha=s.blendSrcAlpha,e.blendDstAlpha=s.blendDstAlpha,e.blendEquationAlpha=s.blendEquationAlpha,e.colorWrite=s.colorWrite,e.depthWrite=s.depthWrite,e.depthTest=s.depthTest,e.depthFunc=s.depthFunc,e.stencilWrite=s.stencilWrite,e.stencilFunc=s.stencilFunc,e.stencilFail=s.stencilFail,e.stencilZFail=s.stencilZFail,e.stencilZPass=s.stencilZPass,e.stencilFuncMask=s.stencilFuncMask,e.stencilWriteMask=s.stencilWriteMask,e.side=s.side,e.alphaToCoverage=s.alphaToCoverage,e.sampleCount=n,e.colorSpace=a,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.clippingContextCacheKey=t.clippingContextCacheKey,u=!0),u}getRenderCacheKey(t){let{object:e,material:r}=t,s=this.utils,i=t.context;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,s.getSampleCountRenderContext(i),s.getCurrentColorSpace(i),s.getCurrentColorFormat(i),s.getCurrentDepthStencilFormat(i),s.getPrimitiveTopology(e,r),t.getGeometryCacheKey(),t.clippingContextCacheKey].join()}createSampler(t){this.textureUtils.createSampler(t)}destroySampler(t){this.textureUtils.destroySampler(t)}createDefaultTexture(t){this.textureUtils.createDefaultTexture(t)}createTexture(t,e){this.textureUtils.createTexture(t,e)}updateTexture(t,e){this.textureUtils.updateTexture(t,e)}generateMipmaps(t){this.textureUtils.generateMipmaps(t)}destroyTexture(t){this.textureUtils.destroyTexture(t)}async copyTextureToBuffer(t,e,r,s,i,n){return this.textureUtils.copyTextureToBuffer(t,e,r,s,i,n)}initTimestampQuery(t,e){if(!this.trackTimestamp)return;let r=t.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new l7(this.device,r,2048));let s=this.timestampQueryPool[r],i=s.allocateQueriesForContext(t);e.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(t,e){return new e7(t,e)}createProgram(t){let e=this.get(t);e.module={module:this.device.createShaderModule({code:t.code,label:t.stage+(t.name===""?"":`_${t.name}`)}),entryPoint:"main"}}destroyProgram(t){this.delete(t)}createRenderPipeline(t,e){this.pipelineUtils.createRenderPipeline(t,e)}createComputePipeline(t,e){this.pipelineUtils.createComputePipeline(t,e)}beginBundle(t){let e=this.get(t);e._currentPass=e.currentPass,e._currentSets=e.currentSets,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentPass=this.pipelineUtils.createBundleEncoder(t)}finishBundle(t,e){let r=this.get(t),s=r.currentPass,i=s.finish();this.get(e).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(t,e){this.get(t).renderBundles.push(this.get(e).bundleGPU)}createBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBinding(t){this.bindingUtils.updateBinding(t)}createIndexAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(t){return this.device.features.has(t)}copyTextureToTexture(t,e,r=null,s=null,i=0,n=0){let a=0,o=0,l=0,h=0,u=0,c=0,d=t.image.width,p=t.image.height,m=1;r!==null&&(r.isBox3===!0?(h=r.min.x,u=r.min.y,c=r.min.z,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=r.max.z-r.min.z):(h=r.min.x,u=r.min.y,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=1)),s!==null&&(a=s.x,o=s.y,l=s.z||0);let f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+t.id+"_"+e.id}),g=this.get(t).texture,b=this.get(e).texture;f.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:h,y:u,z:c}},{texture:b,mipLevel:n,origin:{x:a,y:o,z:l}},[d,p,m]),this.device.queue.submit([f.finish()]),n===0&&e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}copyFramebufferToTexture(t,e,r){let s=this.get(e),i=null;i=e.renderTarget?t.isDepthTexture?this.get(e.depthTexture).texture:this.get(e.textures[0]).texture:t.isDepthTexture?this.textureUtils.getDepthBuffer(e.depth,e.stencil):this.context.getCurrentTexture();let n=this.get(t).texture;if(i.format!==n.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,n.format);return}let a;if(s.currentPass?(s.currentPass.end(),a=s.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+t.id}),a.copyTextureToTexture({texture:i,origin:[r.x,r.y,0]},{texture:n},[r.z,r.w]),s.currentPass){let{descriptor:o}=s;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=tt.Load;if(e.depth&&(o.depthStencilAttachment.depthLoadOp=tt.Load),e.stencil&&(o.depthStencilAttachment.stencilLoadOp=tt.Load),s.currentPass=a.beginRenderPass(o),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.viewport&&this.updateViewport(e),e.scissor){let{x:l,y:h,width:u,height:c}=e.scissorValue;s.currentPass.setScissorRect(l,h,u,c)}}else this.device.queue.submit([a.finish()]);t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}},h7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}},c7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}},d7=class extends l3{constructor(){super(),this.addMaterial(rk,"MeshPhongMaterial"),this.addMaterial(QR,"MeshStandardMaterial"),this.addMaterial(Dk,"MeshPhysicalMaterial"),this.addMaterial(Wk,"MeshToonMaterial"),this.addMaterial(VR,"MeshBasicMaterial"),this.addMaterial(ek,"MeshLambertMaterial"),this.addMaterial(j4,"MeshNormalMaterial"),this.addMaterial(Xk,"MeshMatcapMaterial"),this.addMaterial(V4,"LineBasicMaterial"),this.addMaterial(k4,"LineDashedMaterial"),this.addMaterial(Qk,"PointsMaterial"),this.addMaterial(eE,"SpriteMaterial"),this.addMaterial(tU,"ShadowMaterial"),this.addLight(t8,iV),this.addLight($9,aV),this.addLight(G9,lV),this.addLight(Ev,f1),this.addLight(q9,oV),this.addLight(X9,tV),this.addLight(Y9,hV),this.addLight(j9,h7),this.addLight(H9,c7),this.addToneMapping(SE,Tz),this.addToneMapping(ME,wz),this.addToneMapping(_E,Sz),this.addToneMapping(NE,Mz),this.addToneMapping(AE,_z),this.addToneMapping(CE,Nz)}},KS=class extends m${constructor(t={}){let e;t.forceWebGL?e=jS:(e=u7,t.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new jS(t)));let r=new e(t);super(r,t),this.library=new d7,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},_t={};cz(_t,{BRDF_GGX:()=>p7,BRDF_Lambert:()=>m7,BasicShadowFilter:()=>f7,Break:()=>g7,Const:()=>wj,Continue:()=>y7,DFGApprox:()=>x7,D_GGX:()=>b7,Discard:()=>v7,EPSILON:()=>T7,F_Schlick:()=>w7,Fn:()=>S7,INFINITY:()=>M7,If:()=>_7,Loop:()=>A7,NodeAccess:()=>P7,NodeShaderStage:()=>C7,NodeType:()=>R7,NodeUpdateType:()=>E7,PCFShadowFilter:()=>F7,PCFSoftShadowFilter:()=>L7,PI:()=>I7,PI2:()=>z7,Return:()=>B7,Schlick_to_F0:()=>V7,ScriptableNodeResources:()=>O7,ShaderNode:()=>k7,Switch:()=>N7,TBNViewMatrix:()=>U7,VSMShadowFilter:()=>D7,V_GGX_SmithCorrelated:()=>$7,Var:()=>CJ,abs:()=>G7,acesFilmicToneMapping:()=>j7,acos:()=>W7,add:()=>pb,addNodeElement:()=>H7,agxToneMapping:()=>q7,all:()=>X7,alphaT:()=>Y7,and:()=>Z7,anisotropy:()=>J7,anisotropyB:()=>Q7,anisotropyT:()=>K7,any:()=>eG,append:()=>tG,array:()=>rG,arrayBuffer:()=>sG,asin:()=>iG,assign:()=>nG,atan:()=>aG,atan2:()=>oG,atomicAdd:()=>lG,atomicAnd:()=>uG,atomicFunc:()=>hG,atomicLoad:()=>yG,atomicMax:()=>cG,atomicMin:()=>dG,atomicOr:()=>pG,atomicStore:()=>mG,atomicSub:()=>fG,atomicXor:()=>gG,attenuationColor:()=>xG,attenuationDistance:()=>bG,attribute:()=>vG,attributeArray:()=>TG,backgroundBlurriness:()=>wG,backgroundIntensity:()=>SG,backgroundRotation:()=>MG,batch:()=>_G,billboarding:()=>NG,bitAnd:()=>AG,bitNot:()=>CG,bitOr:()=>RG,bitXor:()=>EG,bitangentGeometry:()=>PG,bitangentLocal:()=>FG,bitangentView:()=>LG,bitangentWorld:()=>IG,bitcast:()=>zG,blendBurn:()=>BG,blendColor:()=>VG,blendDodge:()=>OG,blendOverlay:()=>kG,blendScreen:()=>UG,blur:()=>DG,bool:()=>$G,buffer:()=>GG,bufferAttribute:()=>jG,bumpMap:()=>WG,burn:()=>HG,bvec2:()=>qG,bvec3:()=>XG,bvec4:()=>YG,bypass:()=>ZG,cache:()=>JG,call:()=>QG,cameraFar:()=>KG,cameraIndex:()=>ej,cameraNear:()=>tj,cameraNormalMatrix:()=>rj,cameraPosition:()=>sj,cameraProjectionMatrix:()=>ij,cameraProjectionMatrixInverse:()=>nj,cameraViewMatrix:()=>aj,cameraWorldMatrix:()=>oj,cbrt:()=>lj,cdl:()=>uj,ceil:()=>hj,checker:()=>cj,cineonToneMapping:()=>dj,clamp:()=>x3,clearcoat:()=>pj,clearcoatRoughness:()=>mj,code:()=>fj,color:()=>gj,colorSpaceToWorking:()=>yj,colorToDirection:()=>xj,compute:()=>bj,computeSkinning:()=>vj,cond:()=>Tj,context:()=>Sj,convert:()=>Mj,convertColorSpace:()=>_j,convertToTexture:()=>Nj,cos:()=>ff,cross:()=>Aj,cubeTexture:()=>Cj,dFdx:()=>Rj,dFdy:()=>Ej,dashSize:()=>Pj,debug:()=>Fj,decrement:()=>Lj,decrementBefore:()=>Ij,defaultBuildStages:()=>zj,defaultShaderStages:()=>Bj,defined:()=>Vj,degrees:()=>Oj,deltaTime:()=>kj,densityFog:()=>Uj,densityFogFactor:()=>Dj,depth:()=>$j,depthPass:()=>Gj,difference:()=>jj,diffuseColor:()=>Wj,directPointLight:()=>Hj,directionToColor:()=>qj,dispersion:()=>Xj,distance:()=>Yj,div:()=>Zj,dodge:()=>Jj,dot:()=>wd,drawIndex:()=>Qj,dynamicBufferAttribute:()=>Kj,element:()=>eW,emissive:()=>tW,equal:()=>rW,equals:()=>sW,equirectUV:()=>iW,exp:()=>nW,exp2:()=>aW,expression:()=>oW,faceDirection:()=>lW,faceForward:()=>uW,faceforward:()=>hW,float:()=>mb,floor:()=>cW,fog:()=>dW,fract:()=>fb,frameGroup:()=>pW,frameId:()=>mW,frontFacing:()=>fW,fwidth:()=>b3,gain:()=>gW,gapSize:()=>yW,getConstNodeType:()=>xW,getCurrentStack:()=>bW,getDirection:()=>vW,getDistanceAttenuation:()=>TW,getGeometryRoughness:()=>wW,getNormalFromDepth:()=>SW,getParallaxCorrectNormal:()=>MW,getRoughness:()=>_W,getScreenPosition:()=>NW,getShIrradianceAt:()=>AW,getShadowMaterial:()=>EW,getShadowRenderObjectFunction:()=>PW,getTextureIndex:()=>CW,getViewPosition:()=>RW,globalId:()=>SH,glsl:()=>FW,glslFn:()=>LW,grayscale:()=>IW,greaterThan:()=>zW,greaterThanEqual:()=>BW,hash:()=>VW,highpModelNormalViewMatrix:()=>OW,highpModelViewMatrix:()=>kW,hue:()=>UW,increment:()=>DW,incrementBefore:()=>$W,instance:()=>GW,instanceIndex:()=>jW,instancedArray:()=>WW,instancedBufferAttribute:()=>HW,instancedDynamicBufferAttribute:()=>qW,instancedMesh:()=>XW,int:()=>YW,inverseSqrt:()=>ZW,inversesqrt:()=>JW,invocationLocalIndex:()=>QW,invocationSubgroupIndex:()=>KW,ior:()=>eH,iridescence:()=>tH,iridescenceIOR:()=>rH,iridescenceThickness:()=>sH,ivec2:()=>iH,ivec3:()=>nH,ivec4:()=>aH,js:()=>oH,label:()=>lH,length:()=>uH,lengthSq:()=>hH,lessThan:()=>cH,lessThanEqual:()=>dH,lightPosition:()=>pH,lightProjectionUV:()=>xY,lightShadowMatrix:()=>mH,lightTargetDirection:()=>fH,lightTargetPosition:()=>gH,lightViewPosition:()=>yH,lightingContext:()=>xH,lights:()=>bH,linearDepth:()=>vH,linearToneMapping:()=>TH,localId:()=>wH,log:()=>MH,log2:()=>_H,logarithmicDepthToViewZ:()=>NH,loop:()=>AH,luminance:()=>CH,mat2:()=>EH,mat3:()=>PH,mat4:()=>FH,matcapUV:()=>LH,materialAO:()=>IH,materialAlphaTest:()=>zH,materialAnisotropy:()=>BH,materialAnisotropyVector:()=>VH,materialAttenuationColor:()=>OH,materialAttenuationDistance:()=>kH,materialClearcoat:()=>UH,materialClearcoatNormal:()=>DH,materialClearcoatRoughness:()=>$H,materialColor:()=>GH,materialDispersion:()=>jH,materialEmissive:()=>WH,materialIOR:()=>HH,materialIridescence:()=>qH,materialIridescenceIOR:()=>XH,materialIridescenceThickness:()=>YH,materialLightMap:()=>ZH,materialLineDashOffset:()=>JH,materialLineDashSize:()=>QH,materialLineGapSize:()=>KH,materialLineScale:()=>eq,materialLineWidth:()=>tq,materialMetalness:()=>rq,materialNormal:()=>sq,materialOpacity:()=>iq,materialPointSize:()=>nq,materialReference:()=>aq,materialReflectivity:()=>oq,materialRefractionRatio:()=>lq,materialRotation:()=>uq,materialRoughness:()=>hq,materialSheen:()=>cq,materialSheenRoughness:()=>dq,materialShininess:()=>pq,materialSpecular:()=>mq,materialSpecularColor:()=>fq,materialSpecularIntensity:()=>gq,materialSpecularStrength:()=>yq,materialThickness:()=>xq,materialTransmission:()=>bq,max:()=>v3,maxMipLevel:()=>vq,mediumpModelViewMatrix:()=>RH,metalness:()=>Tq,min:()=>wq,mix:()=>ml,mixElement:()=>Sq,mod:()=>Mq,modInt:()=>_q,modelDirection:()=>Nq,modelNormalMatrix:()=>Aq,modelPosition:()=>Cq,modelRadius:()=>Rq,modelScale:()=>Eq,modelViewMatrix:()=>Pq,modelViewPosition:()=>Fq,modelViewProjection:()=>Lq,modelWorldMatrix:()=>Iq,modelWorldMatrixInverse:()=>zq,morphReference:()=>Bq,mrt:()=>Vq,mul:()=>qs,mx_aastep:()=>Oq,mx_cell_noise_float:()=>kq,mx_contrast:()=>Uq,mx_fractal_noise_float:()=>Dq,mx_fractal_noise_vec2:()=>$q,mx_fractal_noise_vec3:()=>Gq,mx_fractal_noise_vec4:()=>jq,mx_hsvtorgb:()=>Wq,mx_noise_float:()=>Hq,mx_noise_vec3:()=>qq,mx_noise_vec4:()=>Xq,mx_ramplr:()=>Yq,mx_ramptb:()=>Zq,mx_rgbtohsv:()=>Jq,mx_safepower:()=>Qq,mx_splitlr:()=>Kq,mx_splittb:()=>eX,mx_srgb_texture_to_lin_rec709:()=>tX,mx_transform_uv:()=>rX,mx_worley_noise_float:()=>sX,mx_worley_noise_vec2:()=>iX,mx_worley_noise_vec3:()=>nX,namespace:()=>aX,negate:()=>oX,neutralToneMapping:()=>lX,nodeArray:()=>uX,nodeImmutable:()=>hX,nodeObject:()=>cX,nodeObjects:()=>dX,nodeProxy:()=>pX,normalFlat:()=>mX,normalGeometry:()=>fX,normalLocal:()=>gX,normalMap:()=>yX,normalView:()=>xX,normalWorld:()=>bX,normalize:()=>vX,not:()=>TX,notEqual:()=>wX,numWorkgroups:()=>SX,objectDirection:()=>MX,objectGroup:()=>_X,objectPosition:()=>NX,objectRadius:()=>AX,objectScale:()=>CX,objectViewPosition:()=>RX,objectWorldMatrix:()=>EX,oneMinus:()=>PX,or:()=>FX,orthographicDepthToViewZ:()=>LX,oscSawtooth:()=>IX,oscSine:()=>zX,oscSquare:()=>BX,oscTriangle:()=>VX,output:()=>OX,outputStruct:()=>kX,overlay:()=>UX,overloadingFn:()=>DX,parabola:()=>$X,parallaxDirection:()=>GX,parallaxUV:()=>jX,parameter:()=>WX,pass:()=>HX,passTexture:()=>qX,pcurve:()=>XX,perspectiveDepthToViewZ:()=>YX,pmremTexture:()=>ZX,pointShadow:()=>rZ,pointUV:()=>JX,pointWidth:()=>QX,positionGeometry:()=>KX,positionLocal:()=>eY,positionPrevious:()=>tY,positionView:()=>rY,positionViewDirection:()=>sY,positionWorld:()=>iY,positionWorldDirection:()=>nY,posterize:()=>aY,pow:()=>T3,pow2:()=>oY,pow3:()=>lY,pow4:()=>uY,premult:()=>hY,property:()=>cY,radians:()=>dY,rand:()=>pY,range:()=>mY,rangeFog:()=>fY,rangeFogFactor:()=>gY,reciprocal:()=>yY,reference:()=>bY,referenceBuffer:()=>vY,reflect:()=>TY,reflectVector:()=>wY,reflectView:()=>SY,reflector:()=>MY,refract:()=>_Y,refractVector:()=>NY,refractView:()=>AY,reinhardToneMapping:()=>CY,remainder:()=>RY,remap:()=>EY,remapClamp:()=>PY,renderGroup:()=>FY,renderOutput:()=>LY,rendererReference:()=>IY,rotate:()=>zY,rotateUV:()=>BY,roughness:()=>VY,round:()=>OY,rtt:()=>kY,sRGBTransferEOTF:()=>UY,sRGBTransferOETF:()=>DY,sampler:()=>$Y,samplerComparison:()=>GY,saturate:()=>jY,saturation:()=>WY,screen:()=>HY,screenCoordinate:()=>qY,screenSize:()=>XY,screenUV:()=>YY,scriptable:()=>ZY,scriptableValue:()=>JY,select:()=>QY,setCurrentStack:()=>KY,shaderStages:()=>eZ,shadow:()=>tZ,shadowPositionWorld:()=>sZ,shapeCircle:()=>nZ,sharedUniformGroup:()=>iZ,sheen:()=>aZ,sheenRoughness:()=>oZ,shiftLeft:()=>lZ,shiftRight:()=>uZ,shininess:()=>hZ,sign:()=>cZ,sin:()=>no,sinc:()=>dZ,skinning:()=>pZ,smoothstep:()=>gb,smoothstepElement:()=>mZ,specularColor:()=>fZ,specularF90:()=>gZ,spherizeUV:()=>yZ,split:()=>xZ,spritesheetUV:()=>bZ,sqrt:()=>vZ,stack:()=>TZ,step:()=>wZ,storage:()=>SZ,storageBarrier:()=>MZ,storageObject:()=>_Z,storageTexture:()=>NZ,string:()=>AZ,struct:()=>CZ,sub:()=>Sd,subgroupIndex:()=>RZ,subgroupSize:()=>EZ,tan:()=>PZ,tangentGeometry:()=>FZ,tangentLocal:()=>LZ,tangentView:()=>IZ,tangentWorld:()=>zZ,temp:()=>BZ,texture:()=>VZ,texture3D:()=>OZ,textureBarrier:()=>kZ,textureBicubic:()=>UZ,textureCubeUV:()=>DZ,textureLoad:()=>$Z,textureSize:()=>GZ,textureStore:()=>jZ,thickness:()=>WZ,time:()=>Lv,timerDelta:()=>HZ,timerGlobal:()=>qZ,timerLocal:()=>XZ,toneMapping:()=>YZ,toneMappingExposure:()=>ZZ,toonOutlinePass:()=>JZ,transformDirection:()=>QZ,transformNormal:()=>KZ,transformNormalToView:()=>eJ,transformedBentNormalView:()=>tJ,transformedBitangentView:()=>rJ,transformedBitangentWorld:()=>sJ,transformedClearcoatNormalView:()=>iJ,transformedNormalView:()=>nJ,transformedNormalWorld:()=>aJ,transformedTangentView:()=>oJ,transformedTangentWorld:()=>lJ,transmission:()=>uJ,transpose:()=>hJ,triNoise3D:()=>cJ,triplanarTexture:()=>dJ,triplanarTextures:()=>pJ,trunc:()=>mJ,tslFn:()=>fJ,uint:()=>gJ,uniform:()=>yJ,uniformArray:()=>bJ,uniformCubeTexture:()=>xJ,uniformGroup:()=>vJ,uniformTexture:()=>TJ,uniforms:()=>wJ,unpremult:()=>SJ,userData:()=>MJ,uv:()=>Iv,uvec2:()=>_J,uvec3:()=>NJ,uvec4:()=>AJ,varying:()=>RJ,varyingProperty:()=>EJ,vec2:()=>zv,vec3:()=>Bv,vec4:()=>Ur,vectorComponents:()=>PJ,velocity:()=>FJ,vertexColor:()=>LJ,vertexIndex:()=>IJ,vibrance:()=>zJ,viewZToLogarithmicDepth:()=>BJ,viewZToOrthographicDepth:()=>VJ,viewZToPerspectiveDepth:()=>OJ,viewport:()=>kJ,viewportBottomLeft:()=>UJ,viewportCoordinate:()=>DJ,viewportDepthTexture:()=>$J,viewportLinearDepth:()=>GJ,viewportMipTexture:()=>jJ,viewportResolution:()=>WJ,viewportSafeUV:()=>HJ,viewportSharedTexture:()=>qJ,viewportSize:()=>XJ,viewportTexture:()=>YJ,viewportTopLeft:()=>ZJ,viewportUV:()=>JJ,wgsl:()=>QJ,wgslFn:()=>KJ,workgroupArray:()=>eQ,workgroupBarrier:()=>tQ,workgroupId:()=>rQ,workingToColorSpace:()=>sQ,xor:()=>iQ});const p7=y.BRDF_GGX,m7=y.BRDF_Lambert,f7=y.BasicShadowFilter,g7=y.Break,y7=y.Continue,x7=y.DFGApprox,b7=y.D_GGX,v7=y.Discard,T7=y.EPSILON,w7=y.F_Schlick,S7=y.Fn,M7=y.INFINITY,_7=y.If,N7=y.Switch,A7=y.Loop,C7=y.NodeShaderStage,R7=y.NodeType,E7=y.NodeUpdateType,P7=y.NodeAccess,F7=y.PCFShadowFilter,L7=y.PCFSoftShadowFilter,I7=y.PI,z7=y.PI2,B7=y.Return,V7=y.Schlick_to_F0,O7=y.ScriptableNodeResources,k7=y.ShaderNode,U7=y.TBNViewMatrix,D7=y.VSMShadowFilter,$7=y.V_GGX_SmithCorrelated,G7=y.abs,j7=y.acesFilmicToneMapping,W7=y.acos,pb=y.add,H7=y.addNodeElement,q7=y.agxToneMapping,X7=y.all,Y7=y.alphaT,Z7=y.and,J7=y.anisotropy,Q7=y.anisotropyB,K7=y.anisotropyT,eG=y.any,tG=y.append,rG=y.array,sG=y.arrayBuffer,iG=y.asin,nG=y.assign,aG=y.atan,oG=y.atan2,lG=y.atomicAdd,uG=y.atomicAnd,hG=y.atomicFunc,cG=y.atomicMax,dG=y.atomicMin,pG=y.atomicOr,mG=y.atomicStore,fG=y.atomicSub,gG=y.atomicXor,yG=y.atomicLoad,xG=y.attenuationColor,bG=y.attenuationDistance,vG=y.attribute,TG=y.attributeArray,wG=y.backgroundBlurriness,SG=y.backgroundIntensity,MG=y.backgroundRotation,_G=y.batch,NG=y.billboarding,AG=y.bitAnd,CG=y.bitNot,RG=y.bitOr,EG=y.bitXor,PG=y.bitangentGeometry,FG=y.bitangentLocal,LG=y.bitangentView,IG=y.bitangentWorld,zG=y.bitcast,BG=y.blendBurn,VG=y.blendColor,OG=y.blendDodge,kG=y.blendOverlay,UG=y.blendScreen,DG=y.blur,$G=y.bool,GG=y.buffer,jG=y.bufferAttribute,WG=y.bumpMap,HG=y.burn,qG=y.bvec2,XG=y.bvec3,YG=y.bvec4,ZG=y.bypass,JG=y.cache,QG=y.call,KG=y.cameraFar,ej=y.cameraIndex,tj=y.cameraNear,rj=y.cameraNormalMatrix,sj=y.cameraPosition,ij=y.cameraProjectionMatrix,nj=y.cameraProjectionMatrixInverse,aj=y.cameraViewMatrix,oj=y.cameraWorldMatrix,lj=y.cbrt,uj=y.cdl,hj=y.ceil,cj=y.checker,dj=y.cineonToneMapping,x3=y.clamp,pj=y.clearcoat,mj=y.clearcoatRoughness,fj=y.code,gj=y.color,yj=y.colorSpaceToWorking,xj=y.colorToDirection,bj=y.compute,vj=y.computeSkinning,Tj=y.cond,wj=y.Const,Sj=y.context,Mj=y.convert,_j=y.convertColorSpace,Nj=y.convertToTexture,ff=y.cos,Aj=y.cross,Cj=y.cubeTexture,Rj=y.dFdx,Ej=y.dFdy,Pj=y.dashSize,Fj=y.debug,Lj=y.decrement,Ij=y.decrementBefore,zj=y.defaultBuildStages,Bj=y.defaultShaderStages,Vj=y.defined,Oj=y.degrees,kj=y.deltaTime,Uj=y.densityFog,Dj=y.densityFogFactor,$j=y.depth,Gj=y.depthPass,jj=y.difference,Wj=y.diffuseColor,Hj=y.directPointLight,qj=y.directionToColor,Xj=y.dispersion,Yj=y.distance,Zj=y.div,Jj=y.dodge,wd=y.dot,Qj=y.drawIndex,Kj=y.dynamicBufferAttribute,eW=y.element,tW=y.emissive,rW=y.equal,sW=y.equals,iW=y.equirectUV,nW=y.exp,aW=y.exp2,oW=y.expression,lW=y.faceDirection,uW=y.faceForward,hW=y.faceforward,mb=y.float,cW=y.floor,dW=y.fog,fb=y.fract,pW=y.frameGroup,mW=y.frameId,fW=y.frontFacing,b3=y.fwidth,gW=y.gain,yW=y.gapSize,xW=y.getConstNodeType,bW=y.getCurrentStack,vW=y.getDirection,TW=y.getDistanceAttenuation,wW=y.getGeometryRoughness,SW=y.getNormalFromDepth,MW=y.getParallaxCorrectNormal,_W=y.getRoughness,NW=y.getScreenPosition,AW=y.getShIrradianceAt,CW=y.getTextureIndex,RW=y.getViewPosition,EW=y.getShadowMaterial,PW=y.getShadowRenderObjectFunction,FW=y.glsl,LW=y.glslFn,IW=y.grayscale,zW=y.greaterThan,BW=y.greaterThanEqual,VW=y.hash,OW=y.highpModelNormalViewMatrix,kW=y.highpModelViewMatrix,UW=y.hue,DW=y.increment,$W=y.incrementBefore,GW=y.instance,jW=y.instanceIndex,WW=y.instancedArray,HW=y.instancedBufferAttribute,qW=y.instancedDynamicBufferAttribute,XW=y.instancedMesh,YW=y.int,ZW=y.inverseSqrt,JW=y.inversesqrt,QW=y.invocationLocalIndex,KW=y.invocationSubgroupIndex,eH=y.ior,tH=y.iridescence,rH=y.iridescenceIOR,sH=y.iridescenceThickness,iH=y.ivec2,nH=y.ivec3,aH=y.ivec4,oH=y.js,lH=y.label,uH=y.length,hH=y.lengthSq,cH=y.lessThan,dH=y.lessThanEqual,pH=y.lightPosition,mH=y.lightShadowMatrix,fH=y.lightTargetDirection,gH=y.lightTargetPosition,yH=y.lightViewPosition,xH=y.lightingContext,bH=y.lights,vH=y.linearDepth,TH=y.linearToneMapping,wH=y.localId,SH=y.globalId,MH=y.log,_H=y.log2,NH=y.logarithmicDepthToViewZ,AH=y.loop,CH=y.luminance,RH=y.mediumpModelViewMatrix,EH=y.mat2,PH=y.mat3,FH=y.mat4,LH=y.matcapUV,IH=y.materialAO,zH=y.materialAlphaTest,BH=y.materialAnisotropy,VH=y.materialAnisotropyVector,OH=y.materialAttenuationColor,kH=y.materialAttenuationDistance,UH=y.materialClearcoat,DH=y.materialClearcoatNormal,$H=y.materialClearcoatRoughness,GH=y.materialColor,jH=y.materialDispersion,WH=y.materialEmissive,HH=y.materialIOR,qH=y.materialIridescence,XH=y.materialIridescenceIOR,YH=y.materialIridescenceThickness,ZH=y.materialLightMap,JH=y.materialLineDashOffset,QH=y.materialLineDashSize,KH=y.materialLineGapSize,eq=y.materialLineScale,tq=y.materialLineWidth,rq=y.materialMetalness,sq=y.materialNormal,iq=y.materialOpacity,nq=y.materialPointSize,aq=y.materialReference,oq=y.materialReflectivity,lq=y.materialRefractionRatio,uq=y.materialRotation,hq=y.materialRoughness,cq=y.materialSheen,dq=y.materialSheenRoughness,pq=y.materialShininess,mq=y.materialSpecular,fq=y.materialSpecularColor,gq=y.materialSpecularIntensity,yq=y.materialSpecularStrength,xq=y.materialThickness,bq=y.materialTransmission,v3=y.max,vq=y.maxMipLevel,Tq=y.metalness,wq=y.min,ml=y.mix,Sq=y.mixElement,Mq=y.mod,_q=y.modInt,Nq=y.modelDirection,Aq=y.modelNormalMatrix,Cq=y.modelPosition,Rq=y.modelRadius,Eq=y.modelScale,Pq=y.modelViewMatrix,Fq=y.modelViewPosition,Lq=y.modelViewProjection,Iq=y.modelWorldMatrix,zq=y.modelWorldMatrixInverse,Bq=y.morphReference,Vq=y.mrt,qs=y.mul,Oq=y.mx_aastep,kq=y.mx_cell_noise_float,Uq=y.mx_contrast,Dq=y.mx_fractal_noise_float,$q=y.mx_fractal_noise_vec2,Gq=y.mx_fractal_noise_vec3,jq=y.mx_fractal_noise_vec4,Wq=y.mx_hsvtorgb,Hq=y.mx_noise_float,qq=y.mx_noise_vec3,Xq=y.mx_noise_vec4,Yq=y.mx_ramplr,Zq=y.mx_ramptb,Jq=y.mx_rgbtohsv,Qq=y.mx_safepower,Kq=y.mx_splitlr,eX=y.mx_splittb,tX=y.mx_srgb_texture_to_lin_rec709,rX=y.mx_transform_uv,sX=y.mx_worley_noise_float,iX=y.mx_worley_noise_vec2,nX=y.mx_worley_noise_vec3,aX=y.namespace,oX=y.negate,lX=y.neutralToneMapping,uX=y.nodeArray,hX=y.nodeImmutable,cX=y.nodeObject,dX=y.nodeObjects,pX=y.nodeProxy,mX=y.normalFlat,fX=y.normalGeometry,gX=y.normalLocal,yX=y.normalMap,xX=y.normalView,bX=y.normalWorld,vX=y.normalize,TX=y.not,wX=y.notEqual,SX=y.numWorkgroups,MX=y.objectDirection,_X=y.objectGroup,NX=y.objectPosition,AX=y.objectRadius,CX=y.objectScale,RX=y.objectViewPosition,EX=y.objectWorldMatrix,PX=y.oneMinus,FX=y.or,LX=y.orthographicDepthToViewZ,IX=y.oscSawtooth,zX=y.oscSine,BX=y.oscSquare,VX=y.oscTriangle,OX=y.output,kX=y.outputStruct,UX=y.overlay,DX=y.overloadingFn,$X=y.parabola,GX=y.parallaxDirection,jX=y.parallaxUV,WX=y.parameter,HX=y.pass,qX=y.passTexture,XX=y.pcurve,YX=y.perspectiveDepthToViewZ,ZX=y.pmremTexture,JX=y.pointUV,QX=y.pointWidth,KX=y.positionGeometry,eY=y.positionLocal,tY=y.positionPrevious,rY=y.positionView,sY=y.positionViewDirection,iY=y.positionWorld,nY=y.positionWorldDirection,aY=y.posterize,T3=y.pow,oY=y.pow2,lY=y.pow3,uY=y.pow4,hY=y.premult,cY=y.property,dY=y.radians,pY=y.rand,mY=y.range,fY=y.rangeFog,gY=y.rangeFogFactor,yY=y.reciprocal,xY=y.lightProjectionUV,bY=y.reference,vY=y.referenceBuffer,TY=y.reflect,wY=y.reflectVector,SY=y.reflectView,MY=y.reflector,_Y=y.refract,NY=y.refractVector,AY=y.refractView,CY=y.reinhardToneMapping,RY=y.remainder,EY=y.remap,PY=y.remapClamp,FY=y.renderGroup,LY=y.renderOutput,IY=y.rendererReference,zY=y.rotate,BY=y.rotateUV,VY=y.roughness,OY=y.round,kY=y.rtt,UY=y.sRGBTransferEOTF,DY=y.sRGBTransferOETF,$Y=y.sampler,GY=y.samplerComparison,jY=y.saturate,WY=y.saturation,HY=y.screen,qY=y.screenCoordinate,XY=y.screenSize,YY=y.screenUV,ZY=y.scriptable,JY=y.scriptableValue,QY=y.select,KY=y.setCurrentStack,eZ=y.shaderStages,tZ=y.shadow,rZ=y.pointShadow,sZ=y.shadowPositionWorld,iZ=y.sharedUniformGroup,nZ=y.shapeCircle,aZ=y.sheen,oZ=y.sheenRoughness,lZ=y.shiftLeft,uZ=y.shiftRight,hZ=y.shininess,cZ=y.sign,no=y.sin,dZ=y.sinc,pZ=y.skinning,gb=y.smoothstep,mZ=y.smoothstepElement,fZ=y.specularColor,gZ=y.specularF90,yZ=y.spherizeUV,xZ=y.split,bZ=y.spritesheetUV,vZ=y.sqrt,TZ=y.stack,wZ=y.step,SZ=y.storage,MZ=y.storageBarrier,_Z=y.storageObject,NZ=y.storageTexture,AZ=y.string,CZ=y.struct,Sd=y.sub,RZ=y.subgroupIndex,EZ=y.subgroupSize,PZ=y.tan,FZ=y.tangentGeometry,LZ=y.tangentLocal,IZ=y.tangentView,zZ=y.tangentWorld,BZ=y.temp,VZ=y.texture,OZ=y.texture3D,kZ=y.textureBarrier,UZ=y.textureBicubic,DZ=y.textureCubeUV,$Z=y.textureLoad,GZ=y.textureSize,jZ=y.textureStore,WZ=y.thickness,Lv=y.time,HZ=y.timerDelta,qZ=y.timerGlobal,XZ=y.timerLocal,YZ=y.toneMapping,ZZ=y.toneMappingExposure,JZ=y.toonOutlinePass,QZ=y.transformDirection,KZ=y.transformNormal,eJ=y.transformNormalToView,tJ=y.transformedBentNormalView,rJ=y.transformedBitangentView,sJ=y.transformedBitangentWorld,iJ=y.transformedClearcoatNormalView,nJ=y.transformedNormalView,aJ=y.transformedNormalWorld,oJ=y.transformedTangentView,lJ=y.transformedTangentWorld,uJ=y.transmission,hJ=y.transpose,cJ=y.triNoise3D,dJ=y.triplanarTexture,pJ=y.triplanarTextures,mJ=y.trunc,fJ=y.tslFn,gJ=y.uint,yJ=y.uniform,xJ=y.uniformCubeTexture,bJ=y.uniformArray,vJ=y.uniformGroup,TJ=y.uniformTexture,wJ=y.uniforms,SJ=y.unpremult,MJ=y.userData,Iv=y.uv,_J=y.uvec2,NJ=y.uvec3,AJ=y.uvec4,CJ=y.Var,RJ=y.varying,EJ=y.varyingProperty,zv=y.vec2,Bv=y.vec3,Ur=y.vec4,PJ=y.vectorComponents,FJ=y.velocity,LJ=y.vertexColor,IJ=y.vertexIndex,zJ=y.vibrance,BJ=y.viewZToLogarithmicDepth,VJ=y.viewZToOrthographicDepth,OJ=y.viewZToPerspectiveDepth,kJ=y.viewport,UJ=y.viewportBottomLeft,DJ=y.viewportCoordinate,$J=y.viewportDepthTexture,GJ=y.viewportLinearDepth,jJ=y.viewportMipTexture,WJ=y.viewportResolution,HJ=y.viewportSafeUV,qJ=y.viewportSharedTexture,XJ=y.viewportSize,YJ=y.viewportTexture,ZJ=y.viewportTopLeft,JJ=y.viewportUV,QJ=y.wgsl,KJ=y.wgslFn,eQ=y.workgroupArray,tQ=y.workgroupBarrier,rQ=y.workgroupId,sQ=y.workingToColorSpace,iQ=y.xor;function nQ(t,e,r=1){let s=t.rgb,i=e.rgb,n=qs(s,i),a=qs(e.a,r),o=ml(s,n,a),l=v3(t.a,qs(e.a,r));return Ur(o,l)}function aQ(t,e,r=1){let s=qs(e.a,r),i=pb(s,qs(t.a,Sd(1,s))),n=pb(qs(e.rgb,s),qs(t.rgb,qs(t.a,Sd(1,s))));return Ur(n,i)}const eM={normal:aQ,multiply:nQ};function au(t,e,r="normal",s=1){return(eM[r]||eM.normal)(t,e,s)}function oQ(t,e){let r=qs(t.a,e.a);return Ur(t.rgb,r)}function lQ(t,e){let r=Sd(1,e.a),s=qs(t.a,r);return Ur(t.rgb,s)}function uQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=qs(t.a,s);return Ur(t.rgb,i)}function hQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=Sd(1,s),n=qs(t.a,i);return Ur(t.rgb,n)}const tM={alpha:oQ,alphaInverted:lQ,luminance:uQ,luminanceInverted:hQ};function cQ(t,e,r="alpha"){return(tM[r]||tM.alpha)(t,e)}const rM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};let sM=!1;const dQ=()=>{try{if(rM!==void 0){let{MODE:t,DEV:e}=rM;return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function pQ(){let t=`renderer_${Math.random().toString(36).substring(2,11)}`,e=null,r,s,i,n,a,o={nodes:new Map,rootId:null,idToNodeId:new Map},l=null,h=null,u=null,c=!1,d=!1,p=!1,m=null,f=!1,g=!0,b=0,v=0,w=0,T=0,N=8,S=.5,_=.5,A=!1,D=!1,K=!1,J=[],re=!1,te=[],oe=!1,ae=()=>{var le;return(le=window).matchMedia?.call(le,"(prefers-reduced-motion: reduce)").matches??!1},ge=(le,pe)=>{if(le===b&&pe===v)return;let ye=performance.now();if(ye-w<N)return;b=le,v=pe,w=ye,r.setSize(le,pe,!1);let Re=le/pe,bt=2,or=bt*Re;s.left=-or/2,s.right=or/2,s.top=bt/2,s.bottom=-2/2,s.updateProjectionMatrix(),n.scale.set(or,bt,1),o.rootId&&p&&me(),qt().catch(console.warn)},fe=le=>{if(!r||!s||!n)return;let pe=le[0];if(!pe)return;let{width:ye,height:Re}=pe.contentRect,bt=Math.round(ye),or=Math.round(Re);ge(bt,or)},ve=le=>{let pe=le[0];pe&&(f=pe.isIntersecting,f?(a&&c&&o.rootId&&me(),g&&br()):Pi())},me=()=>{if(!o.rootId||!a||D)return;if(o.nodes.get(o.rootId)){D=!0;try{let pe=ft(o.rootId);pe&&a&&(a.fragmentNode=pe,a.needsUpdate=!0)}catch(pe){console.error("Error composing shader tree:",pe)}finally{D=!1}f&&qt().catch(console.warn)}},he=le=>{let pe=[];return o.nodes.forEach(ye=>{ye.parentId===le&&pe.push(ye)}),pe},Te=le=>{for(let[pe,ye]of o.nodes.entries())if(ye.metadata.id===le)return pe;return null},Ge=(le,pe,ye,Re)=>{if(!pe.metadata.mask?.source)return le;let bt=pe.metadata.mask.source,or=Te(bt);if(!or)return le;if(Re.has(or))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),le;let Lo=new Set(Re);Lo.add(ye);let os=ft(or,Lo),kl=pe.metadata.mask.type||"alpha";return cQ(le,os,kl)},He=le=>{let pe=o.nodes.get(le);if(!pe||!pe.metadata.id)return!1;let ye=pe.metadata.id;for(let Re of o.nodes.values())if(Re.metadata.mask?.source===ye)return!0;return!1},ft=(le,pe=new Set)=>{let ye=o.nodes.get(le);if(!ye)return Ur(0,0,0,0);let Re=os=>{ye.cleanupCallbacks.push(os)},bt=os=>{ye.beforeRenderCallbacks.push(os)},or=os=>{ye.afterRenderCallbacks.push(os)},Lo=he(le);if(Lo.length===0){let os=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:void 0,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(os,ye,le,pe)}else{let os=[...Lo].sort((Li,rc)=>Li.metadata.renderOrder-rc.metadata.renderOrder);if(ye.parentId===null){let Li;for(let vr of os){if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let _p=ft(vr.id,pe),Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),_p,"normal",1):au(Ur(1,1,1,0),_p,vr.metadata.blendMode,Dn):au(Li,_p,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}else{let Li;for(let vr of os){let Mp=ft(vr.id,pe);if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),Mp,"normal",1):au(Ur(1,1,1,0),Mp,vr.metadata.blendMode,Dn):au(Li,Mp,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}}},ht=(le,pe,ye,Re,bt={})=>{let or=0;if(ye!==null){let os=Array.from(o.nodes.values()).filter(kl=>kl.parentId===ye);os.length>0&&(or=Math.max(...os.map(kl=>kl.metadata.renderOrder))+1)}let Lo={id:le,fragmentNodeFunc:pe,parentId:ye,metadata:{blendMode:Re?.blendMode||"normal",opacity:Re?.opacity,id:Re?.id,mask:Re?.mask,renderOrder:Re?.renderOrder===void 0?or:Re?.renderOrder},uniforms:bt,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};o.nodes.set(le,Lo),ye===null&&(o.rootId=le),a&&c&&(J.includes(le)||J.push(le),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],me()})))},Ft=(le,pe,ye)=>{let Re=o.nodes.get(le);if(!Re||!Re.uniforms){console.warn(`Node or uniforms not found for ID: ${le}`);return}let bt=Re.uniforms[pe];if(!bt||!bt.uniform){console.warn(`Uniform ${pe} not found in node: ${le}`);return}bt.uniform.value=ye,f&&qt()},ri=(le,pe)=>{let ye=o.nodes.get(le);if(!ye)return;let Re=!1;pe.blendMode!==void 0&&ye.metadata.blendMode!==pe.blendMode&&(ye.metadata.blendMode=pe.blendMode,Re=!0),pe.opacity!==void 0&&ye.metadata.opacity!==pe.opacity&&(ye.metadata.opacity=pe.opacity,Re=!0),pe.renderOrder!==void 0&&ye.metadata.renderOrder!==pe.renderOrder&&(ye.metadata.renderOrder=pe.renderOrder,Re=!0),pe.id!==void 0&&ye.metadata.id!==pe.id&&(ye.metadata.id=pe.id,Re=!0),pe.mask!==void 0&&(ye.metadata.mask?.source!==pe.mask?.source||ye.metadata.mask?.type!==pe.mask?.type)&&(ye.metadata.mask=pe.mask,Re=!0),Re&&a&&c?(te.includes(le)||te.push(le),oe||(oe=!0,queueMicrotask(()=>{oe=!1,te=[],me()}))):f&&qt()},ar=le=>{if(!o.nodes.has(le))return;let pe=o.nodes.get(le);if(pe&&pe.cleanupCallbacks.length>0)for(let Re of pe.cleanupCallbacks)try{Re()}catch(bt){console.error(`Error executing cleanup callback for node ${le}:`,bt)}let ye=he(le);for(let Re of ye)ar(Re.id);o.rootId===le&&(o.rootId=null),o.nodes.delete(le),a&&c&&me()},et=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.beforeRenderCallbacks.length>0)for(let Re of ye.beforeRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing before render callback for node ${ye.id}:`,bt)}},Wr=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.afterRenderCallbacks.length>0)for(let Re of ye.afterRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing after render callback for node ${ye.id}:`,bt)}},qt=async()=>{if(!c||!r||!i||!s||!a)return;let le=performance.now(),pe=T>0?(le-T)/1e3:.016,ye=Math.min(pe,.1);T=le,et(ye);try{if(D)return;r instanceof KS?await r.renderAsync(i,s).then(()=>{c&&Wr(ye)}).catch(Re=>{console.error("WebGPU render error:",Re)}):(r.render(i,s),Wr(ye))}catch(Re){console.error("Render frame error:",Re)}},br=()=>{if(l||!g||!f)return;let le=()=>{l=requestAnimationFrame(le),qt().catch(console.warn)};le()},Pi=()=>{l&&(cancelAnimationFrame(l),l=null)},ns=le=>{if(!e){console.log(`[${t}] No canvas element in updatePointerCoords`);return}let pe,ye;if("touches"in le){if(le.touches.length===0)return;pe=le.touches[0].clientX,ye=le.touches[0].clientY}else pe=le.clientX,ye=le.clientY;let Re=e.getBoundingClientRect(),bt=(pe-Re.left)/Re.width,or=(ye-Re.top)/Re.height;S=bt,_=or},as=le=>{ns(le)},Fi=le=>{ns(le)},vp=()=>{A=!1,qt().catch(console.warn)},Tp=()=>{A=!1,qt().catch(console.warn)},wp=()=>{A=!0,qt().catch(console.warn)},Sp=()=>{A=!0,qt().catch(console.warn)};return{initialize:async({canvas:le})=>{if(c||d)return;d=!0,m=new AbortController;let pe=m;try{if(e=le,i=new xg,i.background=null,s=new bg(-1,1,1,-1,.1,10),s.position.z=1,s.lookAt(0,0,0),K||(window.addEventListener("mousemove",as),window.addEventListener("touchmove",Fi),window.addEventListener("mouseup",vp),window.addEventListener("touchend",Tp),le.addEventListener("mousedown",wp),le.addEventListener("touchstart",Sp),K=!0,console.log(`[${t}] Added event listeners`)),pe.signal.aborted)return;try{if(r=new KS({canvas:le,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await r.init(),pe.signal.aborted){r.dispose();return}}catch(or){if(pe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",or);return}if(pe.signal.aborted){r&&r.dispose();return}r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.outputColorSpace=ws,a=new VR({transparent:!0}),a.fragmentNode=Ur(0,0,0,0);let ye=new T2(2,2);n=new Nn(ye,a),i.add(n),h=new ResizeObserver(fe),h.observe(le),u=new IntersectionObserver(ve,{threshold:0}),u.observe(le),g=!ae();let{width:Re,height:bt}=le.getBoundingClientRect();ge(Math.round(Re),Math.round(bt)),p=!0,await qt(),g&&f&&br(),pe.signal.aborted||(c=!0)}catch(ye){console.error("[Shaders] Initialization error:",ye)}finally{d=!1,m===pe&&(m=null)}},cleanup:()=>{if(console.log(`[${t}] Cleanup called`),m&&m.abort(),h&&(h.disconnect(),h=null),u&&(u.disconnect(),u=null),K&&(console.log(`[${t}] Removing event listeners`),e&&(e.removeEventListener("mousedown",wp),e.removeEventListener("touchstart",Sp)),window&&(window.removeEventListener("mousemove",as),window.removeEventListener("touchmove",Fi),window.removeEventListener("mouseup",vp),window.removeEventListener("touchend",Tp)),K=!1),Pi(),o.nodes.clear(),o.rootId=null,o.idToNodeId.clear(),J=[],re=!1,te=[],oe=!1,n&&(i&&i.remove(n),n.geometry&&n.geometry.dispose(),n.material instanceof bs&&n.material.dispose()),r&&typeof r.dispose=="function")try{r.dispose()}catch(le){console.warn("Error disposing renderer:",le)}e=null,r=null,s=null,i=null,n=null,a=null,c=!1,d=!1,p=!1,m=null,b=0,v=0,f=!1,g=!0,S=.5,_=.5,A=!1},registerNode:ht,removeNode:ar,updateUniformValue:Ft,updateNodeMetadata:ri,showLicenseWarning:()=>{!dQ()||sM||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),sM=!0)}}}const{uniform:mQ}=_t;function Bt(t,e,r){let s={};return Object.entries(t.props).forEach(([i,n])=>{let a=e[i],o=a;n.transform&&(o=n.transform(a)),s[i]={uniform:mQ(o).label(`${i}_${r}`),transform:n.transform||void 0}}),s}const{vec2:Qme,fract:Kme,sin:efe,dot:tfe}=_t,{vec2:rfe}=_t;/**
430
430
  * @license
431
431
  * Copyright 2010-2025 Three.js Authors
432
432
  * SPDX-License-Identifier: MIT
@@ -487,7 +487,7 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
487
487
  * @license
488
488
  * Copyright 2010-2025 Three.js Authors
489
489
  * SPDX-License-Identifier: MIT
490
- */x.BRDF_GGX;x.BRDF_Lambert;x.BasicShadowFilter;x.Break;x.Continue;x.DFGApprox;x.D_GGX;x.Discard;x.EPSILON;x.F_Schlick;x.Fn;x.INFINITY;x.If;x.Switch;x.Loop;x.NodeShaderStage;x.NodeType;x.NodeUpdateType;x.NodeAccess;x.PCFShadowFilter;x.PCFSoftShadowFilter;x.PI;x.PI2;x.Return;x.Schlick_to_F0;x.ScriptableNodeResources;x.ShaderNode;x.TBNViewMatrix;x.VSMShadowFilter;x.V_GGX_SmithCorrelated;x.abs;x.acesFilmicToneMapping;x.acos;x.add;x.addNodeElement;x.agxToneMapping;x.all;x.alphaT;x.and;x.anisotropy;x.anisotropyB;x.anisotropyT;x.any;x.append;x.array;x.arrayBuffer;x.asin;x.assign;x.atan;x.atan2;x.atomicAdd;x.atomicAnd;x.atomicFunc;x.atomicMax;x.atomicMin;x.atomicOr;x.atomicStore;x.atomicSub;x.atomicXor;x.atomicLoad;x.attenuationColor;x.attenuationDistance;x.attribute;x.attributeArray;x.backgroundBlurriness;x.backgroundIntensity;x.backgroundRotation;x.batch;x.billboarding;x.bitAnd;x.bitNot;x.bitOr;x.bitXor;x.bitangentGeometry;x.bitangentLocal;x.bitangentView;x.bitangentWorld;x.bitcast;x.blendBurn;x.blendColor;x.blendDodge;x.blendOverlay;x.blendScreen;x.blur;x.bool;x.buffer;x.bufferAttribute;x.bumpMap;x.burn;x.bvec2;x.bvec3;x.bvec4;x.bypass;x.cache;x.call;x.cameraFar;x.cameraIndex;x.cameraNear;x.cameraNormalMatrix;x.cameraPosition;x.cameraProjectionMatrix;x.cameraProjectionMatrixInverse;x.cameraViewMatrix;x.cameraWorldMatrix;x.cbrt;x.cdl;x.ceil;x.checker;x.cineonToneMapping;x.clamp;x.clearcoat;x.clearcoatRoughness;x.code;x.color;x.colorSpaceToWorking;x.colorToDirection;x.compute;x.computeSkinning;x.cond;x.Const;x.context;x.convert;x.convertColorSpace;x.convertToTexture;x.cos;x.cross;x.cubeTexture;x.dFdx;x.dFdy;x.dashSize;x.debug;x.decrement;x.decrementBefore;x.defaultBuildStages;x.defaultShaderStages;x.defined;x.degrees;x.deltaTime;x.densityFog;x.densityFogFactor;x.depth;x.depthPass;x.difference;x.diffuseColor;x.directPointLight;x.directionToColor;x.dispersion;x.distance;x.div;x.dodge;x.dot;x.drawIndex;x.dynamicBufferAttribute;x.element;x.emissive;x.equal;x.equals;x.equirectUV;x.exp;x.exp2;x.expression;x.faceDirection;x.faceForward;x.faceforward;x.float;x.floor;x.fog;x.fract;x.frameGroup;x.frameId;x.frontFacing;x.fwidth;x.gain;x.gapSize;x.getConstNodeType;x.getCurrentStack;x.getDirection;x.getDistanceAttenuation;x.getGeometryRoughness;x.getNormalFromDepth;x.getParallaxCorrectNormal;x.getRoughness;x.getScreenPosition;x.getShIrradianceAt;x.getTextureIndex;x.getViewPosition;x.getShadowMaterial;x.getShadowRenderObjectFunction;x.glsl;x.glslFn;x.grayscale;x.greaterThan;x.greaterThanEqual;x.hash;x.highpModelNormalViewMatrix;x.highpModelViewMatrix;x.hue;x.increment;x.incrementBefore;x.instance;x.instanceIndex;x.instancedArray;x.instancedBufferAttribute;x.instancedDynamicBufferAttribute;x.instancedMesh;x.int;x.inverseSqrt;x.inversesqrt;x.invocationLocalIndex;x.invocationSubgroupIndex;x.ior;x.iridescence;x.iridescenceIOR;x.iridescenceThickness;x.ivec2;x.ivec3;x.ivec4;x.js;x.label;x.length;x.lengthSq;x.lessThan;x.lessThanEqual;x.lightPosition;x.lightShadowMatrix;x.lightTargetDirection;x.lightTargetPosition;x.lightViewPosition;x.lightingContext;x.lights;x.linearDepth;x.linearToneMapping;x.localId;x.globalId;x.log;x.log2;x.logarithmicDepthToViewZ;x.loop;x.luminance;x.mediumpModelViewMatrix;x.mat2;x.mat3;x.mat4;x.matcapUV;x.materialAO;x.materialAlphaTest;x.materialAnisotropy;x.materialAnisotropyVector;x.materialAttenuationColor;x.materialAttenuationDistance;x.materialClearcoat;x.materialClearcoatNormal;x.materialClearcoatRoughness;x.materialColor;x.materialDispersion;x.materialEmissive;x.materialIOR;x.materialIridescence;x.materialIridescenceIOR;x.materialIridescenceThickness;x.materialLightMap;x.materialLineDashOffset;x.materialLineDashSize;x.materialLineGapSize;x.materialLineScale;x.materialLineWidth;x.materialMetalness;x.materialNormal;x.materialOpacity;x.materialPointSize;x.materialReference;x.materialReflectivity;x.materialRefractionRatio;x.materialRotation;x.materialRoughness;x.materialSheen;x.materialSheenRoughness;x.materialShininess;x.materialSpecular;x.materialSpecularColor;x.materialSpecularIntensity;x.materialSpecularStrength;x.materialThickness;x.materialTransmission;x.max;x.maxMipLevel;x.metalness;x.min;x.mix;x.mixElement;x.mod;x.modInt;x.modelDirection;x.modelNormalMatrix;x.modelPosition;x.modelRadius;x.modelScale;x.modelViewMatrix;x.modelViewPosition;x.modelViewProjection;x.modelWorldMatrix;x.modelWorldMatrixInverse;x.morphReference;x.mrt;x.mul;x.mx_aastep;x.mx_cell_noise_float;x.mx_contrast;x.mx_fractal_noise_float;x.mx_fractal_noise_vec2;x.mx_fractal_noise_vec3;x.mx_fractal_noise_vec4;x.mx_hsvtorgb;x.mx_noise_float;x.mx_noise_vec3;x.mx_noise_vec4;x.mx_ramplr;x.mx_ramptb;x.mx_rgbtohsv;x.mx_safepower;x.mx_splitlr;x.mx_splittb;x.mx_srgb_texture_to_lin_rec709;x.mx_transform_uv;x.mx_worley_noise_float;x.mx_worley_noise_vec2;x.mx_worley_noise_vec3;x.namespace;x.negate;x.neutralToneMapping;x.nodeArray;x.nodeImmutable;x.nodeObject;x.nodeObjects;x.nodeProxy;x.normalFlat;x.normalGeometry;x.normalLocal;x.normalMap;x.normalView;x.normalWorld;x.normalize;x.not;x.notEqual;x.numWorkgroups;x.objectDirection;x.objectGroup;x.objectPosition;x.objectRadius;x.objectScale;x.objectViewPosition;x.objectWorldMatrix;x.oneMinus;x.or;x.orthographicDepthToViewZ;x.oscSawtooth;x.oscSine;x.oscSquare;x.oscTriangle;x.output;x.outputStruct;x.overlay;x.overloadingFn;x.parabola;x.parallaxDirection;x.parallaxUV;x.parameter;x.pass;x.passTexture;x.pcurve;x.perspectiveDepthToViewZ;x.pmremTexture;x.pointUV;x.pointWidth;x.positionGeometry;x.positionLocal;x.positionPrevious;x.positionView;x.positionViewDirection;x.positionWorld;x.positionWorldDirection;x.posterize;x.pow;x.pow2;x.pow3;x.pow4;x.premult;x.property;x.radians;x.rand;x.range;x.rangeFog;x.rangeFogFactor;x.reciprocal;x.lightProjectionUV;x.reference;x.referenceBuffer;x.reflect;x.reflectVector;x.reflectView;x.reflector;x.refract;x.refractVector;x.refractView;x.reinhardToneMapping;x.remainder;x.remap;x.remapClamp;x.renderGroup;x.renderOutput;x.rendererReference;x.rotate;x.rotateUV;x.roughness;x.round;x.rtt;x.sRGBTransferEOTF;x.sRGBTransferOETF;x.sampler;x.samplerComparison;x.saturate;x.saturation;x.screen;x.screenCoordinate;x.screenSize;x.screenUV;x.scriptable;x.scriptableValue;x.select;x.setCurrentStack;x.shaderStages;x.shadow;x.pointShadow;x.shadowPositionWorld;x.sharedUniformGroup;x.shapeCircle;x.sheen;x.sheenRoughness;x.shiftLeft;x.shiftRight;x.shininess;x.sign;x.sin;x.sinc;x.skinning;x.smoothstep;x.smoothstepElement;x.specularColor;x.specularF90;x.spherizeUV;x.split;x.spritesheetUV;x.sqrt;x.stack;x.step;x.storage;x.storageBarrier;x.storageObject;x.storageTexture;x.string;x.struct;x.sub;x.subgroupIndex;x.subgroupSize;x.tan;x.tangentGeometry;x.tangentLocal;x.tangentView;x.tangentWorld;x.temp;x.texture;x.texture3D;x.textureBarrier;x.textureBicubic;x.textureCubeUV;x.textureLoad;x.textureSize;x.textureStore;x.thickness;x.time;x.timerDelta;x.timerGlobal;x.timerLocal;x.toneMapping;x.toneMappingExposure;x.toonOutlinePass;x.transformDirection;x.transformNormal;x.transformNormalToView;x.transformedBentNormalView;x.transformedBitangentView;x.transformedBitangentWorld;x.transformedClearcoatNormalView;x.transformedNormalView;x.transformedNormalWorld;x.transformedTangentView;x.transformedTangentWorld;x.transmission;x.transpose;x.triNoise3D;x.triplanarTexture;x.triplanarTextures;x.trunc;x.tslFn;x.uint;x.uniform;x.uniformCubeTexture;x.uniformArray;x.uniformGroup;x.uniformTexture;x.uniforms;x.unpremult;x.userData;x.uv;x.uvec2;x.uvec3;x.uvec4;x.Var;x.varying;x.varyingProperty;x.vec2;x.vec3;const Uoe=x.vec4;x.vectorComponents;x.velocity;x.vertexColor;x.vertexIndex;x.vibrance;x.viewZToLogarithmicDepth;x.viewZToOrthographicDepth;x.viewZToPerspectiveDepth;x.viewport;x.viewportBottomLeft;x.viewportCoordinate;x.viewportDepthTexture;x.viewportLinearDepth;x.viewportMipTexture;x.viewportResolution;x.viewportSafeUV;x.viewportSharedTexture;x.viewportSize;x.viewportTexture;x.viewportTopLeft;x.viewportUV;x.wgsl;x.wgslFn;x.workgroupArray;x.workgroupBarrier;x.workgroupId;x.workingToColorSpace;x.xor;const Ee=L.createContext(null),Doe=({children:t,hideNotice:e=!1,style:r={},className:s="",...i})=>{const n=L.useRef(null),a=L.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=L.useRef(null);o.current===null&&(o.current=pQ());const l=L.useMemo(()=>(f,g,b,v,w=null)=>{if(g===null){try{o.current.removeNode(f)}catch(T){console.warn("Error removing node:",T)}return}try{o.current.registerNode(f,g,b,v,w)}catch(T){console.error("Error registering node:",T,{id:f,parentId:b,metadata:v})}},[]),h=L.useMemo(()=>(f,g,b)=>{try{o.current.updateUniformValue(f,g,b)}catch(v){console.warn("Error updating uniform:",v)}},[]),u=L.useMemo(()=>(f,g)=>{try{o.current.updateNodeMetadata(f,g)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=L.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=L.useRef(!1),p=L.useRef(!1);L.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const g=o.current;return g.initialize({canvas:f}).then(()=>{g.registerNode(a,({childNode:b})=>b||Uoe(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,e||g.showLicenseWarning()}).catch(b=>{console.error("[Shader] Initialization failed:",b),p.current=!1}),()=>{try{g.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(b){console.warn("[Shader] Error during cleanup:",b)}}},[a,e]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof r=="object"?r:{}};return wt.jsx(Ee.Provider,{value:c,children:wt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof r=="object"?r:{}},className:s,...i,children:[wt.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),t]})})};function $oe(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const ML={blendMode:"normal"};try{rh&&rh.props&&Object.entries(rh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(ML[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Goe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${rh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>$oe(t,ML),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(rh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,rh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})};var m_=function(t){function e(n){"@babel/helpers - typeof";return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e(n)}function r(n,a){if(e(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var l=o.call(n,a);if(e(l)!="object")return l;throw TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function s(n){var a=r(n,"string");return e(a)=="symbol"?a:a+""}function i(n,a,o){return(a=s(a))in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o,n}return t.defineProperty=i,t}({}),qa,Om;function It(t,e){let r=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(a=>[a]));let s=e[0].length,i=e[0].map((a,o)=>e.map(l=>l[o])),n=t.map(a=>i.map(o=>{let l=0;if(!Array.isArray(a)){for(let h of o)l+=a*h;return l}for(let h=0;h<a.length;h++)l+=a[h]*(o[h]||0);return l}));return r===1&&(n=n[0]),s===1?n.map(a=>a[0]):n}function pp(t){return bo(t)==="string"}function bo(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function hg(t,{precision:e,unit:r}){return So(t)?"none":_L(t,e)+(r??"")}function So(t){return Number.isNaN(t)||t instanceof Number&&t?.none}function mr(t){return So(t)?0:t}function _L(t,e){if(t===0)return 0;let r=~~t,s=0;r&&e&&(s=~~Math.log10(Math.abs(r))+1);let i=10**(e-s);return Math.floor(t*i+.5)/i}const joe={deg:1,grad:.9,rad:180/Math.PI,turn:360};function NL(t){if(!t)return;t=t.trim();let e=/^([a-z]+)\((.+?)\)$/i,r=/^-?[\d.]+$/,s=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,n=t.match(e);if(n){let a=[];return n[2].replace(i,(o,l)=>{let h=l.match(s),u=l;if(h){let c=h[0],d=u.slice(0,-c.length);c==="%"?(u=new Number(d/100),u.type="<percentage>"):(u=new Number(d*joe[c]),u.type="<angle>",u.unit=c)}else r.test(u)?(u=new Number(u),u.type="<number>"):u==="none"&&(u=new Number(NaN),u.none=!0);o.startsWith("/")&&(u=u instanceof Number?u:new Number(u),u.alpha=!0),typeof u=="object"&&u instanceof Number&&(u.raw=l),a.push(u)}),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:a}}}function AL(t){return t[t.length-1]}function Cd(t,e,r){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*r}function CL(t,e,r){return(r-t)/(e-t)}function VT(t,e,r){return Cd(e[0],e[1],CL(t[0],t[1],r))}function RL(t){return t.map(e=>e.split("|").map(r=>{r=r.trim();let s=r.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(s){let i=new String(s[1]);return i.range=[+s[2],+s[3]],i}return r}))}function EL(t,e,r){return Math.max(Math.min(r,e),t)}function hy(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function gn(t,e){return hy(Math.abs(t)**e,t)}function OT(t,e){return e===0?0:t/e}function PL(t,e,r=0,s=t.length){for(;r<s;){let i=r+s>>1;t[i]<e?r=i+1:s=i}return r}var Woe=Object.freeze({__proto__:null,bisectLeft:PL,clamp:EL,copySign:hy,interpolate:Cd,interpolateInv:CL,isNone:So,isString:pp,last:AL,mapRange:VT,multiplyMatrices:It,parseCoordGrammar:RL,parseFunction:NL,serializeNumber:hg,skipNone:mr,spow:gn,toPrecision:_L,type:bo,zdiv:OT}),Hoe=class{add(e,r,s){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(i){this[i]=this[i]||[],r&&this[i][s?"unshift":"push"](r)},this)}run(e,r){this[e]=this[e]||[],this[e].forEach(function(s){s.call(r&&r.context?r.context:r,r)})}};const Mo=new Hoe;var ei={gamut_mapping:"css",precision:5,deltaE:"76",verbose:((qa=globalThis)==null||(qa=qa.process)==null||(qa=qa.env)==null||(qa=qa.NODE_ENV)==null?void 0:qa.toLowerCase())!=="test",warn:function(t){var e,r;this.verbose&&((e=globalThis)==null||(e=e.console)==null||(r=e.warn)==null||r.call(e,t))}};const fs={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function Bb(t){return Array.isArray(t)?t:fs[t]}function cg(t,e,r,s={}){if(t=Bb(t),e=Bb(e),!t||!e)throw TypeError(`Missing white point to convert ${t?"":"from"}${!t&&!e?"/":""}${e?"":"to"}`);if(t===e)return r;let i={W1:t,W2:e,XYZ:r,options:s};if(Mo.run("chromatic-adaptation-start",i),i.M||(i.W1===fs.D65&&i.W2===fs.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===fs.D50&&i.W2===fs.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Mo.run("chromatic-adaptation-end",i),i.M)return It(i.M,i.XYZ);throw TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const qoe=new Set(["<number>","<percentage>","<angle>"]);function f_(t,e,r,s){return Object.entries(t.coords).map(([n,a],o)=>{let l=e.coordGrammar[o],h=s[o],u=h?.type,c;if(c=h.none?l.find(m=>qoe.has(m)):l.find(m=>m==u),!c){let m=a.name||n;throw TypeError(`${u??h.raw} not allowed for ${m} in ${r}()`)}let d=c.range;u==="<percentage>"&&(d||(d=[0,1]));let p=a.range||a.refRange;return d&&p&&(s[o]=VT(d,p,s[o])),c})}function FL(t,{meta:e}={}){let r={str:String(t)?.trim()};if(Mo.run("parse-start",r),r.color)return r.color;if(r.parsed=NL(r.str),r.parsed){let i=r.parsed.name;if(i==="color"){let n=r.parsed.args.shift(),a=n.startsWith("--")?n.substring(2):`--${n}`,o=[n,a],l=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let c of _e.all){let d=c.getFormat("color");if(d&&(o.includes(d.id)||d.ids?.filter(p=>o.includes(p)).length)){let p=Object.keys(c.coords).map((f,g)=>r.parsed.args[g]||0),m;return d.coordGrammar&&(m=f_(c,d,"color",p)),e&&Object.assign(e,{formatId:"color",types:m}),d.id.startsWith("--")&&!n.startsWith("--")&&ei.warn(`${c.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${d.id}) instead of color(${n}).`),n.startsWith("--")&&!d.id.startsWith("--")&&ei.warn(`${c.name} is a standard space and supported in the CSS spec. Use color(${d.id}) instead of prefixed color(${n}).`),{spaceId:c.id,coords:p,alpha:l}}}let h="",u=n in _e.registry?n:a;if(u in _e.registry){var s;let c=(s=_e.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;c&&(h=`Did you mean color(${c})?`)}throw TypeError(`Cannot parse color(${n}). `+(h||"Missing a plugin?"))}else for(let n of _e.all){let a=n.getFormat(i);if(a&&a.type==="function"){let o=1;(a.lastAlpha||AL(r.parsed.args).alpha)&&(o=r.parsed.args.pop());let l=r.parsed.args,h;return a.coordGrammar&&(h=f_(n,a,i,l)),e&&Object.assign(e,{formatId:a.name,types:h}),{spaceId:n.id,coords:l,alpha:o}}}}else for(let i of _e.all)for(let n in i.formats){let a=i.formats[n];if(a.type!=="custom"||a.test&&!a.test(r.str))continue;let o=a.parse(r.str);if(o)return o.alpha??(o.alpha=1),e&&(e.formatId=n),o}throw TypeError(`Could not parse ${t} as a color. Missing a plugin?`)}function ke(t){if(Array.isArray(t))return t.map(ke);if(!t)throw TypeError("Empty color reference");pp(t)&&(t=FL(t));let e=t.space||t.spaceId;return e instanceof _e||(t.space=_e.get(e)),t.alpha===void 0&&(t.alpha=1),t}const Xoe=75e-6;var _e=(Om=class $i{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?$i.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let r=e.coords??this.base.coords;for(let i in r)"name"in r[i]||(r[i].name=i);this.coords=r;let s=e.white??this.base.white??"D65";for(let i in this.white=Bb(s),this.formats=e.formats??{},this.formats){let n=this.formats[i];n.type||(n.type="function"),n.name||(n.name=i)}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace=e.gamutSpace==="self"?this:$i.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(i,n)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:Yoe(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Mo.run("colorspace-init-end",this)}inGamut(e,{epsilon:r=Xoe}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:r});let s=Object.values(this.coords);return e.every((i,n)=>{let a=s[n];if(a.type!=="angle"&&a.range){if(Number.isNaN(i))return!0;let[o,l]=a.range;return(o===void 0||i>=o-r)&&(l===void 0||i<=l+r)}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=g_(e,this),e;let r;return r=e==="default"?Object.values(this.formats)[0]:this.formats[e],r?(r=g_(r,this),r):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(e,r){if(arguments.length===1){let o=ke(e);[e,r]=[o.space,o.coords]}if(e=$i.get(e),this.equals(e))return r;r=r.map(o=>Number.isNaN(o)?0:o);let s=this.path,i=e.path,n,a;for(let o=0;o<s.length&&s[o].equals(i[o]);o++)n=s[o],a=o;if(!n)throw Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let o=s.length-1;o>a;o--)r=s[o].toBase(r);for(let o=a+1;o<i.length;o++)r=i[o].fromBase(r);return r}from(e,r){if(arguments.length===1){let s=ke(e);[e,r]=[s.space,s.coords]}return e=$i.get(e),e.to(this,r)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let r in this.coords){let s=this.coords[r],i=s.range||s.refRange;e.push(i?.min??0)}return e}static get all(){return[...new Set(Object.values($i.registry))]}static register(e,r){if(arguments.length===1&&(r=arguments[0],e=r.id),r=this.get(r),this.registry[e]&&this.registry[e]!==r)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=r,arguments.length===1&&r.aliases)for(let s of r.aliases)this.register(s,r);return r}static get(e,...r){if(!e||e instanceof $i)return e;if(bo(e)==="string"){let i=$i.registry[e.toLowerCase()];if(!i)throw TypeError(`No color space found with id = "${e}"`);return i}if(r.length)return $i.get(...r);throw TypeError(`${e} is not a valid color space`)}static resolveCoord(e,r){let s=bo(e),i,n;if(s==="string"?e.includes(".")?[i,n]=e.split("."):[i,n]=[,e]:Array.isArray(e)?[i,n]=e:(i=e.space,n=e.coordId),i=$i.get(i),i||(i=r),!i)throw TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(s=bo(n),s==="number"||s==="string"&&n>=0){let l=Object.entries(i.coords)[n];if(l)return{space:i,id:l[0],index:n,...l[1]}}i=$i.get(i);let a=n.toLowerCase(),o=0;for(let l in i.coords){let h=i.coords[l];if(l.toLowerCase()===a||h.name?.toLowerCase()===a)return{space:i,id:l,index:o,...h};o++}throw TypeError(`No "${n}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(", ")}`)}},m_.defineProperty(Om,"registry",{}),m_.defineProperty(Om,"DEFAULT_FORMAT",{type:"functions",name:"color"}),Om);function Yoe(t){let e=[t];for(let r=t;r=r.base;)e.push(r);return e}function g_(t,{coords:e}={}){if(t.coords&&!t.coordGrammar){t.type||(t.type="function"),t.name||(t.name="color"),t.coordGrammar=RL(t.coords);let r=Object.entries(e).map(([s,i],n)=>{let a=t.coordGrammar[n][0],o=i.range||i.refRange,l=a.range,h="";return a=="<percentage>"?(l=[0,100],h="%"):a=="<angle>"&&(h="deg"),{fromRange:o,toRange:l,suffix:h}});t.serializeCoords=(s,i)=>s.map((n,a)=>{let{fromRange:o,toRange:l,suffix:h}=r[a];return o&&l&&(n=VT(o,l,n)),n=hg(n,{precision:i,unit:h}),n})}return t}var $r=new _e({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"]}),Ps=class extends _e{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=$r),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??(e.toBase=r=>{let s=It(e.toXYZ_M,r);return this.white!==this.base.white&&(s=cg(this.white,this.base.white,s)),s}),e.fromBase??(e.fromBase=r=>(r=cg(this.base.white,this.white,r),It(e.fromXYZ_M,r)))),e.referred??(e.referred="display"),super(e)}};function mp(t,e){return t=ke(t),!e||t.space.equals(e)?t.coords.slice():(e=_e.get(e),e.from(t))}function Ys(t,e){t=ke(t);let{space:r,index:s}=_e.resolveCoord(e,t.space);return mp(t,r)[s]}function kT(t,e,r){return t=ke(t),e=_e.get(e),t.coords=e.to(t.space,r),t}kT.returns="color";function Aa(t,e,r){if(t=ke(t),arguments.length===2&&bo(arguments[1])==="object"){let s=arguments[1];for(let i in s)Aa(t,i,s[i])}else{typeof r=="function"&&(r=r(Ys(t,e)));let{space:s,index:i}=_e.resolveCoord(e,t.space),n=mp(t,s);n[i]=r,kT(t,s,n)}return t}Aa.returns="color";var UT=new _e({id:"xyz-d50",name:"XYZ D50",white:"D50",base:$r,fromBase:t=>cg($r.white,"D50",t),toBase:t=>cg("D50",$r.white,t)});const Zoe=216/24389,y_=24/116,km=24389/27;let h0=fs.D50;var Zs=new _e({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:h0,base:UT,fromBase(t){let e=t.map((s,i)=>s/h0[i]),r=e.map(s=>s>Zoe?Math.cbrt(s):(km*s+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>y_?e[0]**3:(116*e[0]-16)/km,t[0]>8?((t[0]+16)/116)**3:t[0]/km,e[2]>y_?e[2]**3:(116*e[2]-16)/km].map((s,i)=>s*h0[i])},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Un(t){return(t%360+360)%360}function Joe(t,e){if(t==="raw")return e;let[r,s]=e.map(Un),i=s-r;return t==="increasing"?i<0&&(s+=360):t==="decreasing"?i>0&&(r+=360):t==="longer"?-180<i&&i<180&&(i>0?r+=360:s+=360):t==="shorter"&&(i>180?r+=360:i<-180&&(s+=360)),[r,s]}var Rd=new _e({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:Zs,fromBase(t){let[e,r,s]=t,i,n=.02;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t;return r<0&&(r=0),isNaN(s)&&(s=0),[e,r*Math.cos(s*Math.PI/180),r*Math.sin(s*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const x_=25**7,dg=Math.PI,b_=180/dg,Mu=dg/180;function v_(t){let e=t*t;return e*e*e*t}function LL(t,e,{kL:r=1,kC:s=1,kH:i=1}={}){[t,e]=ke([t,e]);let[n,a,o]=Zs.from(t),l=Rd.from(Zs,[n,a,o])[1],[h,u,c]=Zs.from(e),d=Rd.from(Zs,[h,u,c])[1];l<0&&(l=0),d<0&&(d=0);let p=(l+d)/2,m=v_(p),f=.5*(1-Math.sqrt(m/(m+x_))),g=(1+f)*a,b=(1+f)*u,v=Math.sqrt(g**2+o**2),w=Math.sqrt(b**2+c**2),T=g===0&&o===0?0:Math.atan2(o,g),N=b===0&&c===0?0:Math.atan2(c,b);T<0&&(T+=2*dg),N<0&&(N+=2*dg),T*=b_,N*=b_;let S=h-n,_=w-v,A=N-T,D=T+N,K=Math.abs(A),J;v*w===0?J=0:K<=180?J=A:A>180?J=A-360:A<-180?J=A+360:ei.warn("the unthinkable has happened");let re=2*Math.sqrt(w*v)*Math.sin(J*Mu/2),te=(n+h)/2,oe=(v+w)/2,ae=v_(oe),ge;ge=v*w===0?D:K<=180?D/2:D<360?(D+360)/2:(D-360)/2;let fe=(te-50)**2,ve=1+.015*fe/Math.sqrt(20+fe),me=1+.045*oe,he=1;he-=.17*Math.cos((ge-30)*Mu),he+=.24*Math.cos(2*ge*Mu),he+=.32*Math.cos((3*ge+6)*Mu),he-=.2*Math.cos((4*ge-63)*Mu);let Te=1+.015*oe*he,Ge=30*Math.exp(-1*((ge-275)/25)**2),He=2*Math.sqrt(ae/(ae+x_)),ft=-1*Math.sin(2*Ge*Mu)*He,ht=(S/(r*ve))**2;return ht+=(_/(s*me))**2,ht+=(re/(i*Te))**2,ht+=ft*(_/(s*me))*(re/(i*Te)),Math.sqrt(ht)}const Qoe=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],Koe=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],ele=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],tle=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var Dh=new _e({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:$r,fromBase(t){let e=It(Qoe,t),r=e.map(s=>Math.cbrt(s));return It(ele,r)},toBase(t){let e=It(tle,t),r=e.map(s=>s**3);return It(Koe,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Vb(t,e){[t,e]=ke([t,e]);let[r,s,i]=Dh.from(t),[n,a,o]=Dh.from(e),l=r-n,h=s-a,u=i-o;return Math.sqrt(l**2+h**2+u**2)}const rle=75e-6;function bl(t,e,{epsilon:r=rle}={}){t=ke(t),e||(e=t.space),e=_e.get(e);let s=t.coords;return e!==t.space&&(s=e.from(t)),e.inGamut(s,{epsilon:r})}function $h(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}function IL(t,e,r="lab"){r=_e.get(r);let s=r.from(t),i=r.from(e);return Math.sqrt(s.reduce((n,a,o)=>{let l=i[o];return isNaN(a)||isNaN(l)?n:n+(l-a)**2},0))}function sle(t,e){return IL(t,e,"lab")}const ile=Math.PI,T_=ile/180;function nle(t,e,{l:r=2,c:s=1}={}){[t,e]=ke([t,e]);let[i,n,a]=Zs.from(t),[,o,l]=Rd.from(Zs,[i,n,a]),[h,u,c]=Zs.from(e),d=Rd.from(Zs,[h,u,c])[1];o<0&&(o=0),d<0&&(d=0);let p=i-h,m=o-d,f=n-u,g=a-c,b=f**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let w=.0638*o/(1+.0131*o)+.638,T;Number.isNaN(l)&&(l=0),T=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*T_)):.36+Math.abs(.4*Math.cos((l+35)*T_));let N=o**4,S=Math.sqrt(N/(N+1900)),_=w*(S*T+1-S),A=(p/(r*v))**2;return A+=(m/(s*w))**2,A+=b/_**2,Math.sqrt(A)}const w_=203;var DT=new _e({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:$r,fromBase(t){return t.map(e=>Math.max(e*w_,0))},toBase(t){return t.map(e=>Math.max(e/w_,0))}});const Um=1.15,Dm=.66,S_=2610/2**14,ale=2**14/2610,M_=3424/2**12,__=2413/2**7,N_=2392/2**7,ole=1.7*2523/2**5,A_=2**5/(1.7*2523),$m=-.56,c0=16295499532821565e-27,lle=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],ule=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],hle=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],cle=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var zL=new _e({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:DT,fromBase(t){let[e,r,s]=t,i=Um*e-(Um-1)*s,n=Dm*r-(Dm-1)*e,a=It(lle,[i,n,s]),o=a.map(function(d){let p=M_+__*(d/1e4)**S_,m=1+N_*(d/1e4)**S_;return(p/m)**ole}),[l,h,u]=It(hle,o);return[(1+$m)*l/(1+$m*l)-c0,h,u]},toBase(t){let[e,r,s]=t,i=(e+c0)/(1+$m-$m*(e+c0)),n=It(cle,[i,r,s]),a=n.map(function(d){let p=M_-d**A_,m=N_*d**A_-__;return 1e4*(p/m)**ale}),[o,l,h]=It(ule,a),u=(o+(Um-1)*h)/Um,c=(l+(Dm-1)*u)/Dm;return[u,c,h]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),Ob=new _e({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:zL,fromBase(t){let[e,r,s]=t,i,n=2e-4;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]}});function dle(t,e){[t,e]=ke([t,e]);let[r,s,i]=Ob.from(t),[n,a,o]=Ob.from(e),l=r-n,h=s-a;Number.isNaN(i)&&Number.isNaN(o)?(i=0,o=0):Number.isNaN(i)?i=o:Number.isNaN(o)&&(o=i);let u=i-o,c=2*Math.sqrt(s*a)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(l**2+h**2+c**2)}const BL=3424/4096,VL=2413/128,OL=2392/128,C_=2610/16384,ple=2523/32,mle=16384/2610,R_=32/2523,fle=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],gle=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],yle=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],xle=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var kb=new _e({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:DT,fromBase(t){let e=It(fle,t);return ble(e)},toBase(t){let e=vle(t);return It(xle,e)}});function ble(t){let e=t.map(function(r){let s=BL+VL*(r/1e4)**C_,i=1+OL*(r/1e4)**C_;return(s/i)**ple});return It(gle,e)}function vle(t){return It(yle,t).map(function(s){let i=Math.max(s**R_-BL,0),n=VL-OL*s**R_;return 1e4*(i/n)**mle})}function Tle(t,e){[t,e]=ke([t,e]);let[r,s,i]=kb.from(t),[n,a,o]=kb.from(e);return 720*Math.sqrt((r-n)**2+.25*(s-a)**2+(i-o)**2)}const wle=fs.D65,kL=.42,E_=1/kL,d0=2*Math.PI,UL=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Sle=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Mle=[[460,451,288],[460,-891,-261],[460,-220,-6300]],_le={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},il={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Nle=180/Math.PI,P_=Math.PI/180;function DL(t,e){return t.map(s=>{let i=gn(e*Math.abs(s)*.01,kL);return 400*hy(i,s)/(i+27.13)})}function Ale(t,e){let r=100/e*27.13**E_;return t.map(s=>{let i=Math.abs(s);return hy(r*gn(i/(400-i),E_),s)})}function Cle(t){let e=Un(t);e<=il.h[0]&&(e+=360);let r=PL(il.h,e)-1,[s,i]=il.h.slice(r,r+2),[n,a]=il.e.slice(r,r+2),o=il.H[r],l=(e-s)/n;return o+100*l/(l+(i-e)/a)}function Rle(t){let e=(t%400+400)%400,r=Math.floor(.01*e);e%=100;let[s,i]=il.h.slice(r,r+2),[n,a]=il.e.slice(r,r+2);return Un((e*(a*s-n*i)-100*s*a)/(e*(a-n)-100*a))}function $L(t,e,r,s,i){let n={};n.discounting=i,n.refWhite=t,n.surround=s;let a=t.map(f=>f*100);n.la=e,n.yb=r;let o=a[1],l=It(UL,a);s=_le[n.surround];let h=s[0];n.c=s[1],n.nc=s[2];let u=1/(5*n.la+1),c=u**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;let d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=l.map(f=>Cd(1,o/f,d)),n.dRgbInv=n.dRgb.map(f=>1/f);let p=l.map((f,g)=>f*n.dRgb[g]),m=DL(p,n.fl);return n.aW=n.nbb*(2*m[0]+m[1]+.05*m[2]),n}const F_=$L(wle,64/Math.PI*.2,20,"average",!1);function Ub(t,e){if(!(t.J!==void 0^t.Q!==void 0))throw Error("Conversion requires one and only one: 'J' or 'Q'");if(!(t.C!==void 0^t.M!==void 0^t.s!==void 0))throw Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(t.h!==void 0^t.H!==void 0))throw Error("Conversion requires one and only one: 'h' or 'H'");if(t.J===0||t.Q===0)return[0,0,0];let r=0;r=t.h===void 0?Rle(t.H)*P_:Un(t.h)*P_;let s=Math.cos(r),i=Math.sin(r),n=0;t.J===void 0?t.Q!==void 0&&(n=.25*e.c*t.Q/((e.aW+4)*e.flRoot)):n=gn(t.J,1/2)*.1;let a=0;t.C===void 0?t.M===void 0?t.s!==void 0&&(a=4e-4*t.s**2*(e.aW+4)/e.c):a=t.M/e.flRoot/n:a=t.C/n;let o=gn(a*(1.64-.29**e.n)**-.73,10/9),l=.25*(Math.cos(r+2)+3.8),h=e.aW*gn(n,2/e.c/e.z),u=5e4/13*e.nc*e.ncb*l,c=h/e.nbb,d=23*(c+.305)*OT(o,23*u+o*(11*s+108*i)),p=d*s,m=d*i,f=Ale(It(Mle,[c,p,m]).map(g=>g*1/1403),e.fl);return It(Sle,f.map((g,b)=>g*e.dRgbInv[b])).map(g=>g/100)}function GL(t,e){let r=t.map(w=>w*100),s=DL(It(UL,r).map((w,T)=>w*e.dRgb[T]),e.fl),i=s[0]+(-12*s[1]+s[2])/11,n=(s[0]+s[1]-2*s[2])/9,a=(Math.atan2(n,i)%d0+d0)%d0,o=.25*(Math.cos(a+2)+3.8),l=5e4/13*e.nc*e.ncb*OT(o*Math.sqrt(i**2+n**2),s[0]+s[1]+1.05*s[2]+.305),h=gn(l,.9)*(1.64-.29**e.n)**.73,u=e.nbb*(2*s[0]+s[1]+.05*s[2]),c=gn(u/e.aW,.5*e.c*e.z),d=100*gn(c,2),p=4/e.c*c*(e.aW+4)*e.flRoot,m=h*c,f=m*e.flRoot,g=Un(a*Nle),b=Cle(g),v=50*gn(e.c*h/(e.aW+4),1/2);return{J:d,C:m,h:g,s:v,Q:p,M:f,H:b}}var Ele=new _e({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:$r,fromBase(t){let e=GL(t,F_);return[e.J,e.M,e.h]},toBase(t){return Ub({J:t[0],M:t[1],h:t[2]},F_)}});const Ple=fs.D65,Fle=216/24389,jL=24389/27;function Lle(t){return 116*(t>Fle?Math.cbrt(t):(jL*t+16)/116)-16}function Db(t){return t>8?((t+16)/116)**3:t/jL}function Ile(t,e){let[r,s,i]=t,n=[],a=0;if(i===0)return[0,0,0];let o=Db(i);a=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let l=2e-12,h=15,u=0,c=1/0;for(;u<=h;){n=Ub({J:a,C:s,h:r},e);let d=Math.abs(n[1]-o);if(d<c){if(d<=l)return n;c=d}a-=(n[1]-o)*a/(2*n[1]),u+=1}return Ub({J:a,C:s,h:r},e)}function zle(t,e){let r=Lle(t[1]);if(r===0)return[0,0,0];let s=GL(t,$T);return[Un(s.h),s.C,r]}const $T=$L(Ple,200/Math.PI*Db(50),Db(50)*100,"average",!1);var Ed=new _e({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:$r,fromBase(t){return zle(t)},toBase(t){return Ile(t,$T)},formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Ble=Math.PI/180,L_=[1,.007,.0228];function I_(t){t[1]<0&&(t=Ed.fromBase(Ed.toBase(t)));let e=Math.log(Math.max(1+L_[2]*t[1]*$T.flRoot,1))/L_[2],r=t[0]*Ble,s=e*Math.cos(r),i=e*Math.sin(r);return[t[2],s,i]}function Vle(t,e){[t,e]=ke([t,e]);let[r,s,i]=I_(Ed.from(t)),[n,a,o]=I_(Ed.from(e));return Math.sqrt((r-n)**2+(s-a)**2+(i-o)**2)}var Gh={deltaE76:sle,deltaECMC:nle,deltaE2000:LL,deltaEJz:dle,deltaEITP:Tle,deltaEOK:Vb,deltaEHCT:Vle};function Ole(t){let e=t?Math.floor(Math.log10(Math.abs(t))):0;return Math.max(parseFloat(`1e${e-2}`),1e-6)}const z_={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 _o(t,{method:e=ei.gamut_mapping,space:r=void 0,deltaEMethod:s="",jnd:i=2,blackWhiteClamp:n={}}={}){if(t=ke(t),pp(arguments[1])?r=arguments[1]:r||(r=t.space),r=_e.get(r),bl(t,r,{epsilon:0}))return t;let a;if(e==="css")a=kle(t,{space:r});else{if(e!=="clip"&&!bl(t,r)){Object.prototype.hasOwnProperty.call(z_,e)&&({method:e,jnd:i,deltaEMethod:s,blackWhiteClamp:n}=z_[e]);let o=LL;if(s!==""){for(let h in Gh)if("deltae"+s.toLowerCase()===h.toLowerCase()){o=Gh[h];break}}let l=_o(Lt(t,r),{method:"clip",space:r});if(o(t,l)>i){if(Object.keys(n).length===3){let v=_e.resolveCoord(n.channel),w=Ys(Lt(t,v.space),v.id);if(So(w)&&(w=0),w>=n.max)return Lt({space:"xyz-d65",coords:fs.D65},t.space);if(w<=n.min)return Lt({space:"xyz-d65",coords:[0,0,0]},t.space)}let h=_e.resolveCoord(e),u=h.space,c=h.id,d=Lt(t,u);d.coords.forEach((v,w)=>{So(v)&&(d.coords[w]=0)});let p=h.range||h.refRange,m=p[0],f=Ole(i),g=m,b=Ys(d,c);for(;b-g>f;){let v=$h(d);v=_o(v,{space:r,method:"clip"}),o(d,v)-i<f?g=Ys(d,c):b=Ys(d,c),Aa(d,c,(g+b)/2)}a=Lt(d,r)}else a=l}else a=Lt(t,r);if(e==="clip"||!bl(a,r,{epsilon:0})){let o=Object.values(r.coords).map(l=>l.range||[]);a.coords=a.coords.map((l,h)=>{let[u,c]=o[h];return u!==void 0&&(l=Math.max(u,l)),c!==void 0&&(l=Math.min(l,c)),l})}}return r!==t.space&&(a=Lt(a,t.space)),t.coords=a.coords,t}_o.returns="color";const B_={WHITE:{space:Dh,coords:[1,0,0]},BLACK:{space:Dh,coords:[0,0,0]}};function kle(t,{space:e}={}){let r=.02,s=1e-4;t=ke(t),e||(e=t.space),e=_e.get(e);let i=_e.get("oklch");if(e.isUnbounded)return Lt(t,e);let n=Lt(t,i),a=n.coords[0];if(a>=1){let m=Lt(B_.WHITE,e);return m.alpha=t.alpha,Lt(m,e)}if(a<=0){let m=Lt(B_.BLACK,e);return m.alpha=t.alpha,Lt(m,e)}if(bl(n,e,{epsilon:0}))return Lt(n,e);function o(m){let f=Lt(m,e),g=Object.values(e.coords);return f.coords=f.coords.map((b,v)=>{if("range"in g[v]){let[w,T]=g[v].range;return EL(w,b,T)}return b}),f}let l=0,h=n.coords[1],u=!0,c=$h(n),d=o(c),p=Vb(d,c);if(p<r)return d;for(;h-l>s;){let m=(l+h)/2;if(c.coords[1]=m,u&&bl(c,e,{epsilon:0}))l=m;else if(d=o(c),p=Vb(d,c),p<r){if(r-p<s)break;u=!1,l=m}else h=m}return d}function Lt(t,e,{inGamut:r}={}){t=ke(t),e=_e.get(e);let s=e.from(t),i={space:e,coords:s,alpha:t.alpha};return r&&(i=_o(i,r===!0?void 0:r)),i}Lt.returns="color";function ad(t,{precision:e=ei.precision,format:r="default",inGamut:s=!0,...i}={}){let n;t=ke(t);let a=r;r=t.space.getFormat(r)??t.space.getFormat("default")??_e.DEFAULT_FORMAT;let o=t.coords.slice();if(s||(s=r.toGamut),s&&!bl(t)&&(o=_o($h(t),s===!0?void 0:s).coords),r.type==="custom")if(i.precision=e,r.serialize)n=r.serialize(o,t.alpha,i);else throw TypeError(`format ${a} can only be used to parse colors, not for serialization`);else{let l=r.name||"color";r.serializeCoords?o=r.serializeCoords(o,e):e!==null&&(o=o.map(d=>hg(d,{precision:e})));let h=[...o];if(l==="color"){let d=r.id||r.ids?.[0]||t.space.id;h.unshift(d)}let u=t.alpha;e!==null&&(u=hg(u,{precision:e}));let c=t.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${u}`;n=`${l}(${h.join(r.commas?", ":" ")}${c})`}return n}const Ule=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],Dle=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var cy=new Ps({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:Ule,fromXYZ_M:Dle});const Gm=1.09929682680944,V_=.018053968510807;var WL=new Ps({id:"rec2020",name:"REC.2020",base:cy,toBase(t){return t.map(function(e){return e<V_*4.5?e/4.5:((e+Gm-1)/Gm)**(1/.45)})},fromBase(t){return t.map(function(e){return e>=V_?Gm*e**.45-(Gm-1):4.5*e})}});const $le=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],Gle=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var HL=new Ps({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:$le,fromXYZ_M:Gle});const jle=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],Nr=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var qL=new Ps({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:jle,fromXYZ_M:Nr}),O_={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 k_=[,,,].fill("<percentage> | <number>[0, 255]"),U_=[,,,].fill("<number>[0, 255]");var jh=new Ps({id:"srgb",name:"sRGB",base:qL,fromBase:t=>t.map(e=>{let r=e<0?-1:1,s=e*r;return s>.0031308?r*(1.055*s**(1/2.4)-.055):12.92*e}),toBase:t=>t.map(e=>{let r=e<0?-1:1,s=e*r;return s<=.04045?e/12.92:r*((s+.055)/1.055)**2.4}),formats:{rgb:{coords:k_},rgb_number:{name:"rgb",commas:!0,coords:U_,noAlpha:!0},color:{},rgba:{coords:k_,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:U_},hex:{type:"custom",toGamut:!0,test:t=>/^#([a-f0-9]{3,4}){1,2}$/i.test(t),parse(t){t.length<=5&&(t=t.replace(/[a-f0-9]/gi,"$&$&"));let e=[];return t.replace(/[a-f0-9]{2}/gi,r=>{e.push(parseInt(r,16)/255)}),{spaceId:"srgb",coords:e.slice(0,3),alpha:e.slice(3)[0]}},serialize:(t,e,{collapse:r=!0}={})=>{e<1&&t.push(e),t=t.map(n=>Math.round(n*255));let s=r&&t.every(n=>n%17==0);return"#"+t.map(n=>s?(n/17).toString(16):n.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:t=>/^[a-z]+$/i.test(t),parse(t){t=t.toLowerCase();let e={spaceId:"srgb",coords:null,alpha:1};if(t==="transparent"?(e.coords=O_.black,e.alpha=0):e.coords=O_[t],e.coords)return e}}}}),XL=new Ps({id:"p3",cssId:"display-p3",name:"P3",base:HL,fromBase:jh.fromBase,toBase:jh.toBase});ei.display_space=jh;let Wle;if(typeof CSS<"u"&&CSS.supports)for(let t of[Zs,WL,XL]){let e=t.getMinCoords(),r={space:t,coords:e,alpha:1},s=ad(r);if(CSS.supports("color",s)){ei.display_space=t;break}}function Hle(t,{space:e=ei.display_space,...r}={}){let s=ad(t,r);if(typeof CSS>"u"||CSS.supports("color",s)||!ei.display_space)s=new String(s),s.color=t;else{let i=t;if((t.coords.some(So)||So(t.alpha))&&!(Wle??(Wle=CSS.supports("color","hsl(none 50% 50%)")))&&(i=$h(t),i.coords=i.coords.map(mr),i.alpha=mr(i.alpha),s=ad(i,r),CSS.supports("color",s)))return s=new String(s),s.color=i,s;i=Lt(i,e),s=new String(ad(i,r)),s.color=i}return s}function qle(t,e){return t=ke(t),e=ke(e),t.space===e.space&&t.alpha===e.alpha&&t.coords.every((r,s)=>r===e.coords[s])}function No(t){return Ys(t,[$r,"y"])}function YL(t,e){Aa(t,[$r,"y"],e)}function Xle(t){Object.defineProperty(t.prototype,"luminance",{get(){return No(this)},set(e){YL(this,e)}})}var Yle=Object.freeze({__proto__:null,getLuminance:No,register:Xle,setLuminance:YL});function Zle(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);return s>r&&([r,s]=[s,r]),(r+.05)/(s+.05)}const Jle=.56,Qle=.57,Kle=.62,eue=.65,D_=.022,tue=1.414,rue=.1,sue=5e-4,iue=1.14,$_=.027,nue=1.14;function G_(t){return t>=D_?t:t+(D_-t)**tue}function _u(t){let e=t<0?-1:1,r=Math.abs(t);return e*r**2.4}function aue(t,e){e=ke(e),t=ke(t);let r,s,i,n,a,o;e=Lt(e,"srgb"),[n,a,o]=e.coords;let l=_u(n)*.2126729+_u(a)*.7151522+_u(o)*.072175;t=Lt(t,"srgb"),[n,a,o]=t.coords;let h=_u(n)*.2126729+_u(a)*.7151522+_u(o)*.072175,u=G_(l),c=G_(h),d=c>u;return Math.abs(c-u)<sue?s=0:d?(r=c**Jle-u**Qle,s=r*iue):(r=c**eue-u**Kle,s=r*nue),i=Math.abs(s)<rue?0:s>0?s-$_:s+$_,i*100}function oue(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);s>r&&([r,s]=[s,r]);let i=r+s;return i===0?0:(r-s)/i}const lue=5e4;function uue(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);return s>r&&([r,s]=[s,r]),s===0?lue:(r-s)/s}function hue(t,e){t=ke(t),e=ke(e);let r=Ys(t,[Zs,"l"]),s=Ys(e,[Zs,"l"]);return Math.abs(r-s)}const cue=216/24389,j_=24/116,jm=24389/27;let p0=fs.D65;var $b=new _e({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:p0,base:$r,fromBase(t){let e=t.map((s,i)=>s/p0[i]),r=e.map(s=>s>cue?Math.cbrt(s):(jm*s+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>j_?e[0]**3:(116*e[0]-16)/jm,t[0]>8?((t[0]+16)/116)**3:t[0]/jm,e[2]>j_?e[2]**3:(116*e[2]-16)/jm].map((s,i)=>s*p0[i])},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const due=5**.5*.5+.5;function pue(t,e){t=ke(t),e=ke(e);let r=Ys(t,[$b,"l"]),s=Ys(e,[$b,"l"]),i=Math.abs(r**1.618033988749895-s**1.618033988749895),n=i**(1/due)*Math.SQRT2-40;return n<7.5?0:n}var vf=Object.freeze({__proto__:null,contrastAPCA:aue,contrastDeltaPhi:pue,contrastLstar:hue,contrastMichelson:oue,contrastWCAG21:Zle,contrastWeber:uue});function mue(t,e,r={}){pp(r)&&(r={algorithm:r});let{algorithm:s,...i}=r;if(!s){let n=Object.keys(vf).map(a=>a.replace(/^contrast/,"")).join(", ");throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${n}`)}for(let n in t=ke(t),e=ke(e),vf)if("contrast"+s.toLowerCase()===n.toLowerCase())return vf[n](t,e,i);throw TypeError(`Unknown contrast algorithm: ${s}`)}function dy(t){let[e,r,s]=mp(t,$r),i=e+15*r+3*s;return[4*e/i,9*r/i]}function ZL(t){let[e,r,s]=mp(t,$r),i=e+r+s;return[e/i,r/i]}function fue(t){Object.defineProperty(t.prototype,"uv",{get(){return dy(this)}}),Object.defineProperty(t.prototype,"xy",{get(){return ZL(this)}})}var gue=Object.freeze({__proto__:null,register:fue,uv:dy,xy:ZL});function jc(t,e,r={}){pp(r)&&(r={method:r});let{method:s=ei.deltaE,...i}=r;for(let n in Gh)if("deltae"+s.toLowerCase()===n.toLowerCase())return Gh[n](t,e,i);throw TypeError(`Unknown deltaE method: ${s}`)}function yue(t,e=.25){let r=_e.get("oklch","lch");return Aa(t,[r,"l"],i=>i*(1+e))}function xue(t,e=.25){let r=_e.get("oklch","lch");return Aa(t,[r,"l"],i=>i*(1-e))}var bue=Object.freeze({__proto__:null,darken:xue,lighten:yue});function JL(t,e,r=.5,s={}){return[t,e]=[ke(t),ke(e)],bo(r)==="object"&&([r,s]=[.5,r]),fp(t,e,s)(r)}function QL(t,e,r={}){let s;GT(t)&&([s,r]=[t,e],[t,e]=s.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:n,steps:a=2,maxSteps:o=1e3,...l}=r;s||([t,e]=[ke(t),ke(e)],s=fp(t,e,l));let h=jc(t,e),u=i>0?Math.max(a,Math.ceil(h/i)+1):a,c=[];if(o!==void 0&&(u=Math.min(u,o)),u===1)c=[{p:.5,color:s(.5)}];else{let d=1/(u-1);c=Array.from({length:u},(p,m)=>{let f=m*d;return{p:f,color:s(f)}})}if(i>0){let d=c.reduce((p,m,f)=>{if(f===0)return 0;let g=jc(m.color,c[f-1].color,n);return Math.max(p,g)},0);for(;d>i;){d=0;for(let p=1;p<c.length&&c.length<o;p++){let m=c[p-1],f=c[p],g=(f.p+m.p)/2,b=s(g);d=Math.max(d,jc(b,m.color),jc(b,f.color)),c.splice(p,0,{p:g,color:s(g)}),p++}}}return c=c.map(d=>d.color),c}function fp(t,e,r={}){if(GT(t)){let[l,h]=[t,e];return fp(...l.rangeArgs.colors,{...l.rangeArgs.options,...h})}let{space:s,outputSpace:i,progression:n,premultiplied:a}=r;t=ke(t),e=ke(e),t=$h(t),e=$h(e);let o={colors:[t,e],options:r};if(s=s?_e.get(s):_e.registry[ei.interpolationSpace]||t.space,i=i?_e.get(i):s,t=Lt(t,s),e=Lt(e,s),t=_o(t),e=_o(e),s.coords.h&&s.coords.h.type==="angle"){let l=r.hue=r.hue||"shorter",h=[s,"h"],[u,c]=[Ys(t,h),Ys(e,h)];isNaN(u)&&!isNaN(c)?u=c:isNaN(c)&&!isNaN(u)&&(c=u),[u,c]=Joe(l,[u,c]),Aa(t,h,u),Aa(e,h,c)}return a&&(t.coords=t.coords.map(l=>l*t.alpha),e.coords=e.coords.map(l=>l*e.alpha)),Object.assign(l=>{l=n?n(l):l;let h=t.coords.map((d,p)=>{let m=e.coords[p];return Cd(d,m,l)}),u=Cd(t.alpha,e.alpha,l),c={space:s,coords:h,alpha:u};return a&&(c.coords=c.coords.map(d=>d/u)),i!==s&&(c=Lt(c,i)),c},{rangeArgs:o})}function GT(t){return bo(t)==="function"&&!!t.rangeArgs}ei.interpolationSpace="lab";function vue(t){t.defineFunction("mix",JL,{returns:"color"}),t.defineFunction("range",fp,{returns:"function<color>"}),t.defineFunction("steps",QL,{returns:"array<color>"})}var Tue=Object.freeze({__proto__:null,isRange:GT,mix:JL,range:fp,register:vue,steps:QL}),KL=new _e({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:jh,fromBase:t=>{let e=Math.max(...t),r=Math.min(...t),[s,i,n]=t,[a,o,l]=[NaN,0,(r+e)/2],h=e-r;if(h!==0){switch(o=l===0||l===1?0:(e-l)/Math.min(l,1-l),e){case s:a=(i-n)/h+(i<n?6:0);break;case i:a=(n-s)/h+2;break;case n:a=(s-i)/h+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,o*100,l*100]},toBase:t=>{let[e,r,s]=t;e%=360,e<0&&(e+=360),r/=100,s/=100;function i(n){let a=(n+e/30)%12,o=r*Math.min(s,1-s);return s-o*Math.max(-1,Math.min(a-3,9-a,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}}}),eI=new _e({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:KL,fromBase(t){let[e,r,s]=t;r/=100,s/=100;let i=s+r*Math.min(s,1-s);return[e,i===0?0:200*(1-s/i),100*i]},toBase(t){let[e,r,s]=t;r/=100,s/=100;let i=s*(1-r/2);return[e,i===0||i===1?0:(s-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),wue=new _e({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:eI,fromBase(t){let[e,r,s]=t;return[e,s*(100-r)/100,100-s]},toBase(t){let[e,r,s]=t;r/=100,s/=100;let i=r+s;if(i>=1){let o=r/i;return[e,0,o*100]}let n=1-s,a=n===0?0:1-r/n;return[e,a*100,n*100]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Sue=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],Mue=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var tI=new Ps({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:Sue,fromXYZ_M:Mue}),_ue=new Ps({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:tI,toBase:t=>t.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:t=>t.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const Nue=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],Aue=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var rI=new Ps({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:UT,toXYZ_M:Nue,fromXYZ_M:Aue});const Cue=1/512,Rue=16/512;var Eue=new Ps({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:rI,toBase(t){return t.map(e=>e<Rue?e/16:e**1.8)},fromBase(t){return t.map(e=>e>=Cue?e**(1/1.8):16*e)}}),Pue=new _e({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:Dh,fromBase(t){let[e,r,s]=t,i,n=2e-4;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t,i,n;return isNaN(s)?(i=0,n=0):(i=r*Math.cos(s*Math.PI/180),n=r*Math.sin(s*Math.PI/180)),[e,i,n]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let sI=fs.D65;const Fue=216/24389,W_=24389/27,[H_,q_]=dy({space:$r,coords:sI});var iI=new _e({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:sI,base:$r,fromBase(t){let e=[mr(t[0]),mr(t[1]),mr(t[2])],r=e[1],[s,i]=dy({space:$r,coords:e});if(!Number.isFinite(s)||!Number.isFinite(i))return[0,0,0];let n=r<=Fue?W_*r:116*Math.cbrt(r)-16;return[n,13*n*(s-H_),13*n*(i-q_)]},toBase(t){let[e,r,s]=t;if(e===0||So(e))return[0,0,0];r=mr(r),s=mr(s);let i=r/(13*e)+H_,n=s/(13*e)+q_,a=e<=8?e/W_:((e+16)/116)**3;return[a*(9*i/(4*n)),a,a*((12-3*i-20*n)/(4*n))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),jT=new _e({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:iI,fromBase(t){let[e,r,s]=t,i,n=.02;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t;return r<0&&(r=0),isNaN(s)&&(s=0),[e,r*Math.cos(s*Math.PI/180),r*Math.sin(s*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Lue=216/24389,Iue=24389/27,X_=Nr[0][0],Y_=Nr[0][1],m0=Nr[0][2],Z_=Nr[1][0],J_=Nr[1][1],f0=Nr[1][2],Q_=Nr[2][0],K_=Nr[2][1],g0=Nr[2][2];function Nu(t,e,r){let s=e/(Math.sin(r)-t*Math.cos(r));return s<0?1/0:s}function pg(t){let e=(t+16)**3/1560896,r=e>Lue?e:t/Iue,s=r*(284517*X_-94839*m0),i=r*(838422*m0+769860*Y_+731718*X_),n=r*(632260*m0-126452*Y_),a=r*(284517*Z_-94839*f0),o=r*(838422*f0+769860*J_+731718*Z_),l=r*(632260*f0-126452*J_),h=r*(284517*Q_-94839*g0),u=r*(838422*g0+769860*K_+731718*Q_),c=r*(632260*g0-126452*K_);return{r0s:s/n,r0i:i*t/n,r1s:s/(n+126452),r1i:(i-769860)*t/(n+126452),g0s:a/l,g0i:o*t/l,g1s:a/(l+126452),g1i:(o-769860)*t/(l+126452),b0s:h/c,b0i:u*t/c,b1s:h/(c+126452),b1i:(u-769860)*t/(c+126452)}}function eN(t,e){let r=e/360*Math.PI*2,s=Nu(t.r0s,t.r0i,r),i=Nu(t.r1s,t.r1i,r),n=Nu(t.g0s,t.g0i,r),a=Nu(t.g1s,t.g1i,r),o=Nu(t.b0s,t.b0i,r),l=Nu(t.b1s,t.b1i,r);return Math.min(s,i,n,a,o,l)}var zue=new _e({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:jT,gamutSpace:jh,fromBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(e>99.9999999)i=0,e=100;else if(e<1e-8)i=0,e=0;else{let n=pg(e),a=eN(n,s);i=r/a*100}return[s,i,e]},toBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=pg(s);i=eN(n,e)/100*r}return[s,i,e]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});Nr[0][0],Nr[0][1],Nr[0][2],Nr[1][0],Nr[1][1],Nr[1][2],Nr[2][0],Nr[2][1],Nr[2][2];function Au(t,e){return Math.abs(e)/Math.sqrt(t**2+1)}function tN(t){let e=Au(t.r0s,t.r0i),r=Au(t.r1s,t.r1i),s=Au(t.g0s,t.g0i),i=Au(t.g1s,t.g1i),n=Au(t.b0s,t.b0i),a=Au(t.b1s,t.b1i);return Math.min(e,r,s,i,n,a)}var Bue=new _e({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:jT,gamutSpace:"self",fromBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(e>99.9999999)i=0,e=100;else if(e<1e-8)i=0,e=0;else{let n=pg(e),a=tN(n);i=r/a*100}return[s,i,e]},toBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=pg(s);i=tN(n)/100*r}return[s,i,e]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const rN=203,sN=2610/2**14,Vue=2**14/2610,Oue=2523/2**5,iN=2**5/2523,nN=3424/2**12,aN=2413/2**7,oN=2392/2**7;var kue=new Ps({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:cy,toBase(t){return t.map(function(e){return(Math.max(e**iN-nN,0)/(aN-oN*e**iN))**Vue*1e4/rN})},fromBase(t){return t.map(function(e){let r=Math.max(e*rN/1e4,0),s=nN+aN*r**sN,i=1+oN*r**sN;return(s/i)**Oue})}});const lN=.17883277,uN=.28466892,hN=.55991073,y0=3.7743;var Uue=new Ps({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:cy,toBase(t){return t.map(function(e){return e<=.5?e**2/3*y0:(Math.exp((e-hN)/lN)+uN)/12*y0})},fromBase(t){return t.map(function(e){return e/=y0,e<=1/12?Math.sqrt(3*e):lN*Math.log(12*e-uN)+hN})}});const nI={};Mo.add("chromatic-adaptation-start",t=>{t.options.method&&(t.M=cN(t.W1,t.W2,t.options.method))}),Mo.add("chromatic-adaptation-end",t=>{t.M||(t.M=cN(t.W1,t.W2,t.options.method))});function Wm({id:t,toCone_M:e,fromCone_M:r}){nI[t]=arguments[0]}function cN(t,e,r="Bradford"){let s=nI[r],[i,n,a]=It(s.toCone_M,t),[o,l,h]=It(s.toCone_M,e),u=[[o/i,0,0],[0,l/n,0],[0,0,h/a]],c=It(u,s.toCone_M);return It(s.fromCone_M,c)}Wm({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]]}),Wm({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]]}),Wm({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]]}),Wm({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(fs,{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]}),fs.ACES=[.32168/.33767,1,.34065/.33767];const Due=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],$ue=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var aI=new Ps({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:fs.ACES,toXYZ_M:Due,fromXYZ_M:$ue});const Hm=2**-16,x0=-.35828683,qm=(Math.log2(65504)+9.72)/17.52;var Gue=new Ps({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[x0,qm],name:"Red"},g:{range:[x0,qm],name:"Green"},b:{range:[x0,qm],name:"Blue"}},referred:"scene",base:aI,toBase(t){let e=-.3013698630136986;return t.map(function(r){return r<=e?(2**(r*17.52-9.72)-Hm)*2:r<qm?2**(r*17.52-9.72):65504})},fromBase(t){return t.map(function(e){return e<=0?(Math.log2(Hm)+9.72)/17.52:e<Hm?(Math.log2(Hm+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),dN=Object.freeze({__proto__:null,A98RGB:_ue,A98RGB_Linear:tI,ACEScc:Gue,ACEScg:aI,CAM16_JMh:Ele,HCT:Ed,HPLuv:Bue,HSL:KL,HSLuv:zue,HSV:eI,HWB:wue,ICTCP:kb,JzCzHz:Ob,Jzazbz:zL,LCH:Rd,LCHuv:jT,Lab:Zs,Lab_D65:$b,Luv:iI,OKLCH:Pue,OKLab:Dh,P3:XL,P3_Linear:HL,ProPhoto:Eue,ProPhoto_Linear:rI,REC_2020:WL,REC_2020_Linear:cy,REC_2100_HLG:Uue,REC_2100_PQ:kue,XYZ_ABS_D65:DT,XYZ_D50:UT,XYZ_D65:$r,sRGB:jh,sRGB_Linear:qL}),Us=class vs{constructor(...e){let r;e.length===1&&(r=ke(e[0]));let s,i,n;r?(s=r.space||r.spaceId,i=r.coords,n=r.alpha):[s,i,n]=e,Object.defineProperty(this,"space",{value:_e.get(s),writable:!1,enumerable:!0,configurable:!0}),this.coords=i?i.slice():[0,0,0],this.alpha=n>1||n===void 0?1:n<0?0:n;for(let a=0;a<this.coords.length;a++)this.coords[a]==="NaN"&&(this.coords[a]=NaN);for(let a in this.space.coords)Object.defineProperty(this,a,{get:()=>this.get(a),set:o=>this.set(a,o)})}get spaceId(){return this.space.id}clone(){return new vs(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let r=Hle(this,...e);return r.color=new vs(r.color),r}static get(e,...r){return e instanceof vs?e:new vs(e,...r)}static defineFunction(e,r,s=r){let{instance:i=!0,returns:n}=s,a=function(...o){let l=r(...o);if(n==="color")l=vs.get(l);else if(n==="function<color>"){let h=l;l=function(...u){let c=h(...u);return vs.get(c)},Object.assign(l,h)}else n==="array<color>"&&(l=l.map(h=>vs.get(h)));return l};e in vs||(vs[e]=a),i&&(vs.prototype[e]=function(...o){return a(this,...o)})}static defineFunctions(e){for(let r in e)vs.defineFunction(r,e[r],e[r])}static extend(e){if(e.register)e.register(vs);else for(let r in e)vs.defineFunction(r,e[r])}};Us.defineFunctions({get:Ys,getAll:mp,set:Aa,setAll:kT,to:Lt,equals:qle,inGamut:bl,toGamut:_o,distance:IL,toString:ad}),Object.assign(Us,{util:Woe,hooks:Mo,WHITES:fs,Space:_e,spaces:_e.registry,parse:FL,defaults:ei});for(let t of Object.keys(dN))_e.register(dN[t]);for(let t in _e.registry)Gb(t,_e.registry[t]);Mo.add("colorspace-init-end",t=>{Gb(t.id,t),t.aliases?.forEach(e=>{Gb(e,t)})});function Gb(t,e){let r=t.replace(/-/g,"_");Object.defineProperty(Us.prototype,r,{get(){let s=this.getAll(t);return typeof Proxy>"u"?s:new Proxy(s,{has:(i,n)=>{try{return _e.resolveCoord([e,n]),!0}catch{}return Reflect.has(i,n)},get:(i,n,a)=>{if(n&&typeof n!="symbol"&&!(n in i)){let{index:o}=_e.resolveCoord([e,n]);if(o>=0)return i[o]}return Reflect.get(i,n,a)},set:(i,n,a,o)=>{if(n&&typeof n!="symbol"&&!(n in i)||n>=0){let{index:l}=_e.resolveCoord([e,n]);if(l>=0)return i[l]=a,this.setAll(t,i),!0}return Reflect.set(i,n,a,o)}})},set(s){this.setAll(t,s)},configurable:!0,enumerable:!0})}Us.extend(Gh),Us.extend({deltaE:jc}),Object.assign(Us,{deltaEMethods:Gh}),Us.extend(bue),Us.extend({contrast:mue}),Us.extend(gue),Us.extend(Yle),Us.extend(Tue),Us.extend(vf);const{vec2:jue,vec4:Wue}=_t,xs=t=>{let e=new Us(t);return Wue(...e.to("p3-linear").coords,e.alpha).value},gp=t=>{let e=.5,r=.5,s=(i,n=!1)=>{if(typeof i=="number")return i;let a=i.toLowerCase().trim();if(n){if(a==="top")return 0;if(a==="bottom")return 1;if(a==="center")return .5}else{if(a==="left")return 0;if(a==="right")return 1;if(a==="center")return .5}return console.warn(`Invalid position value: ${i}. Defaulting to center.`),.5};if(typeof t=="string"){let i=t.toLowerCase().trim().split(/\s+/);i.includes("left")?e=0:i.includes("right")?e=1:(i.includes("center")||i.length===1&&(i[0]==="top"||i[0]==="bottom"))&&(e=.5),i.includes("top")?r=0:i.includes("bottom")?r=1:(i.includes("center")||i.length===1&&(i[0]==="left"||i[0]==="right"))&&(r=.5),i.length===1&&i[0]==="center"&&(e=.5,r=.5)}else typeof t=="object"&&t?(e=s(t.x,!1),r=s(t.y,!0)):console.warn(`Invalid position value provided: ${t}. Defaulting to center.`);return jue(e,1-r).value},Hue=t=>{if(typeof t=="number")return(t%360+360)%360;let e=t.toLowerCase().trim();switch(e){case"to right":return 0;case"to bottom":return 90;case"to left":return 180;case"to top":return 270;case"to bottom right":case"to right bottom":return 45;case"to bottom left":case"to left bottom":return 135;case"to top left":case"to left top":return 225;case"to top right":case"to right top":return 315;case"from left":return 0;case"from top":return 90;case"from right":return 180;case"from bottom":return 270;case"from top left":return 45;case"from top right":return 135;case"from bottom right":return 225;case"from bottom left":return 315;default:let r=e.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(r){let[,s,i="deg"]=r,n=parseFloat(s);switch(i){case"deg":return(n%360+360)%360;case"rad":return(n*180/Math.PI%360+360)%360;case"turn":return(n*360%360+360)%360;default:return(n%360+360)%360}}return console.warn(`Invalid angle value: ${t}. Defaulting to 0 degrees.`),0}},ah={name:"Checkerboard",props:{colorA:{default:"#cccccc",transform:xs,description:"First color of the checkerboard pattern",ui:{type:"color",label:"Color A"}},colorB:{default:"#999999",transform:xs,description:"Second color of the checkerboard pattern",ui:{type:"color",label:"Color B"}},cells:{default:8,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,floor:s,mod:i,screenUV:n,viewportSize:a}=_t,o=a.x.div(a.y),l=e(n.x.mul(o),n.y.oneMinus()),h=t.cells.uniform,u=l.mul(h),c=s(u),d=i(c.x.add(c.y),2);return r(t.colorA.uniform,t.colorB.uniform,d)}};function que(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const oI={blendMode:"normal"};try{ah&&ah.props&&Object.entries(ah.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(oI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xue=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${ah.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>que(t,oI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(ah,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,ah.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},oh={name:"Circle",props:{color:{default:"#ffffff",transform:xs,description:"The color of the circle",ui:{type:"color",label:"Color"}},radius:{default:1,description:"The radius of the circle. A value of one (1) is sets the circle to fit the canvas.",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}},softness:{default:0,description:"Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},center:{default:{x:.5,y:.5},transform:gp,description:"The center point of the circle",ui:{type:"text",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,length:s,mix:i,smoothstep:n,screenUV:a,viewportSize:o}=_t,l=o.x.div(o.y),h=e(a.x.mul(l),a.y),u=e(t.center.uniform.x.mul(l),t.center.uniform.y.oneMinus()),c=s(h.sub(u)),d=t.softness.uniform,p=t.radius.uniform.mul(.5),m=n(p,p.sub(d),c);return i(r(t.color.uniform.rgb,0),t.color.uniform,m)}};function Yue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const lI={blendMode:"normal"};try{oh&&oh.props&&Object.entries(oh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(lI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zue=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${oh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Yue(t,lI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(oh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,oh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},lh={name:"DotGrid",props:{color:{default:"#ffffff",description:"The color of the dot",transform:xs,ui:{type:"color",label:"Color"}},density:{default:100,description:"The number of dots on the longest canvas edge",ui:{type:"range",min:10,max:500,step:10,label:"Density"}},dotSize:{default:.3,description:"The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps",ui:{type:"range",min:0,max:1,step:.01,label:"Dot Size"}},twinkle:{default:0,description:"Intensity of the twinkle effect (0 = off, 1 = full twinkle)",ui:{type:"range",min:0,max:1,step:.01,label:"Twinkle"}}},fragmentNode:({uniforms:t})=>{let{screenUV:e,vec4:r,vec3:s,vec2:i,smoothstep:n,length:a,floor:o,float:l,viewportSize:h,time:u,sin:c,mix:d}=_t,p=e,m=t.density.uniform,f=t.dotSize.uniform,g=t.color.uniform,b=t.twinkle.uniform,v=h,w=v.x.div(v.y),T=i(p.x.mul(w),p.y.oneMinus()),N=T.mul(m),S=N.sub(o(N)),_=a(S.sub(.5)),A=a(b3(T.mul(m))),D=l(1).sub(n(f.mul(.5),f.mul(.5).add(A.mul(.5)),_)),K=o(N),J=K.x.mul(12.9898).add(K.y.mul(78.233)).sin().mul(43758.5453).fract(),re=u.mul(2).add(J.mul(6.28318)),te=c(re).mul(.5).add(.5),oe=d(l(1),te,b),ae=D.mul(oe),ge=s(g).mul(ae);return r(ge,ae)}};function Jue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const uI={blendMode:"normal"};try{lh&&lh.props&&Object.entries(lh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(uI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Que=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${lh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Jue(t,uI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(lh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,lh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},uh={name:"FilmGrain",props:{intensity:{default:.25,description:"Grain intensity (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Intensity"}},power:{default:.645,description:"Controls blending based on brightness",ui:{type:"range",min:0,max:2,step:.01,label:"Power"}},speed:{default:.5,description:"Animation speed of grain noise",ui:{type:"range",min:0,max:3,step:.1,label:"Speed"}}},fragmentNode:({uniforms:t,childNode:e})=>{let r=e||Ur(0,0,0,0),s=Iv(),i=p=>fb(no(wd(p,zv(12.9898,78.233))).mul(43758.5453)),n=p=>wd(p,Ur(.299,.587,.114,0)),a=i(s).add(Lv.mul(t.speed.uniform)),o=fb(no(a.mul(43758.5453))),l=ml(mb(.5),mb(.75),o).mul(t.intensity.uniform),h=T3(n(r),t.power.uniform),u=r.mul(l),c=x3(h,0,1),d=ml(u,r,c);return Ur(d.x,d.y,d.z,r.w)}};function Kue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const hI={blendMode:"normal"};try{uh&&uh.props&&Object.entries(uh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(hI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ehe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${uh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Kue(t,hI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(uh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,uh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},Xm=new WeakMap,hh={name:"glassTiles",props:{intensity:{default:1,description:"The intensity of the glass tiles effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},tileCount:{default:100,description:"Number of tiles across the shortest dimension",ui:{type:"range",min:1,max:200,step:1,label:"Tile Count"}}},fragmentNode:({uniforms:t,childNode:e,onCleanup:r,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,screenUV:d,uniform:p}=_t;if(!e)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(e),f=p(1),g=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};g();let b=Xm.get(s);b||(b=new ResizeObserver(ae=>{let ge=ae[0];if(!ge)return;let{width:fe,height:ve}=ge.contentRect,me=window.devicePixelRatio||1;m.setSize(fe*me,ve*me),g()}),b.observe(s),Xm.set(s,b)),r(()=>{let ae=Xm.get(s);ae&&(ae.disconnect(),Xm.delete(s))});let v=d,w=t.intensity.uniform,T=t.tileCount.uniform,N=i(f.greaterThanEqual(1).select(o(T,f),T),f.lessThan(1).select(l(T,f),T)),S=l(a(o(v,N)),N),_=h(v,S),A=i(.5,.5),D=o(w,.025),K=l(_,l(i(1),N)),J=h(K,A),re=o(J,D),te=u(_,re),oe=u(te,S);return n(m.sample(oe))}};function the(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const cI={blendMode:"normal"};try{hh&&hh.props&&Object.entries(hh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(cI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rhe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${hh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>the(t,cI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(hh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,hh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},Ym={VERTEX:"vertex"},eo={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},yp=["x","y","z","w"],Zr="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 pN=1234567;const dI=Math.PI/180,pI=180/Math.PI;function Tf(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Zr[t&255]+Zr[t>>8&255]+Zr[t>>16&255]+Zr[t>>24&255]+"-"+Zr[e&255]+Zr[e>>8&255]+"-"+Zr[e>>16&15|64]+Zr[e>>24&255]+"-"+Zr[r&63|128]+Zr[r>>8&255]+"-"+Zr[r>>16&255]+Zr[r>>24&255]+Zr[s&255]+Zr[s>>8&255]+Zr[s>>16&255]+Zr[s>>24&255]).toLowerCase()}function at(t,e,r){return Math.max(e,Math.min(r,t))}function WT(t,e){return(t%e+e)%e}function she(t,e,r,s,i){return s+(t-e)*(i-s)/(r-e)}function ihe(t,e,r){return t===e?0:(r-t)/(e-t)}function od(t,e,r){return(1-r)*t+r*e}function nhe(t,e,r,s){return od(t,e,1-Math.exp(-r*s))}function ahe(t,e=1){return e-Math.abs(WT(t,e*2)-e)}function ohe(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function lhe(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function uhe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function hhe(t,e){return t+Math.random()*(e-t)}function che(t){return t*(.5-Math.random())}function dhe(t){t!==void 0&&(pN=t);let e=pN+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function phe(t){return t*dI}function mhe(t){return t*pI}function fhe(t){return(t&t-1)==0&&t!==0}function ghe(t){return 2**Math.ceil(Math.log(t)/Math.LN2)}function yhe(t){return 2**Math.floor(Math.log(t)/Math.LN2)}function xhe(t,e,r,s,i){let n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+s)/2),u=a((e+s)/2),c=n((e-s)/2),d=a((e-s)/2),p=n((s-e)/2),m=a((s-e)/2);switch(i){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*u,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Zi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function dt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("Invalid component type.")}}const bhe={DEG2RAD:dI,RAD2DEG:pI,generateUUID:Tf,clamp:at,euclideanModulo:WT,mapLinear:she,inverseLerp:ihe,lerp:od,damp:nhe,pingpong:ahe,smoothstep:ohe,smootherstep:lhe,randInt:uhe,randFloat:hhe,randFloatSpread:che,seededRandom:dhe,degToRad:phe,radToDeg:mhe,isPowerOfTwo:fhe,ceilPowerOfTwo:ghe,floorPowerOfTwo:yhe,setQuaternionFromProperEuler:xhe,normalize:dt,denormalize:Zi},jb=0,vhe=1015,Wb="",Wi="srgb",mN="srgb-linear",fN="linear",ld="srgb",mg=35044,ll=2e3,Hb=2001;var xp=class mI{constructor(e,r,s,i,n,a,o,l,h){mI.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,s,i,n,a,o,l,h)}set(e,r,s,i,n,a,o,l,h){let u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let r=this.elements,s=e.elements;return r[0]=s[0],r[1]=s[1],r[2]=s[2],r[3]=s[3],r[4]=s[4],r[5]=s[5],r[6]=s[6],r[7]=s[7],r[8]=s[8],this}extractBasis(e,r,s){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let s=e.elements,i=r.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],g=i[3],b=i[6],v=i[1],w=i[4],T=i[7],N=i[2],S=i[5],_=i[8];return n[0]=a*f+o*v+l*N,n[3]=a*g+o*w+l*S,n[6]=a*b+o*T+l*_,n[1]=h*f+u*v+c*N,n[4]=h*g+u*w+c*S,n[7]=h*b+u*T+c*_,n[2]=d*f+p*v+m*N,n[5]=d*g+p*w+m*S,n[8]=d*b+p*T+m*_,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=r*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return e[0]=c*f,e[1]=(i*h-u*s)*f,e[2]=(o*s-i*a)*f,e[3]=d*f,e[4]=(u*r-i*l)*f,e[5]=(i*n-o*r)*f,e[6]=p*f,e[7]=(s*l-h*r)*f,e[8]=(a*r-s*n)*f,this}transpose(){let e,r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+e,-i*h,i*l,-i*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(b0.makeScale(e,r)),this}rotate(e){return this.premultiply(b0.makeRotation(-e)),this}translate(e,r){return this.premultiply(b0.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,-s,0,s,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){let r=this.elements,s=e.elements;for(let i=0;i<9;i++)if(r[i]!==s[i])return!1;return!0}fromArray(e,r=0){for(let s=0;s<9;s++)this.elements[s]=e[s+r];return this}toArray(e=[],r=0){let s=this.elements;return e[r]=s[0],e[r+1]=s[1],e[r+2]=s[2],e[r+3]=s[3],e[r+4]=s[4],e[r+5]=s[5],e[r+6]=s[6],e[r+7]=s[7],e[r+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const b0=new xp,gN={};function yN(t){t in gN||(gN[t]=!0,console.warn(t))}const xN=new xp().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),bN=new xp().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function The(){let t={enabled:!0,workingColorSpace:mN,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===ld&&(i.r=ch(i.r),i.g=ch(i.g),i.b=ch(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ld&&(i.r=dh(i.r),i.g=dh(i.g),i.b=dh(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Wb?fN:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return yN("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return yN("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],s=[.3127,.329];return t.define({[mN]:{primaries:e,whitePoint:s,transfer:fN,toXYZ:xN,fromXYZ:bN,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:Wi},outputColorSpaceConfig:{drawingBufferColorSpace:Wi}},[Wi]:{primaries:e,whitePoint:s,transfer:ld,toXYZ:xN,fromXYZ:bN,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:Wi}}}),t}const dr=The();function ch(t){return t<.04045?t*.0773993808:(t*.9478672986+.0521327014)**2.4}function dh(t){return t<.0031308?t*12.92:1.055*t**.41666-.055}const fI={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},Xa={h:0,s:0,l:0},Zm={h:0,s:0,l:0};function v0(t,e,r){return r<0&&(r+=1),r>1&&--r,r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}var HT=class{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Wi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,dr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,s=dr.workingColorSpace){return this.r=t,this.g=e,this.b=r,dr.colorSpaceToWorking(this,s),this}setHSL(t,e,r,s=dr.workingColorSpace){if(t=WT(t,1),e=at(e,0,1),r=at(r,0,1),e===0)this.r=this.g=this.b=r;else{let i=r<=.5?r*(1+e):r+e-r*e,n=2*r-i;this.r=v0(n,i,t+1/3),this.g=v0(n,i,t),this.b=v0(n,i,t-1/3)}return dr.colorSpaceToWorking(this,s),this}setStyle(t,e=Wi){function r(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let i,n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let i=s[1],n=i.length;if(n===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(n===6)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Wi){let r=fI[t.toLowerCase()];return r===void 0?console.warn("THREE.Color: Unknown color "+t):this.setHex(r,e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ch(t.r),this.g=ch(t.g),this.b=ch(t.b),this}copyLinearToSRGB(t){return this.r=dh(t.r),this.g=dh(t.g),this.b=dh(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Wi){return dr.workingToColorSpace(Jr.copy(this),t),Math.round(at(Jr.r*255,0,255))*65536+Math.round(at(Jr.g*255,0,255))*256+Math.round(at(Jr.b*255,0,255))}getHexString(t=Wi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=dr.workingColorSpace){dr.workingToColorSpace(Jr.copy(this),e);let r=Jr.r,s=Jr.g,i=Jr.b,n=Math.max(r,s,i),a=Math.min(r,s,i),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case r:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-r)/u+2;break;case i:o=(r-s)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=dr.workingColorSpace){return dr.workingToColorSpace(Jr.copy(this),e),t.r=Jr.r,t.g=Jr.g,t.b=Jr.b,t}getStyle(t=Wi){dr.workingToColorSpace(Jr.copy(this),t);let e=Jr.r,r=Jr.g,s=Jr.b;return t===Wi?`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(s*255)})`:`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(t,e,r){return this.getHSL(Xa),this.setHSL(Xa.h+t,Xa.s+e,Xa.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(Xa),t.getHSL(Zm);let r=od(Xa.h,Zm.h,e),s=od(Xa.s,Zm.s,e),i=od(Xa.l,Zm.l,e);return this.setHSL(r,s,i),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,r=this.g,s=this.b,i=t.elements;return this.r=i[0]*e+i[3]*r+i[6]*s,this.g=i[1]*e+i[4]*r+i[7]*s,this.b=i[2]*e+i[5]*r+i[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Jr=new HT;HT.NAMES=fI;var whe=class gI{constructor(e,r,s,i){gI.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let s=0;s<4;s++)this.elements[s]=e[s+r];return this}set(e,r,s,i){let n=this.elements;return n[0]=e,n[2]=r,n[1]=s,n[3]=i,this}},She=class{constructor(t=0,e=0,r=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=s}static slerpFlat(t,e,r,s,i,n,a){let o=r[s+0],l=r[s+1],h=r[s+2],u=r[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){t[e+0]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(a===1){t[e+0]=c,t[e+1]=d,t[e+2]=p,t[e+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,g=o*c+l*d+h*p+u*m,b=g>=0?1:-1,v=1-g*g;if(v>2**-52){let T=Math.sqrt(v),N=Math.atan2(T,g*b);f=Math.sin(f*N)/T,a=Math.sin(a*N)/T}let w=a*b;if(o=o*f+c*w,l=l*f+d*w,h=h*f+p*w,u=u*f+m*w,f===1-a){let T=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=T,l*=T,h*=T,u*=T}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,r,s,i,n){let a=r[s],o=r[s+1],l=r[s+2],h=r[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return t[e]=a*p+h*u+o*d-l*c,t[e+1]=o*p+h*c+l*u-a*d,t[e+2]=l*p+h*d+a*c-o*u,t[e+3]=h*p-a*u-o*c-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,s){return this._x=t,this._y=e,this._z=r,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let r=t._x,s=t._y,i=t._z,n=t._order,a=Math.cos,o=Math.sin,l=a(r/2),h=a(s/2),u=a(i/2),c=o(r/2),d=o(s/2),p=o(i/2);switch(n){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let r=e/2,s=Math.sin(r);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],s=e[4],i=e[8],n=e[1],a=e[5],o=e[9],l=e[2],h=e[6],u=e[10],c=r+a+u;if(c>0){let d=.5/Math.sqrt(c+1);this._w=.25/d,this._x=(h-o)*d,this._y=(i-l)*d,this._z=(n-s)*d}else if(r>a&&r>u){let d=2*Math.sqrt(1+r-a-u);this._w=(h-o)/d,this._x=.25*d,this._y=(s+n)/d,this._z=(i+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-r-u);this._w=(i-l)/d,this._x=(s+n)/d,this._y=.25*d,this._z=(o+h)/d}else{let d=2*Math.sqrt(1+u-r-a);this._w=(n-s)/d,this._x=(i+l)/d,this._y=(o+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<2**-52?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(at(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let s=Math.min(1,e/r);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x*=t,this._y*=t,this._z*=t,this._w*=t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let r=t._x,s=t._y,i=t._z,n=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=r*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-r*l,this._z=i*h+n*l+r*o-s*a,this._w=n*h-r*a-s*o-i*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,s=this._y,i=this._z,n=this._w,a=n*t._w+r*t._x+s*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=n,this._x=r,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-e;return this._w=d*n+e*this._w,this._x=d*r+e*this._x,this._y=d*s+e*this._y,this._z=d*i+e*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-e)*h)/l,c=Math.sin(e*h)/l;return this._w=n*u+this._w*c,this._x=r*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),s=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ln=class yI{constructor(e=0,r=0,s=0){yI.prototype.isVector3=!0,this.x=e,this.y=r,this.z=s}set(e,r,s){return s===void 0&&(s=this.z),this.x=e,this.y=r,this.z=s,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.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,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(vN.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(vN.setFromAxisAngle(e,r))}applyMatrix3(e){let r=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*r+n[3]*s+n[6]*i,this.y=n[1]*r+n[4]*s+n[7]*i,this.z=n[2]*r+n[5]*s+n[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let r=this.x,s=this.y,i=this.z,n=e.elements,a=1/(n[3]*r+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*r+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*r+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*r+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(e){let r=this.x,s=this.y,i=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*i-o*s),u=2*(o*r-n*i),c=2*(n*s-a*r);return this.x=r+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let r=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*r+n[4]*s+n[8]*i,this.y=n[1]*r+n[5]*s+n[9]*i,this.z=n[2]*r+n[6]*s+n[10]*i,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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this.z=at(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this.z=at(this.z,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}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,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this.z=e.z+(r.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){let s=e.x,i=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(e){let r=e.lengthSq();if(r===0)return this.set(0,0,0);let s=e.dot(this)/r;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return T0.copy(this).projectOnVector(e),this.sub(T0)}reflect(e){return this.sub(T0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let s=this.dot(e)/r;return Math.acos(at(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return r*r+s*s+i*i}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,r,s){let i=Math.sin(r)*e;return this.x=i*Math.sin(s),this.y=Math.cos(r)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,s){return this.x=e*Math.sin(r),this.y=s,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){let r=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=s,this.z=i,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*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,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,r=Math.random()*2-1,s=Math.sqrt(1-r*r);return this.x=s*Math.cos(e),this.y=r,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const T0=new ln,vN=new She;var xI=class qb{constructor(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g){qb.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g)}set(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g){let b=this.elements;return b[0]=e,b[4]=r,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=g,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 qb().fromArray(this.elements)}copy(e){let r=this.elements,s=e.elements;return r[0]=s[0],r[1]=s[1],r[2]=s[2],r[3]=s[3],r[4]=s[4],r[5]=s[5],r[6]=s[6],r[7]=s[7],r[8]=s[8],r[9]=s[9],r[10]=s[10],r[11]=s[11],r[12]=s[12],r[13]=s[13],r[14]=s[14],r[15]=s[15],this}copyPosition(e){let r=this.elements,s=e.elements;return r[12]=s[12],r[13]=s[13],r[14]=s[14],this}setFromMatrix3(e){let r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,s){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,r,s){return this.set(e.x,r.x,s.x,0,e.y,r.y,s.y,0,e.z,r.z,s.z,0,0,0,0,1),this}extractRotation(e){let r=this.elements,s=e.elements,i=1/Cu.setFromMatrixColumn(e,0).length(),n=1/Cu.setFromMatrixColumn(e,1).length(),a=1/Cu.setFromMatrixColumn(e,2).length();return r[0]=s[0]*i,r[1]=s[1]*i,r[2]=s[2]*i,r[3]=0,r[4]=s[4]*n,r[5]=s[5]*n,r[6]=s[6]*n,r[7]=0,r[8]=s[8]*a,r[9]=s[9]*a,r[10]=s[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){let r=this.elements,s=e.x,i=e.y,n=e.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=p+m*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=m+p*h,r[10]=a*l}else if(e.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;r[0]=d+f*o,r[4]=m*o-p,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=p*o-m,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=m+p*o,r[1]=p+m*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;r[0]=l*u,r[4]=m*h-p,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=p*h-m,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=m*c+p,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=p*c+m,r[10]=d-f*c}else if(e.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=p*c-m,r[2]=m*c-p,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Mhe,e,_he)}lookAt(e,r,s){let i=this.elements;return ks.subVectors(e,r),ks.lengthSq()===0&&(ks.z=1),ks.normalize(),Ya.crossVectors(s,ks),Ya.lengthSq()===0&&(Math.abs(s.z)===1?ks.x+=1e-4:ks.z+=1e-4,ks.normalize(),Ya.crossVectors(s,ks)),Ya.normalize(),Jm.crossVectors(ks,Ya),i[0]=Ya.x,i[4]=Jm.x,i[8]=ks.x,i[1]=Ya.y,i[5]=Jm.y,i[9]=ks.y,i[2]=Ya.z,i[6]=Jm.z,i[10]=ks.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let s=e.elements,i=r.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],g=s[10],b=s[14],v=s[3],w=s[7],T=s[11],N=s[15],S=i[0],_=i[4],A=i[8],D=i[12],K=i[1],J=i[5],re=i[9],te=i[13],oe=i[2],ae=i[6],ge=i[10],fe=i[14],ve=i[3],me=i[7],he=i[11],Te=i[15];return n[0]=a*S+o*K+l*oe+h*ve,n[4]=a*_+o*J+l*ae+h*me,n[8]=a*A+o*re+l*ge+h*he,n[12]=a*D+o*te+l*fe+h*Te,n[1]=u*S+c*K+d*oe+p*ve,n[5]=u*_+c*J+d*ae+p*me,n[9]=u*A+c*re+d*ge+p*he,n[13]=u*D+c*te+d*fe+p*Te,n[2]=m*S+f*K+g*oe+b*ve,n[6]=m*_+f*J+g*ae+b*me,n[10]=m*A+f*re+g*ge+b*he,n[14]=m*D+f*te+g*fe+b*Te,n[3]=v*S+w*K+T*oe+N*ve,n[7]=v*_+w*J+T*ae+N*me,n[11]=v*A+w*re+T*ge+N*he,n[15]=v*D+w*te+T*fe+N*Te,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){let e=this.elements,r=e[0],s=e[4],i=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],p=e[14],m=e[3],f=e[7],g=e[11],b=e[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+r*l*p-r*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+g*(+r*h*c-r*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-r*l*c+r*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let e=this.elements,r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,s){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=r,i[14]=s),this}invert(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],p=e[11],m=e[12],f=e[13],g=e[14],b=e[15],v=c*g*h-f*d*h+f*l*p-o*g*p-c*l*b+o*d*b,w=m*d*h-u*g*h-m*l*p+a*g*p+u*l*b-a*d*b,T=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,N=m*c*l-u*f*l-m*o*d+a*f*d+u*o*g-a*c*g,S=r*v+s*w+i*T+n*N;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let _=1/S;return e[0]=v*_,e[1]=(f*d*n-c*g*n-f*i*p+s*g*p+c*i*b-s*d*b)*_,e[2]=(o*g*n-f*l*n+f*i*h-s*g*h-o*i*b+s*l*b)*_,e[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*_,e[4]=w*_,e[5]=(u*g*n-m*d*n+m*i*p-r*g*p-u*i*b+r*d*b)*_,e[6]=(m*l*n-a*g*n-m*i*h+r*g*h+a*i*b-r*l*b)*_,e[7]=(a*d*n-u*l*n+u*i*h-r*d*h-a*i*p+r*l*p)*_,e[8]=T*_,e[9]=(m*c*n-u*f*n-m*s*p+r*f*p+u*s*b-r*c*b)*_,e[10]=(a*f*n-m*o*n+m*s*h-r*f*h-a*s*b+r*o*b)*_,e[11]=(u*o*n-a*c*n-u*s*h+r*c*h+a*s*p-r*o*p)*_,e[12]=N*_,e[13]=(u*f*i-m*c*i+m*s*d-r*f*d-u*s*g+r*c*g)*_,e[14]=(m*o*i-a*f*i-m*s*l+r*f*l+a*s*g-r*o*g)*_,e[15]=(a*c*i-u*o*i+u*s*l-r*c*l-a*s*d+r*o*d)*_,this}scale(e){let r=this.elements,s=e.x,i=e.y,n=e.z;return r[0]*=s,r[4]*=i,r[8]*=n,r[1]*=s,r[5]*=i,r[9]*=n,r[2]*=s,r[6]*=i,r[10]*=n,r[3]*=s,r[7]*=i,r[11]*=n,this}getMaxScaleOnAxis(){let e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,s,i))}makeTranslation(e,r,s){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,r,0,0,1,s,0,0,0,1),this}makeRotationX(e){let r=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,r,-s,0,0,s,r,0,0,0,0,1),this}makeRotationY(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,0,s,0,0,1,0,0,-s,0,r,0,0,0,0,1),this}makeRotationZ(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,-s,0,0,s,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){let s=Math.cos(r),i=Math.sin(r),n=1-s,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(e,r,s){return this.set(e,0,0,0,0,r,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,r,s,i,n,a){return this.set(1,s,n,0,e,1,a,0,r,i,1,0,0,0,0,1),this}compose(e,r,s){let i=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,g=a*c,b=o*c,v=l*h,w=l*u,T=l*c,N=s.x,S=s.y,_=s.z;return i[0]=(1-(f+b))*N,i[1]=(p+T)*N,i[2]=(m-w)*N,i[3]=0,i[4]=(p-T)*S,i[5]=(1-(d+b))*S,i[6]=(g+v)*S,i[7]=0,i[8]=(m+w)*_,i[9]=(g-v)*_,i[10]=(1-(d+f))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,r,s){let i=this.elements,n=Cu.set(i[0],i[1],i[2]).length(),a=Cu.set(i[4],i[5],i[6]).length(),o=Cu.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],Di.copy(this);let h=1/n,u=1/a,c=1/o;return Di.elements[0]*=h,Di.elements[1]*=h,Di.elements[2]*=h,Di.elements[4]*=u,Di.elements[5]*=u,Di.elements[6]*=u,Di.elements[8]*=c,Di.elements[9]*=c,Di.elements[10]*=c,r.setFromRotationMatrix(Di),s.x=n,s.y=a,s.z=o,this}makePerspective(e,r,s,i,n,a,o=ll){let l=this.elements,h=2*n/(r-e),u=2*n/(s-i),c=(r+e)/(r-e),d=(s+i)/(s-i),p,m;if(o===ll)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Hb)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,s,i,n,a,o=ll){let l=this.elements,h=1/(r-e),u=1/(s-i),c=1/(a-n),d=(r+e)*h,p=(s+i)*u,m,f;if(o===ll)m=(a+n)*c,f=-2*c;else if(o===Hb)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let r=this.elements,s=e.elements;for(let i=0;i<16;i++)if(r[i]!==s[i])return!1;return!0}fromArray(e,r=0){for(let s=0;s<16;s++)this.elements[s]=e[s+r];return this}toArray(e=[],r=0){let s=this.elements;return e[r]=s[0],e[r+1]=s[1],e[r+2]=s[2],e[r+3]=s[3],e[r+4]=s[4],e[r+5]=s[5],e[r+6]=s[6],e[r+7]=s[7],e[r+8]=s[8],e[r+9]=s[9],e[r+10]=s[10],e[r+11]=s[11],e[r+12]=s[12],e[r+13]=s[13],e[r+14]=s[14],e[r+15]=s[15],e}};const Cu=new ln,Di=new xI,Mhe=new ln(0,0,0),_he=new ln(1,1,1),Ya=new ln,Jm=new ln,ks=new ln;var bI=class vI{constructor(e=0,r=0){vI.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.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 r=this.x,s=this.y,i=e.elements;return this.x=i[0]*r+i[3]*s+i[6],this.y=i[1]*r+i[4]*s+i[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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let s=this.dot(e)/r;return Math.acos(at(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,s=this.y-e.y;return r*r+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){let s=Math.cos(r),i=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*s-a*i+e.x,this.y=n*i+a*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Nhe=class TI{constructor(e=0,r=0,s=0,i=1){TI.prototype.isVector4=!0,this.x=e,this.y=r,this.z=s,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,r,s,i){return this.x=e,this.y=r,this.z=s,this.w=i,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.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 r=this.x,s=this.y,i=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*r+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*r+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*r+a[7]*s+a[11]*i+a[15]*n,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 r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,s,i,n,a=.01,o=.1,l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],g=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-g)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+g)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;r=Math.PI;let w=(h+1)/2,T=(p+1)/2,N=(b+1)/2,S=(u+d)/4,_=(c+f)/4,A=(m+g)/4;return w>T&&w>N?w<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(w),i=S/s,n=_/s):T>N?T<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(T),s=S/i,n=A/i):N<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(N),s=_/n,i=A/n),this.set(s,i,n,r),this}let v=Math.sqrt((g-m)*(g-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(c-f)/v,this.z=(d-u)/v,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this.z=at(this.z,e.z,r.z),this.w=at(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this.z=at(this.z,e,r),this.w=at(this.w,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}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,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this.z=e.z+(r.z-e.z)*s,this.w=e.w+(r.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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 Xb(t,e=0){let r=3735928559^e,s=1103547991^e;if(t instanceof Array)for(let i=0,n;i<t.length;i++)n=t[i],r=Math.imul(r^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<t.length;i++)n=t.charCodeAt(i),r=Math.imul(r^n,2654435761),s=Math.imul(s^n,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const wI=(...t)=>Xb(t);function Ahe(t,e=!1){let r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(let{property:s,childNode:i}of Yb(t))r.push(Xb(s.slice(0,-4)),i.getCacheKey(e));return Xb(r)}function*Yb(t,e=!1){for(let r in t){if(r.startsWith("_")===!0)continue;let s=t[r];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:r,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:i,childNode:n})}}}function Zb(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function SI(t,...e){let r=t?t.slice(-4):void 0;return e.length===1&&(r==="vec2"?e=[e[0],e[0]]:r==="vec3"?e=[e[0],e[0],e[0]]:r==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new HT(...e):r==="vec2"?new bI(...e):r==="vec3"?new ln(...e):r==="vec4"?new Nhe(...e):r==="mat2"?new whe(...e):r==="mat3"?new xp(...e):r==="mat4"?new xI(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?Rhe(e[0]):null}function Che(t){let e="",r=new Uint8Array(t);for(let s=0;s<r.length;s++)e+=String.fromCharCode(r[s]);return btoa(e)}function Rhe(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}var Ehe=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){let r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){let r=this._listeners;if(r===void 0)return;let s=r[t];if(s!==void 0){let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let r=e[t.type];if(r!==void 0){t.target=this;let s=r.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,t);t.target=null}}};const Phe={analyze:"setup",generate:"analyze"};let Fhe=0;var Lhe=class extends Ehe{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=eo.NONE,this.updateBeforeType=eo.NONE,this.updateAfterType=eo.NONE,this.uuid=bhe.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Fhe++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,eo.FRAME)}onRenderUpdate(t){return this.onUpdate(t,eo.RENDER)}onObjectUpdate(t){return this.onUpdate(t,eo.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of Yb(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t||(t=this.version!==this._cacheKeyVersion),(t===!0||this._cacheKey===null)&&(this._cacheKey=wI(Ahe(this,t),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(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){let e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){let e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){let e=t.getNodeProperties(this),r=0;for(let s of this.getChildren())e["node"+r++]=s;return e.outputNode||null}analyze(t,e=null){let r=t.increaseUsage(this);if(this.parents===!0){let s=t.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[t.shaderStage]=s.stages[t.shaderStage]||[],s.stages[t.shaderStage].push(e)}if(r===1){let s=t.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(t,this)}}generate(t,e){let{outputNode:r}=t.getNodeProperties(this);if(r&&r.isNode===!0)return r.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){let r=this.getShared(t);if(this!==r)return r.build(t,e);let s=t.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[t.buildStage]=!0;let i=Phe[t.buildStage];if(i&&s.buildStages[i]!==!0){let o=t.getBuildStage();t.setBuildStage(i),this.build(t),t.setBuildStage(o)}t.addNode(this),t.addChain(this);let n=null,a=t.getBuildStage();if(a==="setup"){this.updateReference(t);let o=t.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(t)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=t.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(t)}}n=o.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(t),h=t.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(t)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,l,e)}else n=this.generate(t,e)||"";return t.removeChain(this),t.addSequentialNode(this),n}getSerializeChildren(){return Yb(this)}serialize(t){let e=this.getSerializeChildren(),r={};for(let{property:s,index:i,childNode:n}of e)i===void 0?r[s]=n.toJSON(t.meta).uuid:(r[s]===void 0&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(t.meta).uuid);Object.keys(r).length>0&&(t.inputNodes=r)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let r in t.inputNodes)if(Array.isArray(t.inputNodes[r])){let s=[];for(let i of t.inputNodes[r])s.push(e[i]);this[r]=s}else if(typeof t.inputNodes[r]=="object"){let s={};for(let i in t.inputNodes[r]){let n=t.inputNodes[r][i];s[i]=e[n]}this[r]=s}else{let s=t.inputNodes[r];this[r]=e[s]}}}toJSON(t){let{uuid:e,type:r}=this,s=t===void 0||typeof t=="string";s&&(t={textures:{},images:{},nodes:{}});let i=t.nodes[e];i===void 0&&(i={uuid:e,type:r,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(t.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s){let a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},yr=Lhe,Ihe=class extends yr{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){let s=t.getVectorType(this.getNodeType(t,e)),i=t.getDataFromNode(this);if(i.propertyName!==void 0)return t.format(i.propertyName,s,e);if(s!=="void"&&e!=="void"&&this.hasDependencies(t)){let n=super.build(t,s),a=t.getVarFromNode(this,null,s),o=t.getPropertyName(a);return t.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,t.format(i.propertyName,s,e)}}return super.build(t,e)}},ti=Ihe,zhe=class extends yr{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){let e=this.indexNode.getNodeType(t),r=this.node.build(t),s=this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint");return`${r}[ ${s} ]`}},qT=zhe,Bhe=class extends yr{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){let e=this.node.getNodeType(t),r=null;for(let s of this.convertTo.split("|"))(r===null||t.getTypeLength(e)===t.getTypeLength(s))&&(r=s);return r}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){let r=this.node,s=this.getNodeType(t),i=r.build(t,s);return t.format(i,s,e)}},MI=Bhe,Vhe=class extends ti{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType===null?t.getTypeFromLength(this.nodes.reduce((e,r)=>e+t.getTypeLength(r.getNodeType(t)),0)):t.getVectorType(this.nodeType)}generate(t,e){let r=this.getNodeType(t),s=t.getTypeLength(r),i=this.nodes,n=t.getComponentType(r),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let u=h.getNodeType(t),c=t.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),c=s-o,u=t.getTypeFromLength(c)),o+=c,d=h.build(t,u);let p=t.getComponentType(u);p!==n&&(d=t.format(d,p,n)),a.push(d)}let l=`${t.getType(r)}( ${a.join(", ")} )`;return t.format(l,r,e)}},Ohe=Vhe;const khe=yp.join("");var Uhe=class extends yr{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(let e of this.components)t=Math.max(yp.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){let r=this.node,s=t.getTypeLength(r.getNodeType(t)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));let o=r.build(t,n);i=this.components.length===s&&this.components===khe.slice(0,this.components.length)?t.format(o,n,e):t.format(`${o}.${this.components}`,this.getNodeType(t),e)}else i=r.build(t,e);return i}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}},TN=Uhe,Dhe=class extends ti{static get type(){return"SetNode"}constructor(t,e,r){super(),this.sourceNode=t,this.components=e,this.targetNode=r}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:r,targetNode:s}=this,i=this.getNodeType(t),n=t.getComponentType(s.getNodeType(t)),a=t.getTypeFromLength(r.length,n),o=s.build(t,a),l=e.build(t,i),h=t.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=yp[c];d===r[0]?(u.push(o),c+=r.length-1):u.push(l+"."+d)}return`${t.getType(i)}( ${u.join(", ")} )`}},$he=Dhe,Ghe=class extends ti{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{components:e,sourceNode:r}=this,s=this.getNodeType(t),i=r.build(t),n=t.getVarFromNode(this),a=t.getPropertyName(n);t.addLineFlowCode(a+" = "+i,this);let o=t.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=yp[u];c===e[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${t.getType(s)}( ${l.join(", ")} )`}},jhe=Ghe,Whe=class extends yr{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Zb(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Zb(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=Che(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?SI(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}},XT=Whe;const wN=/float|u?int/;var Hhe=class extends XT{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let r=this.getNodeType(t);return wN.test(r)&&wN.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),r,e)}},Fa=Hhe,qhe=class extends yr{static get type(){return"MemberNode"}constructor(t,e){super(),this.node=t,this.property=e,this.isMemberNode=!0}getNodeType(t){return this.node.getMemberType(t,this.property)}generate(t){return this.node.build(t)+"."+this.property}},Xhe=qhe;let Yhe=null;const Wu=new Map;function H(t,e){if(Wu.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw Error(`THREE.TSL: Node element ${t} is not a function`);Wu.set(t,e)}const _I=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),SN=t=>_I(t).split("").sort().join(""),NI={setup(t,e){let r=e.shift();return t(fy(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...s)=>(Yhe.assign(r,...s),r);if(Wu.has(e)){let s=Wu.get(e);return t.isStackNode?(...i)=>r.add(s(...i)):(...i)=>s(r,...i)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Wu.has(e.slice(0,e.length-6))){let s=Wu.get(e.slice(0,e.length-6));return t.isStackNode?(...i)=>r.assign(i[0],s(...i)):(...i)=>r.assign(s(r,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=_I(e),Ne(new TN(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=SN(e.slice(3).toLowerCase()),s=>Ne(new $he(t,e,Ne(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=SN(e.slice(4).toLowerCase()),()=>Ne(new jhe(Ne(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Ne(new TN(t,e));if(/^\d+$/.test(e)===!0)return Ne(new qT(r,new Fa(Number(e),"uint")));if(/^get$/.test(e)===!0)return s=>Ne(new Xhe(r,s))}}}return Reflect.get(t,e,r)},set(t,e,r,s){return typeof e=="string"&&t[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(s[e].assign(r),!0):Reflect.set(t,e,r,s)}},w0=new WeakMap,MN=new WeakMap,Zhe=function(t,e=null){let r=Zb(t);if(r==="node"){let s=w0.get(t);return s===void 0&&(s=new Proxy(t,NI),w0.set(t,s),w0.set(s,s)),s}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return Ne(Jb(t,e));if(r==="shader")return Ei(t)}return t},Jhe=function(t,e=null){for(let r in t)t[r]=Ne(t[r],e);return t},Qhe=function(t,e=null){let r=t.length;for(let s=0;s<r;s++)t[s]=Ne(t[s],e);return t},Khe=function(t,e=null,r=null,s=null){let i=u=>Ne(s===null?u:Object.assign(u,s)),n,a=e,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return e===null?n=(...u)=>i(new t(...wf(h(u)))):r===null?n=(...u)=>i(new t(e,...wf(h(u)))):(r=Ne(r),n=(...u)=>i(new t(e,...wf(h(u)),r))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var ece=class extends yr{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,inputNodes:r}=this,s=t.getNodeProperties(e),i=e.namespace&&e.namespace===t.namespace?t.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(e.layout){let a=MN.get(t.constructor);a===void 0&&(a=new WeakMap,MN.set(t.constructor,a));let o=a.get(e);o===void 0&&(o=Ne(t.buildFunctionNode(e)),a.set(e,o)),t.addInclude(o),n=Ne(o.call(r))}else{let a=e.jsFunc,o=r!==null||a.length>1?a(r||[],t):a(t);n=Ne(o)}return e.once&&(s[i]=n),n}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),r=t.getOutputNamespace();return e[r]=e[r]||this.setupOutput(t),e[r]}build(t,e=null){let r=null,s=t.getBuildStage(),i=t.getNodeProperties(this),n=t.getOutputNamespace(),a=this.getOutputNode(t);if(s==="setup"){let o=t.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(t),i[n].build(t)),r=i[n]}else s==="analyze"?a.build(t,e):s==="generate"&&(r=a.build(t,e)||"");return r}},tce=class extends yr{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(t){return this.layout=t,this}call(t=null){return fy(t),Ne(new ece(this,t))}setup(){return this.call()}};const rce=[!1,!0],sce=[0,1,2,3],ice=[-1,-2],AI=[.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],YT=new Map;for(let t of rce)YT.set(t,new Fa(t));const ZT=new Map;for(let t of sce)ZT.set(t,new Fa(t,"uint"));const JT=new Map([...ZT].map(t=>new Fa(t.value,"int")));for(let t of ice)JT.set(t,new Fa(t,"int"));const py=new Map([...JT].map(t=>new Fa(t.value)));for(let t of AI)py.set(t,new Fa(t));for(let t of AI)py.set(-t,new Fa(-t));const my={bool:YT,uint:ZT,ints:JT,float:py},_N=new Map([...YT,...py]),Jb=(t,e)=>_N.has(t)?_N.get(t):t.isNode===!0?t:new Fa(t,e),nce=t=>{try{return t.getNodeType()}catch{return}},xr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(i=>typeof i!="object"))&&(r=[SI(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return Ne(e.get(r[0]));if(r.length===1){let i=Jb(r[0],t);return nce(i)===t?Ne(i):Ne(new MI(i,t))}let s=r.map(i=>Jb(i));return Ne(new Ohe(s,t))}},ace=t=>t==null?null:t.nodeType||t.convertTo||(typeof t=="string"?t:null);function oce(t,e){return new Proxy(new tce(t,e),NI)}const Ne=(t,e=null)=>Zhe(t,e),fy=(t,e=null)=>new Jhe(t,e),wf=(t,e=null)=>new Qhe(t,e),ue=(...t)=>new Khe(...t);let lce=0;const Ei=(t,e=null)=>{let r=null;e!==null&&(typeof e=="object"?r=e.return:(typeof e=="string"?r=e:console.error("THREE.TSL: Invalid layout type."),e=null));let s=new oce(t,r),i=(...n)=>{let a;fy(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return r==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),e!==null){if(typeof e.inputs!="object"){let n={name:"fn"+lce++,type:r,inputs:[]};for(let a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}i.setLayout(e)}return i};function uce(t){return t}H("toStack",uce);const hce=new xr("color"),zn=new xr("float",my.float),Pd=new xr("int",my.ints),cce=new xr("uint",my.uint),dce=new xr("bool",my.bool),CI=new xr("vec2"),pce=new xr("ivec2"),mce=new xr("uvec2"),fce=new xr("bvec2"),Wh=new xr("vec3"),gce=new xr("ivec3"),yce=new xr("uvec3"),xce=new xr("bvec3"),vl=new xr("vec4"),bce=new xr("ivec4"),vce=new xr("uvec4"),Tce=new xr("bvec4"),wce=new xr("mat2"),RI=new xr("mat3"),Sce=new xr("mat4");H("toColor",hce),H("toFloat",zn),H("toInt",Pd),H("toUint",cce),H("toBool",dce),H("toVec2",CI),H("toIVec2",pce),H("toUVec2",mce),H("toBVec2",fce),H("toVec3",Wh),H("toIVec3",gce),H("toUVec3",yce),H("toBVec3",xce),H("toVec4",vl),H("toIVec4",bce),H("toUVec4",vce),H("toBVec4",Tce),H("toMat2",wce),H("toMat3",RI),H("toMat4",Sce);const Mce=ue(qT).setParameterLength(2),_ce=(t,e)=>Ne(new MI(Ne(t),e));H("element",Mce),H("convert",_ce),H("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),t));const Nce={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var nr=class Qb extends ti{static get type(){return"OperatorNode"}constructor(e,r,s,...i){if(super(),i.length>0){let n=new Qb(e,r,s);for(let a=0;a<i.length-1;a++)n=new Qb(e,n,i[a]);r=n,s=i[i.length-1]}this.op=e,this.aNode=r,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,r){return e.getMethod(Nce[this.op],r)}getNodeType(e){let r=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(e),a=i?i.getNodeType(e):null;if(n==="void"||a==="void")return"void";if(r==="%")return n;if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return e.getIntegerType(n);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){let o=Math.max(e.getTypeLength(n),e.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(e.isMatrix(n)){if(a==="float")return n;if(e.isVector(a))return e.getVectorFromMatrix(n);if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if(n==="float")return a;if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}}generate(e,r){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(e),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(e),l=n?n.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=e.changeComponentType(l,"uint")):s==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):o=e.isMatrix(l)?o==="float"?"float":e.isVector(o)?e.getVectorFromMatrix(l):l=a:l=a);let h=i.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(s);if(r!=="void"){let d=e.renderer.coordinateSystem===ll;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,r)}( ${h}, ${u} )`,a,r):e.format(`( ${h} ${s} ${u} )`,a,r);if(s==="%")return e.isInteger(l)?e.format(`( ${h} % ${u} )`,a,r):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${u} )`,a,r);if(s==="!"||s==="~")return e.format(`(${s}${h})`,o,r);if(c)return e.format(`${c}( ${h}, ${u} )`,a,r);if(e.isMatrix(o)&&l==="float")return e.format(`( ${u} ${s} ${h} )`,a,r);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${s} ${u}`,a,r);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,a,r)}}else if(o!=="void")return c?e.format(`${c}( ${h}, ${u} )`,a,r):e.isMatrix(o)&&l==="float"?e.format(`${u} ${s} ${h}`,a,r):e.format(`${h} ${s} ${u}`,a,r)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const EI=ue(nr,"+").setParameterLength(2,1/0).setName("add"),Kb=ue(nr,"-").setParameterLength(2,1/0).setName("sub"),QT=ue(nr,"*").setParameterLength(2,1/0).setName("mul"),PI=ue(nr,"/").setParameterLength(2,1/0).setName("div"),gy=ue(nr,"%").setParameterLength(2).setName("mod"),FI=ue(nr,"==").setParameterLength(2).setName("equal"),Ace=ue(nr,"!=").setParameterLength(2).setName("notEqual"),Cce=ue(nr,"<").setParameterLength(2).setName("lessThan"),Rce=ue(nr,">").setParameterLength(2).setName("greaterThan"),Ece=ue(nr,"<=").setParameterLength(2).setName("lessThanEqual"),Pce=ue(nr,">=").setParameterLength(2).setName("greaterThanEqual"),Fce=ue(nr,"&&").setParameterLength(2,1/0).setName("and"),Lce=ue(nr,"||").setParameterLength(2,1/0).setName("or"),Ice=ue(nr,"!").setParameterLength(1).setName("not"),zce=ue(nr,"^^").setParameterLength(2).setName("xor"),Bce=ue(nr,"&").setParameterLength(2).setName("bitAnd"),Vce=ue(nr,"~").setParameterLength(2).setName("bitNot"),Oce=ue(nr,"|").setParameterLength(2).setName("bitOr"),kce=ue(nr,"^").setParameterLength(2).setName("bitXor"),Uce=ue(nr,"<<").setParameterLength(2).setName("shiftLeft"),Dce=ue(nr,">>").setParameterLength(2).setName("shiftRight"),$ce=Ei(([t])=>(t.addAssign(1),t)),Gce=Ei(([t])=>(t.subAssign(1),t)),jce=Ei(([t])=>{let e=Pd(t).toConst();return t.addAssign(1),e}),Wce=Ei(([t])=>{let e=Pd(t).toConst();return t.subAssign(1),e});H("add",EI),H("sub",Kb),H("mul",QT),H("div",PI),H("mod",gy),H("equal",FI),H("notEqual",Ace),H("lessThan",Cce),H("greaterThan",Rce),H("lessThanEqual",Ece),H("greaterThanEqual",Pce),H("and",Fce),H("or",Lce),H("not",Ice),H("xor",zce),H("bitAnd",Bce),H("bitNot",Vce),H("bitOr",Oce),H("bitXor",kce),H("shiftLeft",Uce),H("shiftRight",Dce),H("incrementBefore",$ce),H("decrementBefore",Gce),H("increment",jce),H("decrement",Wce);const Hce=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),gy(t,e)),qce=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),gy(Pd(t),Pd(e)));H("remainder",Hce),H("modInt",qce);var U=class Mt extends ti{static get type(){return"MathNode"}constructor(e,r,s=null,i=null){if(super(),(e===Mt.MAX||e===Mt.MIN)&&arguments.length>3){let n=new Mt(e,r,s);for(let a=2;a<arguments.length-1;a++)n=new Mt(e,n,arguments[a]);r=n,s=arguments[arguments.length-1],i=null}this.method=e,this.aNode=r,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(e){let r=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(i)?0:e.getTypeLength(i);return n>a&&n>o?r:a>o?s:o>n?i:r}getNodeType(e){let r=this.method;return r===Mt.LENGTH||r===Mt.DISTANCE||r===Mt.DOT?"float":r===Mt.CROSS?"vec3":r===Mt.ALL||r===Mt.ANY?"bool":r===Mt.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:r,bNode:s,method:i}=this,n=null;if(i===Mt.ONE_MINUS)n=Kb(1,r);else if(i===Mt.RECIPROCAL)n=PI(1,r);else if(i===Mt.DIFFERENCE)n=KT(Kb(r,s));else if(i===Mt.TRANSFORM_DIRECTION){let a=r,o=s;e.isMatrix(a.getNodeType(e))?o=vl(Wh(o),0):a=vl(Wh(a),0);let l=QT(a,o).xyz;n=LI(l)}return n===null?super.setup(e):n}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let i=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(i===Mt.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{let c=[];return i===Mt.CROSS?c.push(o.build(e,n),l.build(e,n)):u===ll&&i===Mt.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===ll&&(i===Mt.MIN||i===Mt.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):i===Mt.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):i===Mt.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Hb&&i===Mt.ATAN&&l!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===Mt.DFDX||i===Mt.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${e.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(e,a)),l!==null&&c.push(l.build(e,a)),h!==null&&c.push(h.build(e,a))),e.format(`${e.getMethod(i,n)}( ${c.join(", ")} )`,n,r)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};U.ALL="all",U.ANY="any",U.RADIANS="radians",U.DEGREES="degrees",U.EXP="exp",U.EXP2="exp2",U.LOG="log",U.LOG2="log2",U.SQRT="sqrt",U.INVERSE_SQRT="inversesqrt",U.FLOOR="floor",U.CEIL="ceil",U.NORMALIZE="normalize",U.FRACT="fract",U.SIN="sin",U.COS="cos",U.TAN="tan",U.ASIN="asin",U.ACOS="acos",U.ATAN="atan",U.ABS="abs",U.SIGN="sign",U.LENGTH="length",U.NEGATE="negate",U.ONE_MINUS="oneMinus",U.DFDX="dFdx",U.DFDY="dFdy",U.ROUND="round",U.RECIPROCAL="reciprocal",U.TRUNC="trunc",U.FWIDTH="fwidth",U.TRANSPOSE="transpose",U.BITCAST="bitcast",U.EQUALS="equals",U.MIN="min",U.MAX="max",U.STEP="step",U.REFLECT="reflect",U.DISTANCE="distance",U.DIFFERENCE="difference",U.DOT="dot",U.CROSS="cross",U.POW="pow",U.TRANSFORM_DIRECTION="transformDirection",U.MIX="mix",U.CLAMP="clamp",U.REFRACT="refract",U.SMOOTHSTEP="smoothstep",U.FACEFORWARD="faceforward";const Xce=zn(Math.PI);zn(Math.PI*2);const Yce=ue(U,U.ALL).setParameterLength(1),Zce=ue(U,U.ANY).setParameterLength(1),Jce=ue(U,U.RADIANS).setParameterLength(1),Qce=ue(U,U.DEGREES).setParameterLength(1),Kce=ue(U,U.EXP).setParameterLength(1),ede=ue(U,U.EXP2).setParameterLength(1),tde=ue(U,U.LOG).setParameterLength(1),rde=ue(U,U.LOG2).setParameterLength(1),sde=ue(U,U.SQRT).setParameterLength(1),ide=ue(U,U.INVERSE_SQRT).setParameterLength(1),nde=ue(U,U.FLOOR).setParameterLength(1),ade=ue(U,U.CEIL).setParameterLength(1),LI=ue(U,U.NORMALIZE).setParameterLength(1),II=ue(U,U.FRACT).setParameterLength(1),zI=ue(U,U.SIN).setParameterLength(1),ode=ue(U,U.COS).setParameterLength(1),lde=ue(U,U.TAN).setParameterLength(1),ude=ue(U,U.ASIN).setParameterLength(1),hde=ue(U,U.ACOS).setParameterLength(1),BI=ue(U,U.ATAN).setParameterLength(1,2),KT=ue(U,U.ABS).setParameterLength(1),VI=ue(U,U.SIGN).setParameterLength(1),cde=ue(U,U.LENGTH).setParameterLength(1),dde=ue(U,U.NEGATE).setParameterLength(1),pde=ue(U,U.ONE_MINUS).setParameterLength(1),mde=ue(U,U.DFDX).setParameterLength(1),fde=ue(U,U.DFDY).setParameterLength(1),gde=ue(U,U.ROUND).setParameterLength(1),yde=ue(U,U.RECIPROCAL).setParameterLength(1),xde=ue(U,U.TRUNC).setParameterLength(1),bde=ue(U,U.FWIDTH).setParameterLength(1),vde=ue(U,U.TRANSPOSE).setParameterLength(1),Tde=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),FI(t,e)),wde=ue(U,U.MIN).setParameterLength(2,1/0),Sde=ue(U,U.MAX).setParameterLength(2,1/0),Mde=ue(U,U.STEP).setParameterLength(2),_de=ue(U,U.REFLECT).setParameterLength(2),Nde=ue(U,U.DISTANCE).setParameterLength(2),Ade=ue(U,U.DIFFERENCE).setParameterLength(2),bp=ue(U,U.DOT).setParameterLength(2),Cde=ue(U,U.CROSS).setParameterLength(2),OI=ue(U,U.POW).setParameterLength(2),Rde=ue(U,U.POW,2).setParameterLength(1),Ede=ue(U,U.POW,3).setParameterLength(1),Pde=ue(U,U.POW,4).setParameterLength(1),Fde=ue(U,U.TRANSFORM_DIRECTION).setParameterLength(2),Lde=t=>QT(VI(t),OI(KT(t),1/3)),Ide=t=>bp(t,t),yy=ue(U,U.MIX).setParameterLength(3),kI=(t,e=0,r=1)=>Ne(new U(U.CLAMP,Ne(t),Ne(e),Ne(r))),zde=t=>kI(t),Bde=ue(U,U.REFRACT).setParameterLength(3),Vde=ue(U,U.SMOOTHSTEP).setParameterLength(3),Ode=ue(U,U.FACEFORWARD).setParameterLength(3),kde=Ei(([t])=>{let e=12.9898,r=78.233,s=43758.5453,i=bp(t.xy,CI(e,r)),n=gy(i,Xce);return II(zI(n).mul(s))}),Ude=(t,e,r)=>yy(e,r,t),Dde=(t,e,r)=>Vde(e,r,t),$de=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),BI(t,e));H("all",Yce),H("any",Zce),H("equals",Tde),H("radians",Jce),H("degrees",Qce),H("exp",Kce),H("exp2",ede),H("log",tde),H("log2",rde),H("sqrt",sde),H("inverseSqrt",ide),H("floor",nde),H("ceil",ade),H("normalize",LI),H("fract",II),H("sin",zI),H("cos",ode),H("tan",lde),H("asin",ude),H("acos",hde),H("atan",BI),H("abs",KT),H("sign",VI),H("length",cde),H("lengthSq",Ide),H("negate",dde),H("oneMinus",pde),H("dFdx",mde),H("dFdy",fde),H("round",gde),H("reciprocal",yde),H("trunc",xde),H("fwidth",bde),H("atan2",$de),H("min",wde),H("max",Sde),H("step",Mde),H("reflect",_de),H("distance",Nde),H("dot",bp),H("cross",Cde),H("pow",OI),H("pow2",Rde),H("pow3",Ede),H("pow4",Pde),H("transformDirection",Fde),H("mix",Ude),H("clamp",kI),H("refract",Bde),H("smoothstep",Dde),H("faceForward",Ode),H("difference",Ade),H("saturate",zde),H("cbrt",Lde),H("transpose",vde),H("rand",kde);var NN=class extends ti{static get type(){return"ArrayNode"}constructor(t,e,r=null){super(t),this.count=e,this.values=r,this.isArrayNode=!0}getNodeType(t){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(t)),this.nodeType}getElementType(t){return this.getNodeType(t)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}};const Gde=(...t)=>{let e;if(t.length===1){let r=t[0];e=new NN(null,r.length,r)}else{let r=t[0],s=t[1];e=new NN(r,s)}return Ne(e)};H("toArray",(t,e)=>Gde(Array(e).fill(t)));var UI=class extends yr{static get type(){return"UniformGroupNode"}constructor(t,e=!1,r=1){super("string"),this.name=t,this.shared=e,this.order=r,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}};const jde=t=>new UI(t),Wde=(t,e=0)=>new UI(t,!0,e),Hde=Wde("render"),qde=jde("object");var Xde=class extends XT{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=qde}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){let r=this.getSelf();return t=t.bind(r),super.onUpdate(s=>{let i=t(s,r);i!==void 0&&(this.value=i)},e)}generate(t,e){let r=this.getNodeType(t),s=this.getUniformHash(t),i=t.getNodeFromHash(s);i===void 0&&(t.setHashNode(this,s),i=this);let n=i.getInputType(t),a=t.getUniformFromNode(i,n,t.shaderStage,this.name||t.context.label),o=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(o,r,e)}};const Yde=(t,e)=>{let r=ace(e||t),s=t;return Ne(new Xde(s,r))};var Zde=class extends yr{static get type(){return"PropertyNode"}constructor(t,e=null,r=!1){super(t),this.name=e,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}};const Jde=(t,e)=>Ne(new Zde(t,e));var Qde=class extends ti{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e==="void"?"void":this.targetNode.getNodeType(t)}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let r=t.getTypeLength(e.node.getNodeType(t));return yp.join("").slice(0,r)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:r}=this,s=t.getNodeProperties(this);s.sourceNode=r,s.targetNode=e.context({assign:!0})}generate(t,e){let{targetNode:r,sourceNode:s}=t.getNodeProperties(this),i=this.needsSplitAssign(t),n=r.getNodeType(t),a=r.build(t),o=s.build(t,n),l=s.getNodeType(t),h=t.getDataFromNode(this),u;if(h.initialized===!0)e!=="void"&&(u=a);else if(i){let c=t.getVarFromNode(this,null,n),d=t.getPropertyName(c);t.addLineFlowCode(`${d} = ${o}`,this);let p=r.node,m=p.node.context({assign:!0}),f=m.build(t);for(let g=0;g<p.components.length;g++){let b=p.components[g];t.addLineFlowCode(`${f}.${b} = ${d}[ ${g} ]`,this)}e!=="void"&&(u=a)}else u=`${a} = ${o}`,(e==="void"||l==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=a));return h.initialized=!0,t.format(u,n,e)}};const Kde=ue(Qde).setParameterLength(2);H("assign",Kde);var epe=class extends ti{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){let e=[],r=this.functionNode,s=r.getInputs(t),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(t):o.build(t,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(zn(0));for(let o=0;o<i.length;o++)e.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),e.push(n(zn(0),o))):e.push(n(l,o))}return`${r.build(t,"property")}( ${e.join(", ")} )`}};const tpe=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?wf(e):fy(e[0]),Ne(new epe(Ne(t),e)));H("call",tpe);var rpe=class extends yr{static get type(){return"ConditionalNode"}constructor(t,e,r=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=r}getNodeType(t){let{ifNode:e,elseNode:r}=t.getNodeProperties(this);if(e===void 0)return this.setup(t),this.getNodeType(t);let s=e.getNodeType(t);if(r!==null){let i=r.getNodeType(t);if(t.getTypeLength(i)>t.getTypeLength(s))return i}return s}setup(t){let e=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=t.context.nodeBlock;t.getDataFromNode(r).parentNodeBlock=i,s!==null&&(t.getDataFromNode(s).parentNodeBlock=i);let n=t.getNodeProperties(this);n.condNode=e,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(t,e){let r=this.getNodeType(t),s=t.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?Jde(r).build(t):"";s.nodeProperty=h;let u=i.build(t,"bool");t.addFlowCode(`
490
+ */x.BRDF_GGX;x.BRDF_Lambert;x.BasicShadowFilter;x.Break;x.Continue;x.DFGApprox;x.D_GGX;x.Discard;x.EPSILON;x.F_Schlick;x.Fn;x.INFINITY;x.If;x.Switch;x.Loop;x.NodeShaderStage;x.NodeType;x.NodeUpdateType;x.NodeAccess;x.PCFShadowFilter;x.PCFSoftShadowFilter;x.PI;x.PI2;x.Return;x.Schlick_to_F0;x.ScriptableNodeResources;x.ShaderNode;x.TBNViewMatrix;x.VSMShadowFilter;x.V_GGX_SmithCorrelated;x.abs;x.acesFilmicToneMapping;x.acos;x.add;x.addNodeElement;x.agxToneMapping;x.all;x.alphaT;x.and;x.anisotropy;x.anisotropyB;x.anisotropyT;x.any;x.append;x.array;x.arrayBuffer;x.asin;x.assign;x.atan;x.atan2;x.atomicAdd;x.atomicAnd;x.atomicFunc;x.atomicMax;x.atomicMin;x.atomicOr;x.atomicStore;x.atomicSub;x.atomicXor;x.atomicLoad;x.attenuationColor;x.attenuationDistance;x.attribute;x.attributeArray;x.backgroundBlurriness;x.backgroundIntensity;x.backgroundRotation;x.batch;x.billboarding;x.bitAnd;x.bitNot;x.bitOr;x.bitXor;x.bitangentGeometry;x.bitangentLocal;x.bitangentView;x.bitangentWorld;x.bitcast;x.blendBurn;x.blendColor;x.blendDodge;x.blendOverlay;x.blendScreen;x.blur;x.bool;x.buffer;x.bufferAttribute;x.bumpMap;x.burn;x.bvec2;x.bvec3;x.bvec4;x.bypass;x.cache;x.call;x.cameraFar;x.cameraIndex;x.cameraNear;x.cameraNormalMatrix;x.cameraPosition;x.cameraProjectionMatrix;x.cameraProjectionMatrixInverse;x.cameraViewMatrix;x.cameraWorldMatrix;x.cbrt;x.cdl;x.ceil;x.checker;x.cineonToneMapping;x.clamp;x.clearcoat;x.clearcoatRoughness;x.code;x.color;x.colorSpaceToWorking;x.colorToDirection;x.compute;x.computeSkinning;x.cond;x.Const;x.context;x.convert;x.convertColorSpace;x.convertToTexture;x.cos;x.cross;x.cubeTexture;x.dFdx;x.dFdy;x.dashSize;x.debug;x.decrement;x.decrementBefore;x.defaultBuildStages;x.defaultShaderStages;x.defined;x.degrees;x.deltaTime;x.densityFog;x.densityFogFactor;x.depth;x.depthPass;x.difference;x.diffuseColor;x.directPointLight;x.directionToColor;x.dispersion;x.distance;x.div;x.dodge;x.dot;x.drawIndex;x.dynamicBufferAttribute;x.element;x.emissive;x.equal;x.equals;x.equirectUV;x.exp;x.exp2;x.expression;x.faceDirection;x.faceForward;x.faceforward;x.float;x.floor;x.fog;x.fract;x.frameGroup;x.frameId;x.frontFacing;x.fwidth;x.gain;x.gapSize;x.getConstNodeType;x.getCurrentStack;x.getDirection;x.getDistanceAttenuation;x.getGeometryRoughness;x.getNormalFromDepth;x.getParallaxCorrectNormal;x.getRoughness;x.getScreenPosition;x.getShIrradianceAt;x.getTextureIndex;x.getViewPosition;x.getShadowMaterial;x.getShadowRenderObjectFunction;x.glsl;x.glslFn;x.grayscale;x.greaterThan;x.greaterThanEqual;x.hash;x.highpModelNormalViewMatrix;x.highpModelViewMatrix;x.hue;x.increment;x.incrementBefore;x.instance;x.instanceIndex;x.instancedArray;x.instancedBufferAttribute;x.instancedDynamicBufferAttribute;x.instancedMesh;x.int;x.inverseSqrt;x.inversesqrt;x.invocationLocalIndex;x.invocationSubgroupIndex;x.ior;x.iridescence;x.iridescenceIOR;x.iridescenceThickness;x.ivec2;x.ivec3;x.ivec4;x.js;x.label;x.length;x.lengthSq;x.lessThan;x.lessThanEqual;x.lightPosition;x.lightShadowMatrix;x.lightTargetDirection;x.lightTargetPosition;x.lightViewPosition;x.lightingContext;x.lights;x.linearDepth;x.linearToneMapping;x.localId;x.globalId;x.log;x.log2;x.logarithmicDepthToViewZ;x.loop;x.luminance;x.mediumpModelViewMatrix;x.mat2;x.mat3;x.mat4;x.matcapUV;x.materialAO;x.materialAlphaTest;x.materialAnisotropy;x.materialAnisotropyVector;x.materialAttenuationColor;x.materialAttenuationDistance;x.materialClearcoat;x.materialClearcoatNormal;x.materialClearcoatRoughness;x.materialColor;x.materialDispersion;x.materialEmissive;x.materialIOR;x.materialIridescence;x.materialIridescenceIOR;x.materialIridescenceThickness;x.materialLightMap;x.materialLineDashOffset;x.materialLineDashSize;x.materialLineGapSize;x.materialLineScale;x.materialLineWidth;x.materialMetalness;x.materialNormal;x.materialOpacity;x.materialPointSize;x.materialReference;x.materialReflectivity;x.materialRefractionRatio;x.materialRotation;x.materialRoughness;x.materialSheen;x.materialSheenRoughness;x.materialShininess;x.materialSpecular;x.materialSpecularColor;x.materialSpecularIntensity;x.materialSpecularStrength;x.materialThickness;x.materialTransmission;x.max;x.maxMipLevel;x.metalness;x.min;x.mix;x.mixElement;x.mod;x.modInt;x.modelDirection;x.modelNormalMatrix;x.modelPosition;x.modelRadius;x.modelScale;x.modelViewMatrix;x.modelViewPosition;x.modelViewProjection;x.modelWorldMatrix;x.modelWorldMatrixInverse;x.morphReference;x.mrt;x.mul;x.mx_aastep;x.mx_cell_noise_float;x.mx_contrast;x.mx_fractal_noise_float;x.mx_fractal_noise_vec2;x.mx_fractal_noise_vec3;x.mx_fractal_noise_vec4;x.mx_hsvtorgb;x.mx_noise_float;x.mx_noise_vec3;x.mx_noise_vec4;x.mx_ramplr;x.mx_ramptb;x.mx_rgbtohsv;x.mx_safepower;x.mx_splitlr;x.mx_splittb;x.mx_srgb_texture_to_lin_rec709;x.mx_transform_uv;x.mx_worley_noise_float;x.mx_worley_noise_vec2;x.mx_worley_noise_vec3;x.namespace;x.negate;x.neutralToneMapping;x.nodeArray;x.nodeImmutable;x.nodeObject;x.nodeObjects;x.nodeProxy;x.normalFlat;x.normalGeometry;x.normalLocal;x.normalMap;x.normalView;x.normalWorld;x.normalize;x.not;x.notEqual;x.numWorkgroups;x.objectDirection;x.objectGroup;x.objectPosition;x.objectRadius;x.objectScale;x.objectViewPosition;x.objectWorldMatrix;x.oneMinus;x.or;x.orthographicDepthToViewZ;x.oscSawtooth;x.oscSine;x.oscSquare;x.oscTriangle;x.output;x.outputStruct;x.overlay;x.overloadingFn;x.parabola;x.parallaxDirection;x.parallaxUV;x.parameter;x.pass;x.passTexture;x.pcurve;x.perspectiveDepthToViewZ;x.pmremTexture;x.pointUV;x.pointWidth;x.positionGeometry;x.positionLocal;x.positionPrevious;x.positionView;x.positionViewDirection;x.positionWorld;x.positionWorldDirection;x.posterize;x.pow;x.pow2;x.pow3;x.pow4;x.premult;x.property;x.radians;x.rand;x.range;x.rangeFog;x.rangeFogFactor;x.reciprocal;x.lightProjectionUV;x.reference;x.referenceBuffer;x.reflect;x.reflectVector;x.reflectView;x.reflector;x.refract;x.refractVector;x.refractView;x.reinhardToneMapping;x.remainder;x.remap;x.remapClamp;x.renderGroup;x.renderOutput;x.rendererReference;x.rotate;x.rotateUV;x.roughness;x.round;x.rtt;x.sRGBTransferEOTF;x.sRGBTransferOETF;x.sampler;x.samplerComparison;x.saturate;x.saturation;x.screen;x.screenCoordinate;x.screenSize;x.screenUV;x.scriptable;x.scriptableValue;x.select;x.setCurrentStack;x.shaderStages;x.shadow;x.pointShadow;x.shadowPositionWorld;x.sharedUniformGroup;x.shapeCircle;x.sheen;x.sheenRoughness;x.shiftLeft;x.shiftRight;x.shininess;x.sign;x.sin;x.sinc;x.skinning;x.smoothstep;x.smoothstepElement;x.specularColor;x.specularF90;x.spherizeUV;x.split;x.spritesheetUV;x.sqrt;x.stack;x.step;x.storage;x.storageBarrier;x.storageObject;x.storageTexture;x.string;x.struct;x.sub;x.subgroupIndex;x.subgroupSize;x.tan;x.tangentGeometry;x.tangentLocal;x.tangentView;x.tangentWorld;x.temp;x.texture;x.texture3D;x.textureBarrier;x.textureBicubic;x.textureCubeUV;x.textureLoad;x.textureSize;x.textureStore;x.thickness;x.time;x.timerDelta;x.timerGlobal;x.timerLocal;x.toneMapping;x.toneMappingExposure;x.toonOutlinePass;x.transformDirection;x.transformNormal;x.transformNormalToView;x.transformedBentNormalView;x.transformedBitangentView;x.transformedBitangentWorld;x.transformedClearcoatNormalView;x.transformedNormalView;x.transformedNormalWorld;x.transformedTangentView;x.transformedTangentWorld;x.transmission;x.transpose;x.triNoise3D;x.triplanarTexture;x.triplanarTextures;x.trunc;x.tslFn;x.uint;x.uniform;x.uniformCubeTexture;x.uniformArray;x.uniformGroup;x.uniformTexture;x.uniforms;x.unpremult;x.userData;x.uv;x.uvec2;x.uvec3;x.uvec4;x.Var;x.varying;x.varyingProperty;x.vec2;x.vec3;const Uoe=x.vec4;x.vectorComponents;x.velocity;x.vertexColor;x.vertexIndex;x.vibrance;x.viewZToLogarithmicDepth;x.viewZToOrthographicDepth;x.viewZToPerspectiveDepth;x.viewport;x.viewportBottomLeft;x.viewportCoordinate;x.viewportDepthTexture;x.viewportLinearDepth;x.viewportMipTexture;x.viewportResolution;x.viewportSafeUV;x.viewportSharedTexture;x.viewportSize;x.viewportTexture;x.viewportTopLeft;x.viewportUV;x.wgsl;x.wgslFn;x.workgroupArray;x.workgroupBarrier;x.workgroupId;x.workingToColorSpace;x.xor;const Ee=L.createContext(null),Doe=({children:t,hideNotice:e=!1,style:r={},className:s="",...i})=>{const n=L.useRef(null),a=L.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=L.useRef(null);o.current===null&&(o.current=pQ());const l=L.useMemo(()=>(g,b,v,w,T=null)=>{if(b===null){try{o.current.removeNode(g)}catch(N){console.warn("Error removing node:",N)}return}try{o.current.registerNode(g,b,v,w,T)}catch(N){console.error("Error registering node:",N,{id:g,parentId:v,metadata:w})}},[]),h=L.useMemo(()=>(g,b,v)=>{try{o.current.updateUniformValue(g,b,v)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=L.useMemo(()=>(g,b)=>{try{o.current.updateNodeMetadata(g,b)}catch(v){console.warn("Error updating metadata:",v)}},[]),c=L.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=L.useRef(!1),p=L.useRef(!1),m=L.useRef(!1);L.useEffect(()=>{if(d.current||p.current)return;const g=n.current;if(!g)return;p.current=!0;const b=o.current;return b.initialize({canvas:g}).then(()=>{b.registerNode(a,({childNode:v})=>v||Uoe(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,e||b.showLicenseWarning()}).catch(v=>{console.error("[Shader] Initialization failed:",v),p.current=!1}),()=>{if(!m.current){m.current=!0;try{b.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(v){console.warn("[Shader] Error during cleanup:",v)}}}},[a,e]);const f={...s===""?{width:"1200px",height:"800px"}:{},...typeof r=="object"?r:{}};return wt.jsx(Ee.Provider,{value:c,children:wt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof r=="object"?r:{}},className:s,...i,children:[wt.jsx("canvas",{"data-renderer":"ombre",ref:n,style:f}),t]})})};function $oe(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const ML={blendMode:"normal"};try{rh&&rh.props&&Object.entries(rh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(ML[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Goe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${rh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>$oe(t,ML),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(rh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,rh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})};var m_=function(t){function e(n){"@babel/helpers - typeof";return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e(n)}function r(n,a){if(e(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var l=o.call(n,a);if(e(l)!="object")return l;throw TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function s(n){var a=r(n,"string");return e(a)=="symbol"?a:a+""}function i(n,a,o){return(a=s(a))in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o,n}return t.defineProperty=i,t}({}),qa,Om;function It(t,e){let r=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(a=>[a]));let s=e[0].length,i=e[0].map((a,o)=>e.map(l=>l[o])),n=t.map(a=>i.map(o=>{let l=0;if(!Array.isArray(a)){for(let h of o)l+=a*h;return l}for(let h=0;h<a.length;h++)l+=a[h]*(o[h]||0);return l}));return r===1&&(n=n[0]),s===1?n.map(a=>a[0]):n}function pp(t){return bo(t)==="string"}function bo(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function hg(t,{precision:e,unit:r}){return So(t)?"none":_L(t,e)+(r??"")}function So(t){return Number.isNaN(t)||t instanceof Number&&t?.none}function mr(t){return So(t)?0:t}function _L(t,e){if(t===0)return 0;let r=~~t,s=0;r&&e&&(s=~~Math.log10(Math.abs(r))+1);let i=10**(e-s);return Math.floor(t*i+.5)/i}const joe={deg:1,grad:.9,rad:180/Math.PI,turn:360};function NL(t){if(!t)return;t=t.trim();let e=/^([a-z]+)\((.+?)\)$/i,r=/^-?[\d.]+$/,s=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,n=t.match(e);if(n){let a=[];return n[2].replace(i,(o,l)=>{let h=l.match(s),u=l;if(h){let c=h[0],d=u.slice(0,-c.length);c==="%"?(u=new Number(d/100),u.type="<percentage>"):(u=new Number(d*joe[c]),u.type="<angle>",u.unit=c)}else r.test(u)?(u=new Number(u),u.type="<number>"):u==="none"&&(u=new Number(NaN),u.none=!0);o.startsWith("/")&&(u=u instanceof Number?u:new Number(u),u.alpha=!0),typeof u=="object"&&u instanceof Number&&(u.raw=l),a.push(u)}),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:a}}}function AL(t){return t[t.length-1]}function Cd(t,e,r){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*r}function CL(t,e,r){return(r-t)/(e-t)}function VT(t,e,r){return Cd(e[0],e[1],CL(t[0],t[1],r))}function RL(t){return t.map(e=>e.split("|").map(r=>{r=r.trim();let s=r.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(s){let i=new String(s[1]);return i.range=[+s[2],+s[3]],i}return r}))}function EL(t,e,r){return Math.max(Math.min(r,e),t)}function hy(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function gn(t,e){return hy(Math.abs(t)**e,t)}function OT(t,e){return e===0?0:t/e}function PL(t,e,r=0,s=t.length){for(;r<s;){let i=r+s>>1;t[i]<e?r=i+1:s=i}return r}var Woe=Object.freeze({__proto__:null,bisectLeft:PL,clamp:EL,copySign:hy,interpolate:Cd,interpolateInv:CL,isNone:So,isString:pp,last:AL,mapRange:VT,multiplyMatrices:It,parseCoordGrammar:RL,parseFunction:NL,serializeNumber:hg,skipNone:mr,spow:gn,toPrecision:_L,type:bo,zdiv:OT}),Hoe=class{add(e,r,s){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(i){this[i]=this[i]||[],r&&this[i][s?"unshift":"push"](r)},this)}run(e,r){this[e]=this[e]||[],this[e].forEach(function(s){s.call(r&&r.context?r.context:r,r)})}};const Mo=new Hoe;var ei={gamut_mapping:"css",precision:5,deltaE:"76",verbose:((qa=globalThis)==null||(qa=qa.process)==null||(qa=qa.env)==null||(qa=qa.NODE_ENV)==null?void 0:qa.toLowerCase())!=="test",warn:function(t){var e,r;this.verbose&&((e=globalThis)==null||(e=e.console)==null||(r=e.warn)==null||r.call(e,t))}};const fs={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function Bb(t){return Array.isArray(t)?t:fs[t]}function cg(t,e,r,s={}){if(t=Bb(t),e=Bb(e),!t||!e)throw TypeError(`Missing white point to convert ${t?"":"from"}${!t&&!e?"/":""}${e?"":"to"}`);if(t===e)return r;let i={W1:t,W2:e,XYZ:r,options:s};if(Mo.run("chromatic-adaptation-start",i),i.M||(i.W1===fs.D65&&i.W2===fs.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===fs.D50&&i.W2===fs.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Mo.run("chromatic-adaptation-end",i),i.M)return It(i.M,i.XYZ);throw TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const qoe=new Set(["<number>","<percentage>","<angle>"]);function f_(t,e,r,s){return Object.entries(t.coords).map(([n,a],o)=>{let l=e.coordGrammar[o],h=s[o],u=h?.type,c;if(c=h.none?l.find(m=>qoe.has(m)):l.find(m=>m==u),!c){let m=a.name||n;throw TypeError(`${u??h.raw} not allowed for ${m} in ${r}()`)}let d=c.range;u==="<percentage>"&&(d||(d=[0,1]));let p=a.range||a.refRange;return d&&p&&(s[o]=VT(d,p,s[o])),c})}function FL(t,{meta:e}={}){let r={str:String(t)?.trim()};if(Mo.run("parse-start",r),r.color)return r.color;if(r.parsed=NL(r.str),r.parsed){let i=r.parsed.name;if(i==="color"){let n=r.parsed.args.shift(),a=n.startsWith("--")?n.substring(2):`--${n}`,o=[n,a],l=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let c of _e.all){let d=c.getFormat("color");if(d&&(o.includes(d.id)||d.ids?.filter(p=>o.includes(p)).length)){let p=Object.keys(c.coords).map((f,g)=>r.parsed.args[g]||0),m;return d.coordGrammar&&(m=f_(c,d,"color",p)),e&&Object.assign(e,{formatId:"color",types:m}),d.id.startsWith("--")&&!n.startsWith("--")&&ei.warn(`${c.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${d.id}) instead of color(${n}).`),n.startsWith("--")&&!d.id.startsWith("--")&&ei.warn(`${c.name} is a standard space and supported in the CSS spec. Use color(${d.id}) instead of prefixed color(${n}).`),{spaceId:c.id,coords:p,alpha:l}}}let h="",u=n in _e.registry?n:a;if(u in _e.registry){var s;let c=(s=_e.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;c&&(h=`Did you mean color(${c})?`)}throw TypeError(`Cannot parse color(${n}). `+(h||"Missing a plugin?"))}else for(let n of _e.all){let a=n.getFormat(i);if(a&&a.type==="function"){let o=1;(a.lastAlpha||AL(r.parsed.args).alpha)&&(o=r.parsed.args.pop());let l=r.parsed.args,h;return a.coordGrammar&&(h=f_(n,a,i,l)),e&&Object.assign(e,{formatId:a.name,types:h}),{spaceId:n.id,coords:l,alpha:o}}}}else for(let i of _e.all)for(let n in i.formats){let a=i.formats[n];if(a.type!=="custom"||a.test&&!a.test(r.str))continue;let o=a.parse(r.str);if(o)return o.alpha??(o.alpha=1),e&&(e.formatId=n),o}throw TypeError(`Could not parse ${t} as a color. Missing a plugin?`)}function ke(t){if(Array.isArray(t))return t.map(ke);if(!t)throw TypeError("Empty color reference");pp(t)&&(t=FL(t));let e=t.space||t.spaceId;return e instanceof _e||(t.space=_e.get(e)),t.alpha===void 0&&(t.alpha=1),t}const Xoe=75e-6;var _e=(Om=class $i{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?$i.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let r=e.coords??this.base.coords;for(let i in r)"name"in r[i]||(r[i].name=i);this.coords=r;let s=e.white??this.base.white??"D65";for(let i in this.white=Bb(s),this.formats=e.formats??{},this.formats){let n=this.formats[i];n.type||(n.type="function"),n.name||(n.name=i)}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace=e.gamutSpace==="self"?this:$i.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(i,n)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:Yoe(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Mo.run("colorspace-init-end",this)}inGamut(e,{epsilon:r=Xoe}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:r});let s=Object.values(this.coords);return e.every((i,n)=>{let a=s[n];if(a.type!=="angle"&&a.range){if(Number.isNaN(i))return!0;let[o,l]=a.range;return(o===void 0||i>=o-r)&&(l===void 0||i<=l+r)}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=g_(e,this),e;let r;return r=e==="default"?Object.values(this.formats)[0]:this.formats[e],r?(r=g_(r,this),r):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(e,r){if(arguments.length===1){let o=ke(e);[e,r]=[o.space,o.coords]}if(e=$i.get(e),this.equals(e))return r;r=r.map(o=>Number.isNaN(o)?0:o);let s=this.path,i=e.path,n,a;for(let o=0;o<s.length&&s[o].equals(i[o]);o++)n=s[o],a=o;if(!n)throw Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let o=s.length-1;o>a;o--)r=s[o].toBase(r);for(let o=a+1;o<i.length;o++)r=i[o].fromBase(r);return r}from(e,r){if(arguments.length===1){let s=ke(e);[e,r]=[s.space,s.coords]}return e=$i.get(e),e.to(this,r)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let r in this.coords){let s=this.coords[r],i=s.range||s.refRange;e.push(i?.min??0)}return e}static get all(){return[...new Set(Object.values($i.registry))]}static register(e,r){if(arguments.length===1&&(r=arguments[0],e=r.id),r=this.get(r),this.registry[e]&&this.registry[e]!==r)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=r,arguments.length===1&&r.aliases)for(let s of r.aliases)this.register(s,r);return r}static get(e,...r){if(!e||e instanceof $i)return e;if(bo(e)==="string"){let i=$i.registry[e.toLowerCase()];if(!i)throw TypeError(`No color space found with id = "${e}"`);return i}if(r.length)return $i.get(...r);throw TypeError(`${e} is not a valid color space`)}static resolveCoord(e,r){let s=bo(e),i,n;if(s==="string"?e.includes(".")?[i,n]=e.split("."):[i,n]=[,e]:Array.isArray(e)?[i,n]=e:(i=e.space,n=e.coordId),i=$i.get(i),i||(i=r),!i)throw TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(s=bo(n),s==="number"||s==="string"&&n>=0){let l=Object.entries(i.coords)[n];if(l)return{space:i,id:l[0],index:n,...l[1]}}i=$i.get(i);let a=n.toLowerCase(),o=0;for(let l in i.coords){let h=i.coords[l];if(l.toLowerCase()===a||h.name?.toLowerCase()===a)return{space:i,id:l,index:o,...h};o++}throw TypeError(`No "${n}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(", ")}`)}},m_.defineProperty(Om,"registry",{}),m_.defineProperty(Om,"DEFAULT_FORMAT",{type:"functions",name:"color"}),Om);function Yoe(t){let e=[t];for(let r=t;r=r.base;)e.push(r);return e}function g_(t,{coords:e}={}){if(t.coords&&!t.coordGrammar){t.type||(t.type="function"),t.name||(t.name="color"),t.coordGrammar=RL(t.coords);let r=Object.entries(e).map(([s,i],n)=>{let a=t.coordGrammar[n][0],o=i.range||i.refRange,l=a.range,h="";return a=="<percentage>"?(l=[0,100],h="%"):a=="<angle>"&&(h="deg"),{fromRange:o,toRange:l,suffix:h}});t.serializeCoords=(s,i)=>s.map((n,a)=>{let{fromRange:o,toRange:l,suffix:h}=r[a];return o&&l&&(n=VT(o,l,n)),n=hg(n,{precision:i,unit:h}),n})}return t}var $r=new _e({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"]}),Ps=class extends _e{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=$r),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??(e.toBase=r=>{let s=It(e.toXYZ_M,r);return this.white!==this.base.white&&(s=cg(this.white,this.base.white,s)),s}),e.fromBase??(e.fromBase=r=>(r=cg(this.base.white,this.white,r),It(e.fromXYZ_M,r)))),e.referred??(e.referred="display"),super(e)}};function mp(t,e){return t=ke(t),!e||t.space.equals(e)?t.coords.slice():(e=_e.get(e),e.from(t))}function Ys(t,e){t=ke(t);let{space:r,index:s}=_e.resolveCoord(e,t.space);return mp(t,r)[s]}function kT(t,e,r){return t=ke(t),e=_e.get(e),t.coords=e.to(t.space,r),t}kT.returns="color";function Aa(t,e,r){if(t=ke(t),arguments.length===2&&bo(arguments[1])==="object"){let s=arguments[1];for(let i in s)Aa(t,i,s[i])}else{typeof r=="function"&&(r=r(Ys(t,e)));let{space:s,index:i}=_e.resolveCoord(e,t.space),n=mp(t,s);n[i]=r,kT(t,s,n)}return t}Aa.returns="color";var UT=new _e({id:"xyz-d50",name:"XYZ D50",white:"D50",base:$r,fromBase:t=>cg($r.white,"D50",t),toBase:t=>cg("D50",$r.white,t)});const Zoe=216/24389,y_=24/116,km=24389/27;let h0=fs.D50;var Zs=new _e({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:h0,base:UT,fromBase(t){let e=t.map((s,i)=>s/h0[i]),r=e.map(s=>s>Zoe?Math.cbrt(s):(km*s+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>y_?e[0]**3:(116*e[0]-16)/km,t[0]>8?((t[0]+16)/116)**3:t[0]/km,e[2]>y_?e[2]**3:(116*e[2]-16)/km].map((s,i)=>s*h0[i])},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Un(t){return(t%360+360)%360}function Joe(t,e){if(t==="raw")return e;let[r,s]=e.map(Un),i=s-r;return t==="increasing"?i<0&&(s+=360):t==="decreasing"?i>0&&(r+=360):t==="longer"?-180<i&&i<180&&(i>0?r+=360:s+=360):t==="shorter"&&(i>180?r+=360:i<-180&&(s+=360)),[r,s]}var Rd=new _e({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:Zs,fromBase(t){let[e,r,s]=t,i,n=.02;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t;return r<0&&(r=0),isNaN(s)&&(s=0),[e,r*Math.cos(s*Math.PI/180),r*Math.sin(s*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const x_=25**7,dg=Math.PI,b_=180/dg,Mu=dg/180;function v_(t){let e=t*t;return e*e*e*t}function LL(t,e,{kL:r=1,kC:s=1,kH:i=1}={}){[t,e]=ke([t,e]);let[n,a,o]=Zs.from(t),l=Rd.from(Zs,[n,a,o])[1],[h,u,c]=Zs.from(e),d=Rd.from(Zs,[h,u,c])[1];l<0&&(l=0),d<0&&(d=0);let p=(l+d)/2,m=v_(p),f=.5*(1-Math.sqrt(m/(m+x_))),g=(1+f)*a,b=(1+f)*u,v=Math.sqrt(g**2+o**2),w=Math.sqrt(b**2+c**2),T=g===0&&o===0?0:Math.atan2(o,g),N=b===0&&c===0?0:Math.atan2(c,b);T<0&&(T+=2*dg),N<0&&(N+=2*dg),T*=b_,N*=b_;let S=h-n,_=w-v,A=N-T,D=T+N,K=Math.abs(A),J;v*w===0?J=0:K<=180?J=A:A>180?J=A-360:A<-180?J=A+360:ei.warn("the unthinkable has happened");let re=2*Math.sqrt(w*v)*Math.sin(J*Mu/2),te=(n+h)/2,oe=(v+w)/2,ae=v_(oe),ge;ge=v*w===0?D:K<=180?D/2:D<360?(D+360)/2:(D-360)/2;let fe=(te-50)**2,ve=1+.015*fe/Math.sqrt(20+fe),me=1+.045*oe,he=1;he-=.17*Math.cos((ge-30)*Mu),he+=.24*Math.cos(2*ge*Mu),he+=.32*Math.cos((3*ge+6)*Mu),he-=.2*Math.cos((4*ge-63)*Mu);let Te=1+.015*oe*he,Ge=30*Math.exp(-1*((ge-275)/25)**2),He=2*Math.sqrt(ae/(ae+x_)),ft=-1*Math.sin(2*Ge*Mu)*He,ht=(S/(r*ve))**2;return ht+=(_/(s*me))**2,ht+=(re/(i*Te))**2,ht+=ft*(_/(s*me))*(re/(i*Te)),Math.sqrt(ht)}const Qoe=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],Koe=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],ele=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],tle=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var Dh=new _e({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:$r,fromBase(t){let e=It(Qoe,t),r=e.map(s=>Math.cbrt(s));return It(ele,r)},toBase(t){let e=It(tle,t),r=e.map(s=>s**3);return It(Koe,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Vb(t,e){[t,e]=ke([t,e]);let[r,s,i]=Dh.from(t),[n,a,o]=Dh.from(e),l=r-n,h=s-a,u=i-o;return Math.sqrt(l**2+h**2+u**2)}const rle=75e-6;function bl(t,e,{epsilon:r=rle}={}){t=ke(t),e||(e=t.space),e=_e.get(e);let s=t.coords;return e!==t.space&&(s=e.from(t)),e.inGamut(s,{epsilon:r})}function $h(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}function IL(t,e,r="lab"){r=_e.get(r);let s=r.from(t),i=r.from(e);return Math.sqrt(s.reduce((n,a,o)=>{let l=i[o];return isNaN(a)||isNaN(l)?n:n+(l-a)**2},0))}function sle(t,e){return IL(t,e,"lab")}const ile=Math.PI,T_=ile/180;function nle(t,e,{l:r=2,c:s=1}={}){[t,e]=ke([t,e]);let[i,n,a]=Zs.from(t),[,o,l]=Rd.from(Zs,[i,n,a]),[h,u,c]=Zs.from(e),d=Rd.from(Zs,[h,u,c])[1];o<0&&(o=0),d<0&&(d=0);let p=i-h,m=o-d,f=n-u,g=a-c,b=f**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let w=.0638*o/(1+.0131*o)+.638,T;Number.isNaN(l)&&(l=0),T=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*T_)):.36+Math.abs(.4*Math.cos((l+35)*T_));let N=o**4,S=Math.sqrt(N/(N+1900)),_=w*(S*T+1-S),A=(p/(r*v))**2;return A+=(m/(s*w))**2,A+=b/_**2,Math.sqrt(A)}const w_=203;var DT=new _e({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:$r,fromBase(t){return t.map(e=>Math.max(e*w_,0))},toBase(t){return t.map(e=>Math.max(e/w_,0))}});const Um=1.15,Dm=.66,S_=2610/2**14,ale=2**14/2610,M_=3424/2**12,__=2413/2**7,N_=2392/2**7,ole=1.7*2523/2**5,A_=2**5/(1.7*2523),$m=-.56,c0=16295499532821565e-27,lle=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],ule=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],hle=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],cle=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var zL=new _e({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:DT,fromBase(t){let[e,r,s]=t,i=Um*e-(Um-1)*s,n=Dm*r-(Dm-1)*e,a=It(lle,[i,n,s]),o=a.map(function(d){let p=M_+__*(d/1e4)**S_,m=1+N_*(d/1e4)**S_;return(p/m)**ole}),[l,h,u]=It(hle,o);return[(1+$m)*l/(1+$m*l)-c0,h,u]},toBase(t){let[e,r,s]=t,i=(e+c0)/(1+$m-$m*(e+c0)),n=It(cle,[i,r,s]),a=n.map(function(d){let p=M_-d**A_,m=N_*d**A_-__;return 1e4*(p/m)**ale}),[o,l,h]=It(ule,a),u=(o+(Um-1)*h)/Um,c=(l+(Dm-1)*u)/Dm;return[u,c,h]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),Ob=new _e({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:zL,fromBase(t){let[e,r,s]=t,i,n=2e-4;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]}});function dle(t,e){[t,e]=ke([t,e]);let[r,s,i]=Ob.from(t),[n,a,o]=Ob.from(e),l=r-n,h=s-a;Number.isNaN(i)&&Number.isNaN(o)?(i=0,o=0):Number.isNaN(i)?i=o:Number.isNaN(o)&&(o=i);let u=i-o,c=2*Math.sqrt(s*a)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(l**2+h**2+c**2)}const BL=3424/4096,VL=2413/128,OL=2392/128,C_=2610/16384,ple=2523/32,mle=16384/2610,R_=32/2523,fle=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],gle=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],yle=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],xle=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var kb=new _e({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:DT,fromBase(t){let e=It(fle,t);return ble(e)},toBase(t){let e=vle(t);return It(xle,e)}});function ble(t){let e=t.map(function(r){let s=BL+VL*(r/1e4)**C_,i=1+OL*(r/1e4)**C_;return(s/i)**ple});return It(gle,e)}function vle(t){return It(yle,t).map(function(s){let i=Math.max(s**R_-BL,0),n=VL-OL*s**R_;return 1e4*(i/n)**mle})}function Tle(t,e){[t,e]=ke([t,e]);let[r,s,i]=kb.from(t),[n,a,o]=kb.from(e);return 720*Math.sqrt((r-n)**2+.25*(s-a)**2+(i-o)**2)}const wle=fs.D65,kL=.42,E_=1/kL,d0=2*Math.PI,UL=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Sle=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Mle=[[460,451,288],[460,-891,-261],[460,-220,-6300]],_le={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},il={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Nle=180/Math.PI,P_=Math.PI/180;function DL(t,e){return t.map(s=>{let i=gn(e*Math.abs(s)*.01,kL);return 400*hy(i,s)/(i+27.13)})}function Ale(t,e){let r=100/e*27.13**E_;return t.map(s=>{let i=Math.abs(s);return hy(r*gn(i/(400-i),E_),s)})}function Cle(t){let e=Un(t);e<=il.h[0]&&(e+=360);let r=PL(il.h,e)-1,[s,i]=il.h.slice(r,r+2),[n,a]=il.e.slice(r,r+2),o=il.H[r],l=(e-s)/n;return o+100*l/(l+(i-e)/a)}function Rle(t){let e=(t%400+400)%400,r=Math.floor(.01*e);e%=100;let[s,i]=il.h.slice(r,r+2),[n,a]=il.e.slice(r,r+2);return Un((e*(a*s-n*i)-100*s*a)/(e*(a-n)-100*a))}function $L(t,e,r,s,i){let n={};n.discounting=i,n.refWhite=t,n.surround=s;let a=t.map(f=>f*100);n.la=e,n.yb=r;let o=a[1],l=It(UL,a);s=_le[n.surround];let h=s[0];n.c=s[1],n.nc=s[2];let u=1/(5*n.la+1),c=u**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;let d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=l.map(f=>Cd(1,o/f,d)),n.dRgbInv=n.dRgb.map(f=>1/f);let p=l.map((f,g)=>f*n.dRgb[g]),m=DL(p,n.fl);return n.aW=n.nbb*(2*m[0]+m[1]+.05*m[2]),n}const F_=$L(wle,64/Math.PI*.2,20,"average",!1);function Ub(t,e){if(!(t.J!==void 0^t.Q!==void 0))throw Error("Conversion requires one and only one: 'J' or 'Q'");if(!(t.C!==void 0^t.M!==void 0^t.s!==void 0))throw Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(t.h!==void 0^t.H!==void 0))throw Error("Conversion requires one and only one: 'h' or 'H'");if(t.J===0||t.Q===0)return[0,0,0];let r=0;r=t.h===void 0?Rle(t.H)*P_:Un(t.h)*P_;let s=Math.cos(r),i=Math.sin(r),n=0;t.J===void 0?t.Q!==void 0&&(n=.25*e.c*t.Q/((e.aW+4)*e.flRoot)):n=gn(t.J,1/2)*.1;let a=0;t.C===void 0?t.M===void 0?t.s!==void 0&&(a=4e-4*t.s**2*(e.aW+4)/e.c):a=t.M/e.flRoot/n:a=t.C/n;let o=gn(a*(1.64-.29**e.n)**-.73,10/9),l=.25*(Math.cos(r+2)+3.8),h=e.aW*gn(n,2/e.c/e.z),u=5e4/13*e.nc*e.ncb*l,c=h/e.nbb,d=23*(c+.305)*OT(o,23*u+o*(11*s+108*i)),p=d*s,m=d*i,f=Ale(It(Mle,[c,p,m]).map(g=>g*1/1403),e.fl);return It(Sle,f.map((g,b)=>g*e.dRgbInv[b])).map(g=>g/100)}function GL(t,e){let r=t.map(w=>w*100),s=DL(It(UL,r).map((w,T)=>w*e.dRgb[T]),e.fl),i=s[0]+(-12*s[1]+s[2])/11,n=(s[0]+s[1]-2*s[2])/9,a=(Math.atan2(n,i)%d0+d0)%d0,o=.25*(Math.cos(a+2)+3.8),l=5e4/13*e.nc*e.ncb*OT(o*Math.sqrt(i**2+n**2),s[0]+s[1]+1.05*s[2]+.305),h=gn(l,.9)*(1.64-.29**e.n)**.73,u=e.nbb*(2*s[0]+s[1]+.05*s[2]),c=gn(u/e.aW,.5*e.c*e.z),d=100*gn(c,2),p=4/e.c*c*(e.aW+4)*e.flRoot,m=h*c,f=m*e.flRoot,g=Un(a*Nle),b=Cle(g),v=50*gn(e.c*h/(e.aW+4),1/2);return{J:d,C:m,h:g,s:v,Q:p,M:f,H:b}}var Ele=new _e({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:$r,fromBase(t){let e=GL(t,F_);return[e.J,e.M,e.h]},toBase(t){return Ub({J:t[0],M:t[1],h:t[2]},F_)}});const Ple=fs.D65,Fle=216/24389,jL=24389/27;function Lle(t){return 116*(t>Fle?Math.cbrt(t):(jL*t+16)/116)-16}function Db(t){return t>8?((t+16)/116)**3:t/jL}function Ile(t,e){let[r,s,i]=t,n=[],a=0;if(i===0)return[0,0,0];let o=Db(i);a=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let l=2e-12,h=15,u=0,c=1/0;for(;u<=h;){n=Ub({J:a,C:s,h:r},e);let d=Math.abs(n[1]-o);if(d<c){if(d<=l)return n;c=d}a-=(n[1]-o)*a/(2*n[1]),u+=1}return Ub({J:a,C:s,h:r},e)}function zle(t,e){let r=Lle(t[1]);if(r===0)return[0,0,0];let s=GL(t,$T);return[Un(s.h),s.C,r]}const $T=$L(Ple,200/Math.PI*Db(50),Db(50)*100,"average",!1);var Ed=new _e({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:$r,fromBase(t){return zle(t)},toBase(t){return Ile(t,$T)},formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Ble=Math.PI/180,L_=[1,.007,.0228];function I_(t){t[1]<0&&(t=Ed.fromBase(Ed.toBase(t)));let e=Math.log(Math.max(1+L_[2]*t[1]*$T.flRoot,1))/L_[2],r=t[0]*Ble,s=e*Math.cos(r),i=e*Math.sin(r);return[t[2],s,i]}function Vle(t,e){[t,e]=ke([t,e]);let[r,s,i]=I_(Ed.from(t)),[n,a,o]=I_(Ed.from(e));return Math.sqrt((r-n)**2+(s-a)**2+(i-o)**2)}var Gh={deltaE76:sle,deltaECMC:nle,deltaE2000:LL,deltaEJz:dle,deltaEITP:Tle,deltaEOK:Vb,deltaEHCT:Vle};function Ole(t){let e=t?Math.floor(Math.log10(Math.abs(t))):0;return Math.max(parseFloat(`1e${e-2}`),1e-6)}const z_={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 _o(t,{method:e=ei.gamut_mapping,space:r=void 0,deltaEMethod:s="",jnd:i=2,blackWhiteClamp:n={}}={}){if(t=ke(t),pp(arguments[1])?r=arguments[1]:r||(r=t.space),r=_e.get(r),bl(t,r,{epsilon:0}))return t;let a;if(e==="css")a=kle(t,{space:r});else{if(e!=="clip"&&!bl(t,r)){Object.prototype.hasOwnProperty.call(z_,e)&&({method:e,jnd:i,deltaEMethod:s,blackWhiteClamp:n}=z_[e]);let o=LL;if(s!==""){for(let h in Gh)if("deltae"+s.toLowerCase()===h.toLowerCase()){o=Gh[h];break}}let l=_o(Lt(t,r),{method:"clip",space:r});if(o(t,l)>i){if(Object.keys(n).length===3){let v=_e.resolveCoord(n.channel),w=Ys(Lt(t,v.space),v.id);if(So(w)&&(w=0),w>=n.max)return Lt({space:"xyz-d65",coords:fs.D65},t.space);if(w<=n.min)return Lt({space:"xyz-d65",coords:[0,0,0]},t.space)}let h=_e.resolveCoord(e),u=h.space,c=h.id,d=Lt(t,u);d.coords.forEach((v,w)=>{So(v)&&(d.coords[w]=0)});let p=h.range||h.refRange,m=p[0],f=Ole(i),g=m,b=Ys(d,c);for(;b-g>f;){let v=$h(d);v=_o(v,{space:r,method:"clip"}),o(d,v)-i<f?g=Ys(d,c):b=Ys(d,c),Aa(d,c,(g+b)/2)}a=Lt(d,r)}else a=l}else a=Lt(t,r);if(e==="clip"||!bl(a,r,{epsilon:0})){let o=Object.values(r.coords).map(l=>l.range||[]);a.coords=a.coords.map((l,h)=>{let[u,c]=o[h];return u!==void 0&&(l=Math.max(u,l)),c!==void 0&&(l=Math.min(l,c)),l})}}return r!==t.space&&(a=Lt(a,t.space)),t.coords=a.coords,t}_o.returns="color";const B_={WHITE:{space:Dh,coords:[1,0,0]},BLACK:{space:Dh,coords:[0,0,0]}};function kle(t,{space:e}={}){let r=.02,s=1e-4;t=ke(t),e||(e=t.space),e=_e.get(e);let i=_e.get("oklch");if(e.isUnbounded)return Lt(t,e);let n=Lt(t,i),a=n.coords[0];if(a>=1){let m=Lt(B_.WHITE,e);return m.alpha=t.alpha,Lt(m,e)}if(a<=0){let m=Lt(B_.BLACK,e);return m.alpha=t.alpha,Lt(m,e)}if(bl(n,e,{epsilon:0}))return Lt(n,e);function o(m){let f=Lt(m,e),g=Object.values(e.coords);return f.coords=f.coords.map((b,v)=>{if("range"in g[v]){let[w,T]=g[v].range;return EL(w,b,T)}return b}),f}let l=0,h=n.coords[1],u=!0,c=$h(n),d=o(c),p=Vb(d,c);if(p<r)return d;for(;h-l>s;){let m=(l+h)/2;if(c.coords[1]=m,u&&bl(c,e,{epsilon:0}))l=m;else if(d=o(c),p=Vb(d,c),p<r){if(r-p<s)break;u=!1,l=m}else h=m}return d}function Lt(t,e,{inGamut:r}={}){t=ke(t),e=_e.get(e);let s=e.from(t),i={space:e,coords:s,alpha:t.alpha};return r&&(i=_o(i,r===!0?void 0:r)),i}Lt.returns="color";function ad(t,{precision:e=ei.precision,format:r="default",inGamut:s=!0,...i}={}){let n;t=ke(t);let a=r;r=t.space.getFormat(r)??t.space.getFormat("default")??_e.DEFAULT_FORMAT;let o=t.coords.slice();if(s||(s=r.toGamut),s&&!bl(t)&&(o=_o($h(t),s===!0?void 0:s).coords),r.type==="custom")if(i.precision=e,r.serialize)n=r.serialize(o,t.alpha,i);else throw TypeError(`format ${a} can only be used to parse colors, not for serialization`);else{let l=r.name||"color";r.serializeCoords?o=r.serializeCoords(o,e):e!==null&&(o=o.map(d=>hg(d,{precision:e})));let h=[...o];if(l==="color"){let d=r.id||r.ids?.[0]||t.space.id;h.unshift(d)}let u=t.alpha;e!==null&&(u=hg(u,{precision:e}));let c=t.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${u}`;n=`${l}(${h.join(r.commas?", ":" ")}${c})`}return n}const Ule=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],Dle=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var cy=new Ps({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:Ule,fromXYZ_M:Dle});const Gm=1.09929682680944,V_=.018053968510807;var WL=new Ps({id:"rec2020",name:"REC.2020",base:cy,toBase(t){return t.map(function(e){return e<V_*4.5?e/4.5:((e+Gm-1)/Gm)**(1/.45)})},fromBase(t){return t.map(function(e){return e>=V_?Gm*e**.45-(Gm-1):4.5*e})}});const $le=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],Gle=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var HL=new Ps({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:$le,fromXYZ_M:Gle});const jle=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],Nr=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var qL=new Ps({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:jle,fromXYZ_M:Nr}),O_={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 k_=[,,,].fill("<percentage> | <number>[0, 255]"),U_=[,,,].fill("<number>[0, 255]");var jh=new Ps({id:"srgb",name:"sRGB",base:qL,fromBase:t=>t.map(e=>{let r=e<0?-1:1,s=e*r;return s>.0031308?r*(1.055*s**(1/2.4)-.055):12.92*e}),toBase:t=>t.map(e=>{let r=e<0?-1:1,s=e*r;return s<=.04045?e/12.92:r*((s+.055)/1.055)**2.4}),formats:{rgb:{coords:k_},rgb_number:{name:"rgb",commas:!0,coords:U_,noAlpha:!0},color:{},rgba:{coords:k_,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:U_},hex:{type:"custom",toGamut:!0,test:t=>/^#([a-f0-9]{3,4}){1,2}$/i.test(t),parse(t){t.length<=5&&(t=t.replace(/[a-f0-9]/gi,"$&$&"));let e=[];return t.replace(/[a-f0-9]{2}/gi,r=>{e.push(parseInt(r,16)/255)}),{spaceId:"srgb",coords:e.slice(0,3),alpha:e.slice(3)[0]}},serialize:(t,e,{collapse:r=!0}={})=>{e<1&&t.push(e),t=t.map(n=>Math.round(n*255));let s=r&&t.every(n=>n%17==0);return"#"+t.map(n=>s?(n/17).toString(16):n.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:t=>/^[a-z]+$/i.test(t),parse(t){t=t.toLowerCase();let e={spaceId:"srgb",coords:null,alpha:1};if(t==="transparent"?(e.coords=O_.black,e.alpha=0):e.coords=O_[t],e.coords)return e}}}}),XL=new Ps({id:"p3",cssId:"display-p3",name:"P3",base:HL,fromBase:jh.fromBase,toBase:jh.toBase});ei.display_space=jh;let Wle;if(typeof CSS<"u"&&CSS.supports)for(let t of[Zs,WL,XL]){let e=t.getMinCoords(),r={space:t,coords:e,alpha:1},s=ad(r);if(CSS.supports("color",s)){ei.display_space=t;break}}function Hle(t,{space:e=ei.display_space,...r}={}){let s=ad(t,r);if(typeof CSS>"u"||CSS.supports("color",s)||!ei.display_space)s=new String(s),s.color=t;else{let i=t;if((t.coords.some(So)||So(t.alpha))&&!(Wle??(Wle=CSS.supports("color","hsl(none 50% 50%)")))&&(i=$h(t),i.coords=i.coords.map(mr),i.alpha=mr(i.alpha),s=ad(i,r),CSS.supports("color",s)))return s=new String(s),s.color=i,s;i=Lt(i,e),s=new String(ad(i,r)),s.color=i}return s}function qle(t,e){return t=ke(t),e=ke(e),t.space===e.space&&t.alpha===e.alpha&&t.coords.every((r,s)=>r===e.coords[s])}function No(t){return Ys(t,[$r,"y"])}function YL(t,e){Aa(t,[$r,"y"],e)}function Xle(t){Object.defineProperty(t.prototype,"luminance",{get(){return No(this)},set(e){YL(this,e)}})}var Yle=Object.freeze({__proto__:null,getLuminance:No,register:Xle,setLuminance:YL});function Zle(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);return s>r&&([r,s]=[s,r]),(r+.05)/(s+.05)}const Jle=.56,Qle=.57,Kle=.62,eue=.65,D_=.022,tue=1.414,rue=.1,sue=5e-4,iue=1.14,$_=.027,nue=1.14;function G_(t){return t>=D_?t:t+(D_-t)**tue}function _u(t){let e=t<0?-1:1,r=Math.abs(t);return e*r**2.4}function aue(t,e){e=ke(e),t=ke(t);let r,s,i,n,a,o;e=Lt(e,"srgb"),[n,a,o]=e.coords;let l=_u(n)*.2126729+_u(a)*.7151522+_u(o)*.072175;t=Lt(t,"srgb"),[n,a,o]=t.coords;let h=_u(n)*.2126729+_u(a)*.7151522+_u(o)*.072175,u=G_(l),c=G_(h),d=c>u;return Math.abs(c-u)<sue?s=0:d?(r=c**Jle-u**Qle,s=r*iue):(r=c**eue-u**Kle,s=r*nue),i=Math.abs(s)<rue?0:s>0?s-$_:s+$_,i*100}function oue(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);s>r&&([r,s]=[s,r]);let i=r+s;return i===0?0:(r-s)/i}const lue=5e4;function uue(t,e){t=ke(t),e=ke(e);let r=Math.max(No(t),0),s=Math.max(No(e),0);return s>r&&([r,s]=[s,r]),s===0?lue:(r-s)/s}function hue(t,e){t=ke(t),e=ke(e);let r=Ys(t,[Zs,"l"]),s=Ys(e,[Zs,"l"]);return Math.abs(r-s)}const cue=216/24389,j_=24/116,jm=24389/27;let p0=fs.D65;var $b=new _e({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:p0,base:$r,fromBase(t){let e=t.map((s,i)=>s/p0[i]),r=e.map(s=>s>cue?Math.cbrt(s):(jm*s+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>j_?e[0]**3:(116*e[0]-16)/jm,t[0]>8?((t[0]+16)/116)**3:t[0]/jm,e[2]>j_?e[2]**3:(116*e[2]-16)/jm].map((s,i)=>s*p0[i])},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const due=5**.5*.5+.5;function pue(t,e){t=ke(t),e=ke(e);let r=Ys(t,[$b,"l"]),s=Ys(e,[$b,"l"]),i=Math.abs(r**1.618033988749895-s**1.618033988749895),n=i**(1/due)*Math.SQRT2-40;return n<7.5?0:n}var vf=Object.freeze({__proto__:null,contrastAPCA:aue,contrastDeltaPhi:pue,contrastLstar:hue,contrastMichelson:oue,contrastWCAG21:Zle,contrastWeber:uue});function mue(t,e,r={}){pp(r)&&(r={algorithm:r});let{algorithm:s,...i}=r;if(!s){let n=Object.keys(vf).map(a=>a.replace(/^contrast/,"")).join(", ");throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${n}`)}for(let n in t=ke(t),e=ke(e),vf)if("contrast"+s.toLowerCase()===n.toLowerCase())return vf[n](t,e,i);throw TypeError(`Unknown contrast algorithm: ${s}`)}function dy(t){let[e,r,s]=mp(t,$r),i=e+15*r+3*s;return[4*e/i,9*r/i]}function ZL(t){let[e,r,s]=mp(t,$r),i=e+r+s;return[e/i,r/i]}function fue(t){Object.defineProperty(t.prototype,"uv",{get(){return dy(this)}}),Object.defineProperty(t.prototype,"xy",{get(){return ZL(this)}})}var gue=Object.freeze({__proto__:null,register:fue,uv:dy,xy:ZL});function jc(t,e,r={}){pp(r)&&(r={method:r});let{method:s=ei.deltaE,...i}=r;for(let n in Gh)if("deltae"+s.toLowerCase()===n.toLowerCase())return Gh[n](t,e,i);throw TypeError(`Unknown deltaE method: ${s}`)}function yue(t,e=.25){let r=_e.get("oklch","lch");return Aa(t,[r,"l"],i=>i*(1+e))}function xue(t,e=.25){let r=_e.get("oklch","lch");return Aa(t,[r,"l"],i=>i*(1-e))}var bue=Object.freeze({__proto__:null,darken:xue,lighten:yue});function JL(t,e,r=.5,s={}){return[t,e]=[ke(t),ke(e)],bo(r)==="object"&&([r,s]=[.5,r]),fp(t,e,s)(r)}function QL(t,e,r={}){let s;GT(t)&&([s,r]=[t,e],[t,e]=s.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:n,steps:a=2,maxSteps:o=1e3,...l}=r;s||([t,e]=[ke(t),ke(e)],s=fp(t,e,l));let h=jc(t,e),u=i>0?Math.max(a,Math.ceil(h/i)+1):a,c=[];if(o!==void 0&&(u=Math.min(u,o)),u===1)c=[{p:.5,color:s(.5)}];else{let d=1/(u-1);c=Array.from({length:u},(p,m)=>{let f=m*d;return{p:f,color:s(f)}})}if(i>0){let d=c.reduce((p,m,f)=>{if(f===0)return 0;let g=jc(m.color,c[f-1].color,n);return Math.max(p,g)},0);for(;d>i;){d=0;for(let p=1;p<c.length&&c.length<o;p++){let m=c[p-1],f=c[p],g=(f.p+m.p)/2,b=s(g);d=Math.max(d,jc(b,m.color),jc(b,f.color)),c.splice(p,0,{p:g,color:s(g)}),p++}}}return c=c.map(d=>d.color),c}function fp(t,e,r={}){if(GT(t)){let[l,h]=[t,e];return fp(...l.rangeArgs.colors,{...l.rangeArgs.options,...h})}let{space:s,outputSpace:i,progression:n,premultiplied:a}=r;t=ke(t),e=ke(e),t=$h(t),e=$h(e);let o={colors:[t,e],options:r};if(s=s?_e.get(s):_e.registry[ei.interpolationSpace]||t.space,i=i?_e.get(i):s,t=Lt(t,s),e=Lt(e,s),t=_o(t),e=_o(e),s.coords.h&&s.coords.h.type==="angle"){let l=r.hue=r.hue||"shorter",h=[s,"h"],[u,c]=[Ys(t,h),Ys(e,h)];isNaN(u)&&!isNaN(c)?u=c:isNaN(c)&&!isNaN(u)&&(c=u),[u,c]=Joe(l,[u,c]),Aa(t,h,u),Aa(e,h,c)}return a&&(t.coords=t.coords.map(l=>l*t.alpha),e.coords=e.coords.map(l=>l*e.alpha)),Object.assign(l=>{l=n?n(l):l;let h=t.coords.map((d,p)=>{let m=e.coords[p];return Cd(d,m,l)}),u=Cd(t.alpha,e.alpha,l),c={space:s,coords:h,alpha:u};return a&&(c.coords=c.coords.map(d=>d/u)),i!==s&&(c=Lt(c,i)),c},{rangeArgs:o})}function GT(t){return bo(t)==="function"&&!!t.rangeArgs}ei.interpolationSpace="lab";function vue(t){t.defineFunction("mix",JL,{returns:"color"}),t.defineFunction("range",fp,{returns:"function<color>"}),t.defineFunction("steps",QL,{returns:"array<color>"})}var Tue=Object.freeze({__proto__:null,isRange:GT,mix:JL,range:fp,register:vue,steps:QL}),KL=new _e({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:jh,fromBase:t=>{let e=Math.max(...t),r=Math.min(...t),[s,i,n]=t,[a,o,l]=[NaN,0,(r+e)/2],h=e-r;if(h!==0){switch(o=l===0||l===1?0:(e-l)/Math.min(l,1-l),e){case s:a=(i-n)/h+(i<n?6:0);break;case i:a=(n-s)/h+2;break;case n:a=(s-i)/h+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,o*100,l*100]},toBase:t=>{let[e,r,s]=t;e%=360,e<0&&(e+=360),r/=100,s/=100;function i(n){let a=(n+e/30)%12,o=r*Math.min(s,1-s);return s-o*Math.max(-1,Math.min(a-3,9-a,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}}}),eI=new _e({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:KL,fromBase(t){let[e,r,s]=t;r/=100,s/=100;let i=s+r*Math.min(s,1-s);return[e,i===0?0:200*(1-s/i),100*i]},toBase(t){let[e,r,s]=t;r/=100,s/=100;let i=s*(1-r/2);return[e,i===0||i===1?0:(s-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),wue=new _e({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:eI,fromBase(t){let[e,r,s]=t;return[e,s*(100-r)/100,100-s]},toBase(t){let[e,r,s]=t;r/=100,s/=100;let i=r+s;if(i>=1){let o=r/i;return[e,0,o*100]}let n=1-s,a=n===0?0:1-r/n;return[e,a*100,n*100]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Sue=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],Mue=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var tI=new Ps({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:Sue,fromXYZ_M:Mue}),_ue=new Ps({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:tI,toBase:t=>t.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:t=>t.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const Nue=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],Aue=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var rI=new Ps({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:UT,toXYZ_M:Nue,fromXYZ_M:Aue});const Cue=1/512,Rue=16/512;var Eue=new Ps({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:rI,toBase(t){return t.map(e=>e<Rue?e/16:e**1.8)},fromBase(t){return t.map(e=>e>=Cue?e**(1/1.8):16*e)}}),Pue=new _e({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:Dh,fromBase(t){let[e,r,s]=t,i,n=2e-4;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t,i,n;return isNaN(s)?(i=0,n=0):(i=r*Math.cos(s*Math.PI/180),n=r*Math.sin(s*Math.PI/180)),[e,i,n]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let sI=fs.D65;const Fue=216/24389,W_=24389/27,[H_,q_]=dy({space:$r,coords:sI});var iI=new _e({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:sI,base:$r,fromBase(t){let e=[mr(t[0]),mr(t[1]),mr(t[2])],r=e[1],[s,i]=dy({space:$r,coords:e});if(!Number.isFinite(s)||!Number.isFinite(i))return[0,0,0];let n=r<=Fue?W_*r:116*Math.cbrt(r)-16;return[n,13*n*(s-H_),13*n*(i-q_)]},toBase(t){let[e,r,s]=t;if(e===0||So(e))return[0,0,0];r=mr(r),s=mr(s);let i=r/(13*e)+H_,n=s/(13*e)+q_,a=e<=8?e/W_:((e+16)/116)**3;return[a*(9*i/(4*n)),a,a*((12-3*i-20*n)/(4*n))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),jT=new _e({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:iI,fromBase(t){let[e,r,s]=t,i,n=.02;return i=Math.abs(r)<n&&Math.abs(s)<n?NaN:Math.atan2(s,r)*180/Math.PI,[e,Math.sqrt(r**2+s**2),Un(i)]},toBase(t){let[e,r,s]=t;return r<0&&(r=0),isNaN(s)&&(s=0),[e,r*Math.cos(s*Math.PI/180),r*Math.sin(s*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Lue=216/24389,Iue=24389/27,X_=Nr[0][0],Y_=Nr[0][1],m0=Nr[0][2],Z_=Nr[1][0],J_=Nr[1][1],f0=Nr[1][2],Q_=Nr[2][0],K_=Nr[2][1],g0=Nr[2][2];function Nu(t,e,r){let s=e/(Math.sin(r)-t*Math.cos(r));return s<0?1/0:s}function pg(t){let e=(t+16)**3/1560896,r=e>Lue?e:t/Iue,s=r*(284517*X_-94839*m0),i=r*(838422*m0+769860*Y_+731718*X_),n=r*(632260*m0-126452*Y_),a=r*(284517*Z_-94839*f0),o=r*(838422*f0+769860*J_+731718*Z_),l=r*(632260*f0-126452*J_),h=r*(284517*Q_-94839*g0),u=r*(838422*g0+769860*K_+731718*Q_),c=r*(632260*g0-126452*K_);return{r0s:s/n,r0i:i*t/n,r1s:s/(n+126452),r1i:(i-769860)*t/(n+126452),g0s:a/l,g0i:o*t/l,g1s:a/(l+126452),g1i:(o-769860)*t/(l+126452),b0s:h/c,b0i:u*t/c,b1s:h/(c+126452),b1i:(u-769860)*t/(c+126452)}}function eN(t,e){let r=e/360*Math.PI*2,s=Nu(t.r0s,t.r0i,r),i=Nu(t.r1s,t.r1i,r),n=Nu(t.g0s,t.g0i,r),a=Nu(t.g1s,t.g1i,r),o=Nu(t.b0s,t.b0i,r),l=Nu(t.b1s,t.b1i,r);return Math.min(s,i,n,a,o,l)}var zue=new _e({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:jT,gamutSpace:jh,fromBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(e>99.9999999)i=0,e=100;else if(e<1e-8)i=0,e=0;else{let n=pg(e),a=eN(n,s);i=r/a*100}return[s,i,e]},toBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=pg(s);i=eN(n,e)/100*r}return[s,i,e]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});Nr[0][0],Nr[0][1],Nr[0][2],Nr[1][0],Nr[1][1],Nr[1][2],Nr[2][0],Nr[2][1],Nr[2][2];function Au(t,e){return Math.abs(e)/Math.sqrt(t**2+1)}function tN(t){let e=Au(t.r0s,t.r0i),r=Au(t.r1s,t.r1i),s=Au(t.g0s,t.g0i),i=Au(t.g1s,t.g1i),n=Au(t.b0s,t.b0i),a=Au(t.b1s,t.b1i);return Math.min(e,r,s,i,n,a)}var Bue=new _e({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:jT,gamutSpace:"self",fromBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(e>99.9999999)i=0,e=100;else if(e<1e-8)i=0,e=0;else{let n=pg(e),a=tN(n);i=r/a*100}return[s,i,e]},toBase(t){let[e,r,s]=[mr(t[0]),mr(t[1]),mr(t[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=pg(s);i=tN(n)/100*r}return[s,i,e]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const rN=203,sN=2610/2**14,Vue=2**14/2610,Oue=2523/2**5,iN=2**5/2523,nN=3424/2**12,aN=2413/2**7,oN=2392/2**7;var kue=new Ps({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:cy,toBase(t){return t.map(function(e){return(Math.max(e**iN-nN,0)/(aN-oN*e**iN))**Vue*1e4/rN})},fromBase(t){return t.map(function(e){let r=Math.max(e*rN/1e4,0),s=nN+aN*r**sN,i=1+oN*r**sN;return(s/i)**Oue})}});const lN=.17883277,uN=.28466892,hN=.55991073,y0=3.7743;var Uue=new Ps({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:cy,toBase(t){return t.map(function(e){return e<=.5?e**2/3*y0:(Math.exp((e-hN)/lN)+uN)/12*y0})},fromBase(t){return t.map(function(e){return e/=y0,e<=1/12?Math.sqrt(3*e):lN*Math.log(12*e-uN)+hN})}});const nI={};Mo.add("chromatic-adaptation-start",t=>{t.options.method&&(t.M=cN(t.W1,t.W2,t.options.method))}),Mo.add("chromatic-adaptation-end",t=>{t.M||(t.M=cN(t.W1,t.W2,t.options.method))});function Wm({id:t,toCone_M:e,fromCone_M:r}){nI[t]=arguments[0]}function cN(t,e,r="Bradford"){let s=nI[r],[i,n,a]=It(s.toCone_M,t),[o,l,h]=It(s.toCone_M,e),u=[[o/i,0,0],[0,l/n,0],[0,0,h/a]],c=It(u,s.toCone_M);return It(s.fromCone_M,c)}Wm({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]]}),Wm({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]]}),Wm({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]]}),Wm({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(fs,{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]}),fs.ACES=[.32168/.33767,1,.34065/.33767];const Due=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],$ue=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var aI=new Ps({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:fs.ACES,toXYZ_M:Due,fromXYZ_M:$ue});const Hm=2**-16,x0=-.35828683,qm=(Math.log2(65504)+9.72)/17.52;var Gue=new Ps({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[x0,qm],name:"Red"},g:{range:[x0,qm],name:"Green"},b:{range:[x0,qm],name:"Blue"}},referred:"scene",base:aI,toBase(t){let e=-.3013698630136986;return t.map(function(r){return r<=e?(2**(r*17.52-9.72)-Hm)*2:r<qm?2**(r*17.52-9.72):65504})},fromBase(t){return t.map(function(e){return e<=0?(Math.log2(Hm)+9.72)/17.52:e<Hm?(Math.log2(Hm+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),dN=Object.freeze({__proto__:null,A98RGB:_ue,A98RGB_Linear:tI,ACEScc:Gue,ACEScg:aI,CAM16_JMh:Ele,HCT:Ed,HPLuv:Bue,HSL:KL,HSLuv:zue,HSV:eI,HWB:wue,ICTCP:kb,JzCzHz:Ob,Jzazbz:zL,LCH:Rd,LCHuv:jT,Lab:Zs,Lab_D65:$b,Luv:iI,OKLCH:Pue,OKLab:Dh,P3:XL,P3_Linear:HL,ProPhoto:Eue,ProPhoto_Linear:rI,REC_2020:WL,REC_2020_Linear:cy,REC_2100_HLG:Uue,REC_2100_PQ:kue,XYZ_ABS_D65:DT,XYZ_D50:UT,XYZ_D65:$r,sRGB:jh,sRGB_Linear:qL}),Us=class vs{constructor(...e){let r;e.length===1&&(r=ke(e[0]));let s,i,n;r?(s=r.space||r.spaceId,i=r.coords,n=r.alpha):[s,i,n]=e,Object.defineProperty(this,"space",{value:_e.get(s),writable:!1,enumerable:!0,configurable:!0}),this.coords=i?i.slice():[0,0,0],this.alpha=n>1||n===void 0?1:n<0?0:n;for(let a=0;a<this.coords.length;a++)this.coords[a]==="NaN"&&(this.coords[a]=NaN);for(let a in this.space.coords)Object.defineProperty(this,a,{get:()=>this.get(a),set:o=>this.set(a,o)})}get spaceId(){return this.space.id}clone(){return new vs(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let r=Hle(this,...e);return r.color=new vs(r.color),r}static get(e,...r){return e instanceof vs?e:new vs(e,...r)}static defineFunction(e,r,s=r){let{instance:i=!0,returns:n}=s,a=function(...o){let l=r(...o);if(n==="color")l=vs.get(l);else if(n==="function<color>"){let h=l;l=function(...u){let c=h(...u);return vs.get(c)},Object.assign(l,h)}else n==="array<color>"&&(l=l.map(h=>vs.get(h)));return l};e in vs||(vs[e]=a),i&&(vs.prototype[e]=function(...o){return a(this,...o)})}static defineFunctions(e){for(let r in e)vs.defineFunction(r,e[r],e[r])}static extend(e){if(e.register)e.register(vs);else for(let r in e)vs.defineFunction(r,e[r])}};Us.defineFunctions({get:Ys,getAll:mp,set:Aa,setAll:kT,to:Lt,equals:qle,inGamut:bl,toGamut:_o,distance:IL,toString:ad}),Object.assign(Us,{util:Woe,hooks:Mo,WHITES:fs,Space:_e,spaces:_e.registry,parse:FL,defaults:ei});for(let t of Object.keys(dN))_e.register(dN[t]);for(let t in _e.registry)Gb(t,_e.registry[t]);Mo.add("colorspace-init-end",t=>{Gb(t.id,t),t.aliases?.forEach(e=>{Gb(e,t)})});function Gb(t,e){let r=t.replace(/-/g,"_");Object.defineProperty(Us.prototype,r,{get(){let s=this.getAll(t);return typeof Proxy>"u"?s:new Proxy(s,{has:(i,n)=>{try{return _e.resolveCoord([e,n]),!0}catch{}return Reflect.has(i,n)},get:(i,n,a)=>{if(n&&typeof n!="symbol"&&!(n in i)){let{index:o}=_e.resolveCoord([e,n]);if(o>=0)return i[o]}return Reflect.get(i,n,a)},set:(i,n,a,o)=>{if(n&&typeof n!="symbol"&&!(n in i)||n>=0){let{index:l}=_e.resolveCoord([e,n]);if(l>=0)return i[l]=a,this.setAll(t,i),!0}return Reflect.set(i,n,a,o)}})},set(s){this.setAll(t,s)},configurable:!0,enumerable:!0})}Us.extend(Gh),Us.extend({deltaE:jc}),Object.assign(Us,{deltaEMethods:Gh}),Us.extend(bue),Us.extend({contrast:mue}),Us.extend(gue),Us.extend(Yle),Us.extend(Tue),Us.extend(vf);const{vec2:jue,vec4:Wue}=_t,xs=t=>{let e=new Us(t);return Wue(...e.to("p3-linear").coords,e.alpha).value},gp=t=>{let e=.5,r=.5,s=(i,n=!1)=>{if(typeof i=="number")return i;let a=i.toLowerCase().trim();if(n){if(a==="top")return 0;if(a==="bottom")return 1;if(a==="center")return .5}else{if(a==="left")return 0;if(a==="right")return 1;if(a==="center")return .5}return console.warn(`Invalid position value: ${i}. Defaulting to center.`),.5};if(typeof t=="string"){let i=t.toLowerCase().trim().split(/\s+/);i.includes("left")?e=0:i.includes("right")?e=1:(i.includes("center")||i.length===1&&(i[0]==="top"||i[0]==="bottom"))&&(e=.5),i.includes("top")?r=0:i.includes("bottom")?r=1:(i.includes("center")||i.length===1&&(i[0]==="left"||i[0]==="right"))&&(r=.5),i.length===1&&i[0]==="center"&&(e=.5,r=.5)}else typeof t=="object"&&t?(e=s(t.x,!1),r=s(t.y,!0)):console.warn(`Invalid position value provided: ${t}. Defaulting to center.`);return jue(e,1-r).value},Hue=t=>{if(typeof t=="number")return(t%360+360)%360;let e=t.toLowerCase().trim();switch(e){case"to right":return 0;case"to bottom":return 90;case"to left":return 180;case"to top":return 270;case"to bottom right":case"to right bottom":return 45;case"to bottom left":case"to left bottom":return 135;case"to top left":case"to left top":return 225;case"to top right":case"to right top":return 315;case"from left":return 0;case"from top":return 90;case"from right":return 180;case"from bottom":return 270;case"from top left":return 45;case"from top right":return 135;case"from bottom right":return 225;case"from bottom left":return 315;default:let r=e.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(r){let[,s,i="deg"]=r,n=parseFloat(s);switch(i){case"deg":return(n%360+360)%360;case"rad":return(n*180/Math.PI%360+360)%360;case"turn":return(n*360%360+360)%360;default:return(n%360+360)%360}}return console.warn(`Invalid angle value: ${t}. Defaulting to 0 degrees.`),0}},ah={name:"Checkerboard",props:{colorA:{default:"#cccccc",transform:xs,description:"First color of the checkerboard pattern",ui:{type:"color",label:"Color A"}},colorB:{default:"#999999",transform:xs,description:"Second color of the checkerboard pattern",ui:{type:"color",label:"Color B"}},cells:{default:8,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,floor:s,mod:i,screenUV:n,viewportSize:a}=_t,o=a.x.div(a.y),l=e(n.x.mul(o),n.y.oneMinus()),h=t.cells.uniform,u=l.mul(h),c=s(u),d=i(c.x.add(c.y),2);return r(t.colorA.uniform,t.colorB.uniform,d)}};function que(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const oI={blendMode:"normal"};try{ah&&ah.props&&Object.entries(ah.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(oI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xue=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${ah.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>que(t,oI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(ah,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,ah.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},oh={name:"Circle",props:{color:{default:"#ffffff",transform:xs,description:"The color of the circle",ui:{type:"color",label:"Color"}},radius:{default:1,description:"The radius of the circle. A value of one (1) is sets the circle to fit the canvas.",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}},softness:{default:0,description:"Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},center:{default:{x:.5,y:.5},transform:gp,description:"The center point of the circle",ui:{type:"text",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,length:s,mix:i,smoothstep:n,screenUV:a,viewportSize:o}=_t,l=o.x.div(o.y),h=e(a.x.mul(l),a.y),u=e(t.center.uniform.x.mul(l),t.center.uniform.y.oneMinus()),c=s(h.sub(u)),d=t.softness.uniform,p=t.radius.uniform.mul(.5),m=n(p,p.sub(d),c);return i(r(t.color.uniform.rgb,0),t.color.uniform,m)}};function Yue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const lI={blendMode:"normal"};try{oh&&oh.props&&Object.entries(oh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(lI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zue=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${oh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Yue(t,lI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(oh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,oh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},lh={name:"DotGrid",props:{color:{default:"#ffffff",description:"The color of the dot",transform:xs,ui:{type:"color",label:"Color"}},density:{default:100,description:"The number of dots on the longest canvas edge",ui:{type:"range",min:10,max:500,step:10,label:"Density"}},dotSize:{default:.3,description:"The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps",ui:{type:"range",min:0,max:1,step:.01,label:"Dot Size"}},twinkle:{default:0,description:"Intensity of the twinkle effect (0 = off, 1 = full twinkle)",ui:{type:"range",min:0,max:1,step:.01,label:"Twinkle"}}},fragmentNode:({uniforms:t})=>{let{screenUV:e,vec4:r,vec3:s,vec2:i,smoothstep:n,length:a,floor:o,float:l,viewportSize:h,time:u,sin:c,mix:d}=_t,p=e,m=t.density.uniform,f=t.dotSize.uniform,g=t.color.uniform,b=t.twinkle.uniform,v=h,w=v.x.div(v.y),T=i(p.x.mul(w),p.y.oneMinus()),N=T.mul(m),S=N.sub(o(N)),_=a(S.sub(.5)),A=a(b3(T.mul(m))),D=l(1).sub(n(f.mul(.5),f.mul(.5).add(A.mul(.5)),_)),K=o(N),J=K.x.mul(12.9898).add(K.y.mul(78.233)).sin().mul(43758.5453).fract(),re=u.mul(2).add(J.mul(6.28318)),te=c(re).mul(.5).add(.5),oe=d(l(1),te,b),ae=D.mul(oe),ge=s(g).mul(ae);return r(ge,ae)}};function Jue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const uI={blendMode:"normal"};try{lh&&lh.props&&Object.entries(lh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(uI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Que=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${lh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Jue(t,uI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(lh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,lh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},uh={name:"FilmGrain",props:{intensity:{default:.25,description:"Grain intensity (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Intensity"}},power:{default:.645,description:"Controls blending based on brightness",ui:{type:"range",min:0,max:2,step:.01,label:"Power"}},speed:{default:.5,description:"Animation speed of grain noise",ui:{type:"range",min:0,max:3,step:.1,label:"Speed"}}},fragmentNode:({uniforms:t,childNode:e})=>{let r=e||Ur(0,0,0,0),s=Iv(),i=p=>fb(no(wd(p,zv(12.9898,78.233))).mul(43758.5453)),n=p=>wd(p,Ur(.299,.587,.114,0)),a=i(s).add(Lv.mul(t.speed.uniform)),o=fb(no(a.mul(43758.5453))),l=ml(mb(.5),mb(.75),o).mul(t.intensity.uniform),h=T3(n(r),t.power.uniform),u=r.mul(l),c=x3(h,0,1),d=ml(u,r,c);return Ur(d.x,d.y,d.z,r.w)}};function Kue(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const hI={blendMode:"normal"};try{uh&&uh.props&&Object.entries(uh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(hI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ehe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${uh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>Kue(t,hI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(uh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,uh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},Xm=new WeakMap,hh={name:"glassTiles",props:{intensity:{default:1,description:"The intensity of the glass tiles effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},tileCount:{default:100,description:"Number of tiles across the shortest dimension",ui:{type:"range",min:1,max:200,step:1,label:"Tile Count"}}},fragmentNode:({uniforms:t,childNode:e,onCleanup:r,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,screenUV:d,uniform:p}=_t;if(!e)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(e),f=p(1),g=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};g();let b=Xm.get(s);b||(b=new ResizeObserver(ae=>{let ge=ae[0];if(!ge)return;let{width:fe,height:ve}=ge.contentRect,me=window.devicePixelRatio||1;m.setSize(fe*me,ve*me),g()}),b.observe(s),Xm.set(s,b)),r(()=>{let ae=Xm.get(s);ae&&(ae.disconnect(),Xm.delete(s))});let v=d,w=t.intensity.uniform,T=t.tileCount.uniform,N=i(f.greaterThanEqual(1).select(o(T,f),T),f.lessThan(1).select(l(T,f),T)),S=l(a(o(v,N)),N),_=h(v,S),A=i(.5,.5),D=o(w,.025),K=l(_,l(i(1),N)),J=h(K,A),re=o(J,D),te=u(_,re),oe=u(te,S);return n(m.sample(oe))}};function the(t,e){let r={...e};for(const[s,i]of Object.entries(t))s!=="children"&&s!=="ref"&&i!==void 0&&(r[s]=i);return r}const cI={blendMode:"normal"};try{hh&&hh.props&&Object.entries(hh.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(cI[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rhe=t=>{const e=L.useContext(Ee);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=e,a=L.useMemo(()=>t.id||`${hh.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=L.useMemo(()=>the(t,cI),[t]),l=L.useRef(null);l.current===null&&(l.current=Bt(hh,o,a));const h=L.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(L.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};return s(a,hh.fragmentNode,r,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,s,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),L.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),L.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return wt.jsx(Ee.Provider,{value:h,children:t.children})},Ym={VERTEX:"vertex"},eo={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},yp=["x","y","z","w"],Zr="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 pN=1234567;const dI=Math.PI/180,pI=180/Math.PI;function Tf(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Zr[t&255]+Zr[t>>8&255]+Zr[t>>16&255]+Zr[t>>24&255]+"-"+Zr[e&255]+Zr[e>>8&255]+"-"+Zr[e>>16&15|64]+Zr[e>>24&255]+"-"+Zr[r&63|128]+Zr[r>>8&255]+"-"+Zr[r>>16&255]+Zr[r>>24&255]+Zr[s&255]+Zr[s>>8&255]+Zr[s>>16&255]+Zr[s>>24&255]).toLowerCase()}function at(t,e,r){return Math.max(e,Math.min(r,t))}function WT(t,e){return(t%e+e)%e}function she(t,e,r,s,i){return s+(t-e)*(i-s)/(r-e)}function ihe(t,e,r){return t===e?0:(r-t)/(e-t)}function od(t,e,r){return(1-r)*t+r*e}function nhe(t,e,r,s){return od(t,e,1-Math.exp(-r*s))}function ahe(t,e=1){return e-Math.abs(WT(t,e*2)-e)}function ohe(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function lhe(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function uhe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function hhe(t,e){return t+Math.random()*(e-t)}function che(t){return t*(.5-Math.random())}function dhe(t){t!==void 0&&(pN=t);let e=pN+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function phe(t){return t*dI}function mhe(t){return t*pI}function fhe(t){return(t&t-1)==0&&t!==0}function ghe(t){return 2**Math.ceil(Math.log(t)/Math.LN2)}function yhe(t){return 2**Math.floor(Math.log(t)/Math.LN2)}function xhe(t,e,r,s,i){let n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+s)/2),u=a((e+s)/2),c=n((e-s)/2),d=a((e-s)/2),p=n((s-e)/2),m=a((s-e)/2);switch(i){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*u,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Zi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function dt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("Invalid component type.")}}const bhe={DEG2RAD:dI,RAD2DEG:pI,generateUUID:Tf,clamp:at,euclideanModulo:WT,mapLinear:she,inverseLerp:ihe,lerp:od,damp:nhe,pingpong:ahe,smoothstep:ohe,smootherstep:lhe,randInt:uhe,randFloat:hhe,randFloatSpread:che,seededRandom:dhe,degToRad:phe,radToDeg:mhe,isPowerOfTwo:fhe,ceilPowerOfTwo:ghe,floorPowerOfTwo:yhe,setQuaternionFromProperEuler:xhe,normalize:dt,denormalize:Zi},jb=0,vhe=1015,Wb="",Wi="srgb",mN="srgb-linear",fN="linear",ld="srgb",mg=35044,ll=2e3,Hb=2001;var xp=class mI{constructor(e,r,s,i,n,a,o,l,h){mI.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,s,i,n,a,o,l,h)}set(e,r,s,i,n,a,o,l,h){let u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let r=this.elements,s=e.elements;return r[0]=s[0],r[1]=s[1],r[2]=s[2],r[3]=s[3],r[4]=s[4],r[5]=s[5],r[6]=s[6],r[7]=s[7],r[8]=s[8],this}extractBasis(e,r,s){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let s=e.elements,i=r.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],g=i[3],b=i[6],v=i[1],w=i[4],T=i[7],N=i[2],S=i[5],_=i[8];return n[0]=a*f+o*v+l*N,n[3]=a*g+o*w+l*S,n[6]=a*b+o*T+l*_,n[1]=h*f+u*v+c*N,n[4]=h*g+u*w+c*S,n[7]=h*b+u*T+c*_,n[2]=d*f+p*v+m*N,n[5]=d*g+p*w+m*S,n[8]=d*b+p*T+m*_,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=r*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return e[0]=c*f,e[1]=(i*h-u*s)*f,e[2]=(o*s-i*a)*f,e[3]=d*f,e[4]=(u*r-i*l)*f,e[5]=(i*n-o*r)*f,e[6]=p*f,e[7]=(s*l-h*r)*f,e[8]=(a*r-s*n)*f,this}transpose(){let e,r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+e,-i*h,i*l,-i*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(b0.makeScale(e,r)),this}rotate(e){return this.premultiply(b0.makeRotation(-e)),this}translate(e,r){return this.premultiply(b0.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,-s,0,s,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){let r=this.elements,s=e.elements;for(let i=0;i<9;i++)if(r[i]!==s[i])return!1;return!0}fromArray(e,r=0){for(let s=0;s<9;s++)this.elements[s]=e[s+r];return this}toArray(e=[],r=0){let s=this.elements;return e[r]=s[0],e[r+1]=s[1],e[r+2]=s[2],e[r+3]=s[3],e[r+4]=s[4],e[r+5]=s[5],e[r+6]=s[6],e[r+7]=s[7],e[r+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const b0=new xp,gN={};function yN(t){t in gN||(gN[t]=!0,console.warn(t))}const xN=new xp().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),bN=new xp().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function The(){let t={enabled:!0,workingColorSpace:mN,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===ld&&(i.r=ch(i.r),i.g=ch(i.g),i.b=ch(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ld&&(i.r=dh(i.r),i.g=dh(i.g),i.b=dh(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Wb?fN:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return yN("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return yN("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],s=[.3127,.329];return t.define({[mN]:{primaries:e,whitePoint:s,transfer:fN,toXYZ:xN,fromXYZ:bN,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:Wi},outputColorSpaceConfig:{drawingBufferColorSpace:Wi}},[Wi]:{primaries:e,whitePoint:s,transfer:ld,toXYZ:xN,fromXYZ:bN,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:Wi}}}),t}const dr=The();function ch(t){return t<.04045?t*.0773993808:(t*.9478672986+.0521327014)**2.4}function dh(t){return t<.0031308?t*12.92:1.055*t**.41666-.055}const fI={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},Xa={h:0,s:0,l:0},Zm={h:0,s:0,l:0};function v0(t,e,r){return r<0&&(r+=1),r>1&&--r,r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}var HT=class{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Wi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,dr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,s=dr.workingColorSpace){return this.r=t,this.g=e,this.b=r,dr.colorSpaceToWorking(this,s),this}setHSL(t,e,r,s=dr.workingColorSpace){if(t=WT(t,1),e=at(e,0,1),r=at(r,0,1),e===0)this.r=this.g=this.b=r;else{let i=r<=.5?r*(1+e):r+e-r*e,n=2*r-i;this.r=v0(n,i,t+1/3),this.g=v0(n,i,t),this.b=v0(n,i,t-1/3)}return dr.colorSpaceToWorking(this,s),this}setStyle(t,e=Wi){function r(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let i,n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(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,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let i=s[1],n=i.length;if(n===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(n===6)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Wi){let r=fI[t.toLowerCase()];return r===void 0?console.warn("THREE.Color: Unknown color "+t):this.setHex(r,e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ch(t.r),this.g=ch(t.g),this.b=ch(t.b),this}copyLinearToSRGB(t){return this.r=dh(t.r),this.g=dh(t.g),this.b=dh(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Wi){return dr.workingToColorSpace(Jr.copy(this),t),Math.round(at(Jr.r*255,0,255))*65536+Math.round(at(Jr.g*255,0,255))*256+Math.round(at(Jr.b*255,0,255))}getHexString(t=Wi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=dr.workingColorSpace){dr.workingToColorSpace(Jr.copy(this),e);let r=Jr.r,s=Jr.g,i=Jr.b,n=Math.max(r,s,i),a=Math.min(r,s,i),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case r:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-r)/u+2;break;case i:o=(r-s)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=dr.workingColorSpace){return dr.workingToColorSpace(Jr.copy(this),e),t.r=Jr.r,t.g=Jr.g,t.b=Jr.b,t}getStyle(t=Wi){dr.workingToColorSpace(Jr.copy(this),t);let e=Jr.r,r=Jr.g,s=Jr.b;return t===Wi?`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(s*255)})`:`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(t,e,r){return this.getHSL(Xa),this.setHSL(Xa.h+t,Xa.s+e,Xa.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(Xa),t.getHSL(Zm);let r=od(Xa.h,Zm.h,e),s=od(Xa.s,Zm.s,e),i=od(Xa.l,Zm.l,e);return this.setHSL(r,s,i),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,r=this.g,s=this.b,i=t.elements;return this.r=i[0]*e+i[3]*r+i[6]*s,this.g=i[1]*e+i[4]*r+i[7]*s,this.b=i[2]*e+i[5]*r+i[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Jr=new HT;HT.NAMES=fI;var whe=class gI{constructor(e,r,s,i){gI.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let s=0;s<4;s++)this.elements[s]=e[s+r];return this}set(e,r,s,i){let n=this.elements;return n[0]=e,n[2]=r,n[1]=s,n[3]=i,this}},She=class{constructor(t=0,e=0,r=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=s}static slerpFlat(t,e,r,s,i,n,a){let o=r[s+0],l=r[s+1],h=r[s+2],u=r[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){t[e+0]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(a===1){t[e+0]=c,t[e+1]=d,t[e+2]=p,t[e+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,g=o*c+l*d+h*p+u*m,b=g>=0?1:-1,v=1-g*g;if(v>2**-52){let T=Math.sqrt(v),N=Math.atan2(T,g*b);f=Math.sin(f*N)/T,a=Math.sin(a*N)/T}let w=a*b;if(o=o*f+c*w,l=l*f+d*w,h=h*f+p*w,u=u*f+m*w,f===1-a){let T=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=T,l*=T,h*=T,u*=T}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,r,s,i,n){let a=r[s],o=r[s+1],l=r[s+2],h=r[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return t[e]=a*p+h*u+o*d-l*c,t[e+1]=o*p+h*c+l*u-a*d,t[e+2]=l*p+h*d+a*c-o*u,t[e+3]=h*p-a*u-o*c-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,s){return this._x=t,this._y=e,this._z=r,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let r=t._x,s=t._y,i=t._z,n=t._order,a=Math.cos,o=Math.sin,l=a(r/2),h=a(s/2),u=a(i/2),c=o(r/2),d=o(s/2),p=o(i/2);switch(n){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let r=e/2,s=Math.sin(r);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],s=e[4],i=e[8],n=e[1],a=e[5],o=e[9],l=e[2],h=e[6],u=e[10],c=r+a+u;if(c>0){let d=.5/Math.sqrt(c+1);this._w=.25/d,this._x=(h-o)*d,this._y=(i-l)*d,this._z=(n-s)*d}else if(r>a&&r>u){let d=2*Math.sqrt(1+r-a-u);this._w=(h-o)/d,this._x=.25*d,this._y=(s+n)/d,this._z=(i+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-r-u);this._w=(i-l)/d,this._x=(s+n)/d,this._y=.25*d,this._z=(o+h)/d}else{let d=2*Math.sqrt(1+u-r-a);this._w=(n-s)/d,this._x=(i+l)/d,this._y=(o+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<2**-52?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(at(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let s=Math.min(1,e/r);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x*=t,this._y*=t,this._z*=t,this._w*=t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let r=t._x,s=t._y,i=t._z,n=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=r*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-r*l,this._z=i*h+n*l+r*o-s*a,this._w=n*h-r*a-s*o-i*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,s=this._y,i=this._z,n=this._w,a=n*t._w+r*t._x+s*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=n,this._x=r,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-e;return this._w=d*n+e*this._w,this._x=d*r+e*this._x,this._y=d*s+e*this._y,this._z=d*i+e*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-e)*h)/l,c=Math.sin(e*h)/l;return this._w=n*u+this._w*c,this._x=r*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),s=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ln=class yI{constructor(e=0,r=0,s=0){yI.prototype.isVector3=!0,this.x=e,this.y=r,this.z=s}set(e,r,s){return s===void 0&&(s=this.z),this.x=e,this.y=r,this.z=s,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.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,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(vN.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(vN.setFromAxisAngle(e,r))}applyMatrix3(e){let r=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*r+n[3]*s+n[6]*i,this.y=n[1]*r+n[4]*s+n[7]*i,this.z=n[2]*r+n[5]*s+n[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let r=this.x,s=this.y,i=this.z,n=e.elements,a=1/(n[3]*r+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*r+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*r+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*r+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(e){let r=this.x,s=this.y,i=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*i-o*s),u=2*(o*r-n*i),c=2*(n*s-a*r);return this.x=r+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let r=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*r+n[4]*s+n[8]*i,this.y=n[1]*r+n[5]*s+n[9]*i,this.z=n[2]*r+n[6]*s+n[10]*i,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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this.z=at(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this.z=at(this.z,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}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,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this.z=e.z+(r.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){let s=e.x,i=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(e){let r=e.lengthSq();if(r===0)return this.set(0,0,0);let s=e.dot(this)/r;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return T0.copy(this).projectOnVector(e),this.sub(T0)}reflect(e){return this.sub(T0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let s=this.dot(e)/r;return Math.acos(at(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return r*r+s*s+i*i}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,r,s){let i=Math.sin(r)*e;return this.x=i*Math.sin(s),this.y=Math.cos(r)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,s){return this.x=e*Math.sin(r),this.y=s,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){let r=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=s,this.z=i,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*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,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,r=Math.random()*2-1,s=Math.sqrt(1-r*r);return this.x=s*Math.cos(e),this.y=r,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const T0=new ln,vN=new She;var xI=class qb{constructor(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g){qb.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g)}set(e,r,s,i,n,a,o,l,h,u,c,d,p,m,f,g){let b=this.elements;return b[0]=e,b[4]=r,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=g,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 qb().fromArray(this.elements)}copy(e){let r=this.elements,s=e.elements;return r[0]=s[0],r[1]=s[1],r[2]=s[2],r[3]=s[3],r[4]=s[4],r[5]=s[5],r[6]=s[6],r[7]=s[7],r[8]=s[8],r[9]=s[9],r[10]=s[10],r[11]=s[11],r[12]=s[12],r[13]=s[13],r[14]=s[14],r[15]=s[15],this}copyPosition(e){let r=this.elements,s=e.elements;return r[12]=s[12],r[13]=s[13],r[14]=s[14],this}setFromMatrix3(e){let r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,s){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,r,s){return this.set(e.x,r.x,s.x,0,e.y,r.y,s.y,0,e.z,r.z,s.z,0,0,0,0,1),this}extractRotation(e){let r=this.elements,s=e.elements,i=1/Cu.setFromMatrixColumn(e,0).length(),n=1/Cu.setFromMatrixColumn(e,1).length(),a=1/Cu.setFromMatrixColumn(e,2).length();return r[0]=s[0]*i,r[1]=s[1]*i,r[2]=s[2]*i,r[3]=0,r[4]=s[4]*n,r[5]=s[5]*n,r[6]=s[6]*n,r[7]=0,r[8]=s[8]*a,r[9]=s[9]*a,r[10]=s[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){let r=this.elements,s=e.x,i=e.y,n=e.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=p+m*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=m+p*h,r[10]=a*l}else if(e.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;r[0]=d+f*o,r[4]=m*o-p,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=p*o-m,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=m+p*o,r[1]=p+m*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;r[0]=l*u,r[4]=m*h-p,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=p*h-m,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=m*c+p,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=p*c+m,r[10]=d-f*c}else if(e.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=p*c-m,r[2]=m*c-p,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Mhe,e,_he)}lookAt(e,r,s){let i=this.elements;return ks.subVectors(e,r),ks.lengthSq()===0&&(ks.z=1),ks.normalize(),Ya.crossVectors(s,ks),Ya.lengthSq()===0&&(Math.abs(s.z)===1?ks.x+=1e-4:ks.z+=1e-4,ks.normalize(),Ya.crossVectors(s,ks)),Ya.normalize(),Jm.crossVectors(ks,Ya),i[0]=Ya.x,i[4]=Jm.x,i[8]=ks.x,i[1]=Ya.y,i[5]=Jm.y,i[9]=ks.y,i[2]=Ya.z,i[6]=Jm.z,i[10]=ks.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let s=e.elements,i=r.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],g=s[10],b=s[14],v=s[3],w=s[7],T=s[11],N=s[15],S=i[0],_=i[4],A=i[8],D=i[12],K=i[1],J=i[5],re=i[9],te=i[13],oe=i[2],ae=i[6],ge=i[10],fe=i[14],ve=i[3],me=i[7],he=i[11],Te=i[15];return n[0]=a*S+o*K+l*oe+h*ve,n[4]=a*_+o*J+l*ae+h*me,n[8]=a*A+o*re+l*ge+h*he,n[12]=a*D+o*te+l*fe+h*Te,n[1]=u*S+c*K+d*oe+p*ve,n[5]=u*_+c*J+d*ae+p*me,n[9]=u*A+c*re+d*ge+p*he,n[13]=u*D+c*te+d*fe+p*Te,n[2]=m*S+f*K+g*oe+b*ve,n[6]=m*_+f*J+g*ae+b*me,n[10]=m*A+f*re+g*ge+b*he,n[14]=m*D+f*te+g*fe+b*Te,n[3]=v*S+w*K+T*oe+N*ve,n[7]=v*_+w*J+T*ae+N*me,n[11]=v*A+w*re+T*ge+N*he,n[15]=v*D+w*te+T*fe+N*Te,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){let e=this.elements,r=e[0],s=e[4],i=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],p=e[14],m=e[3],f=e[7],g=e[11],b=e[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+r*l*p-r*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+g*(+r*h*c-r*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-r*l*c+r*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let e=this.elements,r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,s){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=r,i[14]=s),this}invert(){let e=this.elements,r=e[0],s=e[1],i=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],p=e[11],m=e[12],f=e[13],g=e[14],b=e[15],v=c*g*h-f*d*h+f*l*p-o*g*p-c*l*b+o*d*b,w=m*d*h-u*g*h-m*l*p+a*g*p+u*l*b-a*d*b,T=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,N=m*c*l-u*f*l-m*o*d+a*f*d+u*o*g-a*c*g,S=r*v+s*w+i*T+n*N;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let _=1/S;return e[0]=v*_,e[1]=(f*d*n-c*g*n-f*i*p+s*g*p+c*i*b-s*d*b)*_,e[2]=(o*g*n-f*l*n+f*i*h-s*g*h-o*i*b+s*l*b)*_,e[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*_,e[4]=w*_,e[5]=(u*g*n-m*d*n+m*i*p-r*g*p-u*i*b+r*d*b)*_,e[6]=(m*l*n-a*g*n-m*i*h+r*g*h+a*i*b-r*l*b)*_,e[7]=(a*d*n-u*l*n+u*i*h-r*d*h-a*i*p+r*l*p)*_,e[8]=T*_,e[9]=(m*c*n-u*f*n-m*s*p+r*f*p+u*s*b-r*c*b)*_,e[10]=(a*f*n-m*o*n+m*s*h-r*f*h-a*s*b+r*o*b)*_,e[11]=(u*o*n-a*c*n-u*s*h+r*c*h+a*s*p-r*o*p)*_,e[12]=N*_,e[13]=(u*f*i-m*c*i+m*s*d-r*f*d-u*s*g+r*c*g)*_,e[14]=(m*o*i-a*f*i-m*s*l+r*f*l+a*s*g-r*o*g)*_,e[15]=(a*c*i-u*o*i+u*s*l-r*c*l-a*s*d+r*o*d)*_,this}scale(e){let r=this.elements,s=e.x,i=e.y,n=e.z;return r[0]*=s,r[4]*=i,r[8]*=n,r[1]*=s,r[5]*=i,r[9]*=n,r[2]*=s,r[6]*=i,r[10]*=n,r[3]*=s,r[7]*=i,r[11]*=n,this}getMaxScaleOnAxis(){let e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,s,i))}makeTranslation(e,r,s){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,r,0,0,1,s,0,0,0,1),this}makeRotationX(e){let r=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,r,-s,0,0,s,r,0,0,0,0,1),this}makeRotationY(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,0,s,0,0,1,0,0,-s,0,r,0,0,0,0,1),this}makeRotationZ(e){let r=Math.cos(e),s=Math.sin(e);return this.set(r,-s,0,0,s,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){let s=Math.cos(r),i=Math.sin(r),n=1-s,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(e,r,s){return this.set(e,0,0,0,0,r,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,r,s,i,n,a){return this.set(1,s,n,0,e,1,a,0,r,i,1,0,0,0,0,1),this}compose(e,r,s){let i=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,g=a*c,b=o*c,v=l*h,w=l*u,T=l*c,N=s.x,S=s.y,_=s.z;return i[0]=(1-(f+b))*N,i[1]=(p+T)*N,i[2]=(m-w)*N,i[3]=0,i[4]=(p-T)*S,i[5]=(1-(d+b))*S,i[6]=(g+v)*S,i[7]=0,i[8]=(m+w)*_,i[9]=(g-v)*_,i[10]=(1-(d+f))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,r,s){let i=this.elements,n=Cu.set(i[0],i[1],i[2]).length(),a=Cu.set(i[4],i[5],i[6]).length(),o=Cu.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],Di.copy(this);let h=1/n,u=1/a,c=1/o;return Di.elements[0]*=h,Di.elements[1]*=h,Di.elements[2]*=h,Di.elements[4]*=u,Di.elements[5]*=u,Di.elements[6]*=u,Di.elements[8]*=c,Di.elements[9]*=c,Di.elements[10]*=c,r.setFromRotationMatrix(Di),s.x=n,s.y=a,s.z=o,this}makePerspective(e,r,s,i,n,a,o=ll){let l=this.elements,h=2*n/(r-e),u=2*n/(s-i),c=(r+e)/(r-e),d=(s+i)/(s-i),p,m;if(o===ll)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Hb)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,s,i,n,a,o=ll){let l=this.elements,h=1/(r-e),u=1/(s-i),c=1/(a-n),d=(r+e)*h,p=(s+i)*u,m,f;if(o===ll)m=(a+n)*c,f=-2*c;else if(o===Hb)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let r=this.elements,s=e.elements;for(let i=0;i<16;i++)if(r[i]!==s[i])return!1;return!0}fromArray(e,r=0){for(let s=0;s<16;s++)this.elements[s]=e[s+r];return this}toArray(e=[],r=0){let s=this.elements;return e[r]=s[0],e[r+1]=s[1],e[r+2]=s[2],e[r+3]=s[3],e[r+4]=s[4],e[r+5]=s[5],e[r+6]=s[6],e[r+7]=s[7],e[r+8]=s[8],e[r+9]=s[9],e[r+10]=s[10],e[r+11]=s[11],e[r+12]=s[12],e[r+13]=s[13],e[r+14]=s[14],e[r+15]=s[15],e}};const Cu=new ln,Di=new xI,Mhe=new ln(0,0,0),_he=new ln(1,1,1),Ya=new ln,Jm=new ln,ks=new ln;var bI=class vI{constructor(e=0,r=0){vI.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.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 r=this.x,s=this.y,i=e.elements;return this.x=i[0]*r+i[3]*s+i[6],this.y=i[1]*r+i[4]*s+i[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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let s=this.dot(e)/r;return Math.acos(at(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,s=this.y-e.y;return r*r+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){let s=Math.cos(r),i=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*s-a*i+e.x,this.y=n*i+a*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Nhe=class TI{constructor(e=0,r=0,s=0,i=1){TI.prototype.isVector4=!0,this.x=e,this.y=r,this.z=s,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,r,s,i){return this.x=e,this.y=r,this.z=s,this.w=i,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,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;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,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,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,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.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 r=this.x,s=this.y,i=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*r+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*r+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*r+a[7]*s+a[11]*i+a[15]*n,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 r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,s,i,n,a=.01,o=.1,l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],g=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-g)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+g)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;r=Math.PI;let w=(h+1)/2,T=(p+1)/2,N=(b+1)/2,S=(u+d)/4,_=(c+f)/4,A=(m+g)/4;return w>T&&w>N?w<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(w),i=S/s,n=_/s):T>N?T<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(T),s=S/i,n=A/i):N<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(N),s=_/n,i=A/n),this.set(s,i,n,r),this}let v=Math.sqrt((g-m)*(g-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(c-f)/v,this.z=(d-u)/v,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[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,r){return this.x=at(this.x,e.x,r.x),this.y=at(this.y,e.y,r.y),this.z=at(this.z,e.z,r.z),this.w=at(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=at(this.x,e,r),this.y=at(this.y,e,r),this.z=at(this.z,e,r),this.w=at(this.w,e,r),this}clampLength(e,r){let s=this.length();return this.divideScalar(s||1).multiplyScalar(at(s,e,r))}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,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,s){return this.x=e.x+(r.x-e.x)*s,this.y=e.y+(r.y-e.y)*s,this.z=e.z+(r.z-e.z)*s,this.w=e.w+(r.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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 Xb(t,e=0){let r=3735928559^e,s=1103547991^e;if(t instanceof Array)for(let i=0,n;i<t.length;i++)n=t[i],r=Math.imul(r^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<t.length;i++)n=t.charCodeAt(i),r=Math.imul(r^n,2654435761),s=Math.imul(s^n,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const wI=(...t)=>Xb(t);function Ahe(t,e=!1){let r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(let{property:s,childNode:i}of Yb(t))r.push(Xb(s.slice(0,-4)),i.getCacheKey(e));return Xb(r)}function*Yb(t,e=!1){for(let r in t){if(r.startsWith("_")===!0)continue;let s=t[r];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:r,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:i,childNode:n})}}}function Zb(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function SI(t,...e){let r=t?t.slice(-4):void 0;return e.length===1&&(r==="vec2"?e=[e[0],e[0]]:r==="vec3"?e=[e[0],e[0],e[0]]:r==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new HT(...e):r==="vec2"?new bI(...e):r==="vec3"?new ln(...e):r==="vec4"?new Nhe(...e):r==="mat2"?new whe(...e):r==="mat3"?new xp(...e):r==="mat4"?new xI(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?Rhe(e[0]):null}function Che(t){let e="",r=new Uint8Array(t);for(let s=0;s<r.length;s++)e+=String.fromCharCode(r[s]);return btoa(e)}function Rhe(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}var Ehe=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){let r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){let r=this._listeners;if(r===void 0)return;let s=r[t];if(s!==void 0){let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let r=e[t.type];if(r!==void 0){t.target=this;let s=r.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,t);t.target=null}}};const Phe={analyze:"setup",generate:"analyze"};let Fhe=0;var Lhe=class extends Ehe{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=eo.NONE,this.updateBeforeType=eo.NONE,this.updateAfterType=eo.NONE,this.uuid=bhe.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Fhe++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,eo.FRAME)}onRenderUpdate(t){return this.onUpdate(t,eo.RENDER)}onObjectUpdate(t){return this.onUpdate(t,eo.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of Yb(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t||(t=this.version!==this._cacheKeyVersion),(t===!0||this._cacheKey===null)&&(this._cacheKey=wI(Ahe(this,t),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(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){let e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){let e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){let e=t.getNodeProperties(this),r=0;for(let s of this.getChildren())e["node"+r++]=s;return e.outputNode||null}analyze(t,e=null){let r=t.increaseUsage(this);if(this.parents===!0){let s=t.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[t.shaderStage]=s.stages[t.shaderStage]||[],s.stages[t.shaderStage].push(e)}if(r===1){let s=t.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(t,this)}}generate(t,e){let{outputNode:r}=t.getNodeProperties(this);if(r&&r.isNode===!0)return r.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){let r=this.getShared(t);if(this!==r)return r.build(t,e);let s=t.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[t.buildStage]=!0;let i=Phe[t.buildStage];if(i&&s.buildStages[i]!==!0){let o=t.getBuildStage();t.setBuildStage(i),this.build(t),t.setBuildStage(o)}t.addNode(this),t.addChain(this);let n=null,a=t.getBuildStage();if(a==="setup"){this.updateReference(t);let o=t.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(t)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=t.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(t)}}n=o.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(t),h=t.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(t)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,l,e)}else n=this.generate(t,e)||"";return t.removeChain(this),t.addSequentialNode(this),n}getSerializeChildren(){return Yb(this)}serialize(t){let e=this.getSerializeChildren(),r={};for(let{property:s,index:i,childNode:n}of e)i===void 0?r[s]=n.toJSON(t.meta).uuid:(r[s]===void 0&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(t.meta).uuid);Object.keys(r).length>0&&(t.inputNodes=r)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let r in t.inputNodes)if(Array.isArray(t.inputNodes[r])){let s=[];for(let i of t.inputNodes[r])s.push(e[i]);this[r]=s}else if(typeof t.inputNodes[r]=="object"){let s={};for(let i in t.inputNodes[r]){let n=t.inputNodes[r][i];s[i]=e[n]}this[r]=s}else{let s=t.inputNodes[r];this[r]=e[s]}}}toJSON(t){let{uuid:e,type:r}=this,s=t===void 0||typeof t=="string";s&&(t={textures:{},images:{},nodes:{}});let i=t.nodes[e];i===void 0&&(i={uuid:e,type:r,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(t.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s){let a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},yr=Lhe,Ihe=class extends yr{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){let s=t.getVectorType(this.getNodeType(t,e)),i=t.getDataFromNode(this);if(i.propertyName!==void 0)return t.format(i.propertyName,s,e);if(s!=="void"&&e!=="void"&&this.hasDependencies(t)){let n=super.build(t,s),a=t.getVarFromNode(this,null,s),o=t.getPropertyName(a);return t.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,t.format(i.propertyName,s,e)}}return super.build(t,e)}},ti=Ihe,zhe=class extends yr{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){let e=this.indexNode.getNodeType(t),r=this.node.build(t),s=this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint");return`${r}[ ${s} ]`}},qT=zhe,Bhe=class extends yr{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){let e=this.node.getNodeType(t),r=null;for(let s of this.convertTo.split("|"))(r===null||t.getTypeLength(e)===t.getTypeLength(s))&&(r=s);return r}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){let r=this.node,s=this.getNodeType(t),i=r.build(t,s);return t.format(i,s,e)}},MI=Bhe,Vhe=class extends ti{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType===null?t.getTypeFromLength(this.nodes.reduce((e,r)=>e+t.getTypeLength(r.getNodeType(t)),0)):t.getVectorType(this.nodeType)}generate(t,e){let r=this.getNodeType(t),s=t.getTypeLength(r),i=this.nodes,n=t.getComponentType(r),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let u=h.getNodeType(t),c=t.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),c=s-o,u=t.getTypeFromLength(c)),o+=c,d=h.build(t,u);let p=t.getComponentType(u);p!==n&&(d=t.format(d,p,n)),a.push(d)}let l=`${t.getType(r)}( ${a.join(", ")} )`;return t.format(l,r,e)}},Ohe=Vhe;const khe=yp.join("");var Uhe=class extends yr{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(let e of this.components)t=Math.max(yp.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){let r=this.node,s=t.getTypeLength(r.getNodeType(t)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));let o=r.build(t,n);i=this.components.length===s&&this.components===khe.slice(0,this.components.length)?t.format(o,n,e):t.format(`${o}.${this.components}`,this.getNodeType(t),e)}else i=r.build(t,e);return i}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}},TN=Uhe,Dhe=class extends ti{static get type(){return"SetNode"}constructor(t,e,r){super(),this.sourceNode=t,this.components=e,this.targetNode=r}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:r,targetNode:s}=this,i=this.getNodeType(t),n=t.getComponentType(s.getNodeType(t)),a=t.getTypeFromLength(r.length,n),o=s.build(t,a),l=e.build(t,i),h=t.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=yp[c];d===r[0]?(u.push(o),c+=r.length-1):u.push(l+"."+d)}return`${t.getType(i)}( ${u.join(", ")} )`}},$he=Dhe,Ghe=class extends ti{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{components:e,sourceNode:r}=this,s=this.getNodeType(t),i=r.build(t),n=t.getVarFromNode(this),a=t.getPropertyName(n);t.addLineFlowCode(a+" = "+i,this);let o=t.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=yp[u];c===e[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${t.getType(s)}( ${l.join(", ")} )`}},jhe=Ghe,Whe=class extends yr{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Zb(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Zb(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=Che(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?SI(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}},XT=Whe;const wN=/float|u?int/;var Hhe=class extends XT{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let r=this.getNodeType(t);return wN.test(r)&&wN.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),r,e)}},Fa=Hhe,qhe=class extends yr{static get type(){return"MemberNode"}constructor(t,e){super(),this.node=t,this.property=e,this.isMemberNode=!0}getNodeType(t){return this.node.getMemberType(t,this.property)}generate(t){return this.node.build(t)+"."+this.property}},Xhe=qhe;let Yhe=null;const Wu=new Map;function H(t,e){if(Wu.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw Error(`THREE.TSL: Node element ${t} is not a function`);Wu.set(t,e)}const _I=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),SN=t=>_I(t).split("").sort().join(""),NI={setup(t,e){let r=e.shift();return t(fy(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...s)=>(Yhe.assign(r,...s),r);if(Wu.has(e)){let s=Wu.get(e);return t.isStackNode?(...i)=>r.add(s(...i)):(...i)=>s(r,...i)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Wu.has(e.slice(0,e.length-6))){let s=Wu.get(e.slice(0,e.length-6));return t.isStackNode?(...i)=>r.assign(i[0],s(...i)):(...i)=>r.assign(s(r,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=_I(e),Ne(new TN(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=SN(e.slice(3).toLowerCase()),s=>Ne(new $he(t,e,Ne(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=SN(e.slice(4).toLowerCase()),()=>Ne(new jhe(Ne(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Ne(new TN(t,e));if(/^\d+$/.test(e)===!0)return Ne(new qT(r,new Fa(Number(e),"uint")));if(/^get$/.test(e)===!0)return s=>Ne(new Xhe(r,s))}}}return Reflect.get(t,e,r)},set(t,e,r,s){return typeof e=="string"&&t[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(s[e].assign(r),!0):Reflect.set(t,e,r,s)}},w0=new WeakMap,MN=new WeakMap,Zhe=function(t,e=null){let r=Zb(t);if(r==="node"){let s=w0.get(t);return s===void 0&&(s=new Proxy(t,NI),w0.set(t,s),w0.set(s,s)),s}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return Ne(Jb(t,e));if(r==="shader")return Ei(t)}return t},Jhe=function(t,e=null){for(let r in t)t[r]=Ne(t[r],e);return t},Qhe=function(t,e=null){let r=t.length;for(let s=0;s<r;s++)t[s]=Ne(t[s],e);return t},Khe=function(t,e=null,r=null,s=null){let i=u=>Ne(s===null?u:Object.assign(u,s)),n,a=e,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return e===null?n=(...u)=>i(new t(...wf(h(u)))):r===null?n=(...u)=>i(new t(e,...wf(h(u)))):(r=Ne(r),n=(...u)=>i(new t(e,...wf(h(u)),r))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var ece=class extends yr{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,inputNodes:r}=this,s=t.getNodeProperties(e),i=e.namespace&&e.namespace===t.namespace?t.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(e.layout){let a=MN.get(t.constructor);a===void 0&&(a=new WeakMap,MN.set(t.constructor,a));let o=a.get(e);o===void 0&&(o=Ne(t.buildFunctionNode(e)),a.set(e,o)),t.addInclude(o),n=Ne(o.call(r))}else{let a=e.jsFunc,o=r!==null||a.length>1?a(r||[],t):a(t);n=Ne(o)}return e.once&&(s[i]=n),n}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),r=t.getOutputNamespace();return e[r]=e[r]||this.setupOutput(t),e[r]}build(t,e=null){let r=null,s=t.getBuildStage(),i=t.getNodeProperties(this),n=t.getOutputNamespace(),a=this.getOutputNode(t);if(s==="setup"){let o=t.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(t),i[n].build(t)),r=i[n]}else s==="analyze"?a.build(t,e):s==="generate"&&(r=a.build(t,e)||"");return r}},tce=class extends yr{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(t){return this.layout=t,this}call(t=null){return fy(t),Ne(new ece(this,t))}setup(){return this.call()}};const rce=[!1,!0],sce=[0,1,2,3],ice=[-1,-2],AI=[.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],YT=new Map;for(let t of rce)YT.set(t,new Fa(t));const ZT=new Map;for(let t of sce)ZT.set(t,new Fa(t,"uint"));const JT=new Map([...ZT].map(t=>new Fa(t.value,"int")));for(let t of ice)JT.set(t,new Fa(t,"int"));const py=new Map([...JT].map(t=>new Fa(t.value)));for(let t of AI)py.set(t,new Fa(t));for(let t of AI)py.set(-t,new Fa(-t));const my={bool:YT,uint:ZT,ints:JT,float:py},_N=new Map([...YT,...py]),Jb=(t,e)=>_N.has(t)?_N.get(t):t.isNode===!0?t:new Fa(t,e),nce=t=>{try{return t.getNodeType()}catch{return}},xr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(i=>typeof i!="object"))&&(r=[SI(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return Ne(e.get(r[0]));if(r.length===1){let i=Jb(r[0],t);return nce(i)===t?Ne(i):Ne(new MI(i,t))}let s=r.map(i=>Jb(i));return Ne(new Ohe(s,t))}},ace=t=>t==null?null:t.nodeType||t.convertTo||(typeof t=="string"?t:null);function oce(t,e){return new Proxy(new tce(t,e),NI)}const Ne=(t,e=null)=>Zhe(t,e),fy=(t,e=null)=>new Jhe(t,e),wf=(t,e=null)=>new Qhe(t,e),ue=(...t)=>new Khe(...t);let lce=0;const Ei=(t,e=null)=>{let r=null;e!==null&&(typeof e=="object"?r=e.return:(typeof e=="string"?r=e:console.error("THREE.TSL: Invalid layout type."),e=null));let s=new oce(t,r),i=(...n)=>{let a;fy(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return r==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),e!==null){if(typeof e.inputs!="object"){let n={name:"fn"+lce++,type:r,inputs:[]};for(let a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}i.setLayout(e)}return i};function uce(t){return t}H("toStack",uce);const hce=new xr("color"),zn=new xr("float",my.float),Pd=new xr("int",my.ints),cce=new xr("uint",my.uint),dce=new xr("bool",my.bool),CI=new xr("vec2"),pce=new xr("ivec2"),mce=new xr("uvec2"),fce=new xr("bvec2"),Wh=new xr("vec3"),gce=new xr("ivec3"),yce=new xr("uvec3"),xce=new xr("bvec3"),vl=new xr("vec4"),bce=new xr("ivec4"),vce=new xr("uvec4"),Tce=new xr("bvec4"),wce=new xr("mat2"),RI=new xr("mat3"),Sce=new xr("mat4");H("toColor",hce),H("toFloat",zn),H("toInt",Pd),H("toUint",cce),H("toBool",dce),H("toVec2",CI),H("toIVec2",pce),H("toUVec2",mce),H("toBVec2",fce),H("toVec3",Wh),H("toIVec3",gce),H("toUVec3",yce),H("toBVec3",xce),H("toVec4",vl),H("toIVec4",bce),H("toUVec4",vce),H("toBVec4",Tce),H("toMat2",wce),H("toMat3",RI),H("toMat4",Sce);const Mce=ue(qT).setParameterLength(2),_ce=(t,e)=>Ne(new MI(Ne(t),e));H("element",Mce),H("convert",_ce),H("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),t));const Nce={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var nr=class Qb extends ti{static get type(){return"OperatorNode"}constructor(e,r,s,...i){if(super(),i.length>0){let n=new Qb(e,r,s);for(let a=0;a<i.length-1;a++)n=new Qb(e,n,i[a]);r=n,s=i[i.length-1]}this.op=e,this.aNode=r,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,r){return e.getMethod(Nce[this.op],r)}getNodeType(e){let r=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(e),a=i?i.getNodeType(e):null;if(n==="void"||a==="void")return"void";if(r==="%")return n;if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return e.getIntegerType(n);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){let o=Math.max(e.getTypeLength(n),e.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(e.isMatrix(n)){if(a==="float")return n;if(e.isVector(a))return e.getVectorFromMatrix(n);if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if(n==="float")return a;if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}}generate(e,r){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(e),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(e),l=n?n.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=e.changeComponentType(l,"uint")):s==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):o=e.isMatrix(l)?o==="float"?"float":e.isVector(o)?e.getVectorFromMatrix(l):l=a:l=a);let h=i.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(s);if(r!=="void"){let d=e.renderer.coordinateSystem===ll;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,r)}( ${h}, ${u} )`,a,r):e.format(`( ${h} ${s} ${u} )`,a,r);if(s==="%")return e.isInteger(l)?e.format(`( ${h} % ${u} )`,a,r):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${u} )`,a,r);if(s==="!"||s==="~")return e.format(`(${s}${h})`,o,r);if(c)return e.format(`${c}( ${h}, ${u} )`,a,r);if(e.isMatrix(o)&&l==="float")return e.format(`( ${u} ${s} ${h} )`,a,r);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${s} ${u}`,a,r);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,a,r)}}else if(o!=="void")return c?e.format(`${c}( ${h}, ${u} )`,a,r):e.isMatrix(o)&&l==="float"?e.format(`${u} ${s} ${h}`,a,r):e.format(`${h} ${s} ${u}`,a,r)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const EI=ue(nr,"+").setParameterLength(2,1/0).setName("add"),Kb=ue(nr,"-").setParameterLength(2,1/0).setName("sub"),QT=ue(nr,"*").setParameterLength(2,1/0).setName("mul"),PI=ue(nr,"/").setParameterLength(2,1/0).setName("div"),gy=ue(nr,"%").setParameterLength(2).setName("mod"),FI=ue(nr,"==").setParameterLength(2).setName("equal"),Ace=ue(nr,"!=").setParameterLength(2).setName("notEqual"),Cce=ue(nr,"<").setParameterLength(2).setName("lessThan"),Rce=ue(nr,">").setParameterLength(2).setName("greaterThan"),Ece=ue(nr,"<=").setParameterLength(2).setName("lessThanEqual"),Pce=ue(nr,">=").setParameterLength(2).setName("greaterThanEqual"),Fce=ue(nr,"&&").setParameterLength(2,1/0).setName("and"),Lce=ue(nr,"||").setParameterLength(2,1/0).setName("or"),Ice=ue(nr,"!").setParameterLength(1).setName("not"),zce=ue(nr,"^^").setParameterLength(2).setName("xor"),Bce=ue(nr,"&").setParameterLength(2).setName("bitAnd"),Vce=ue(nr,"~").setParameterLength(2).setName("bitNot"),Oce=ue(nr,"|").setParameterLength(2).setName("bitOr"),kce=ue(nr,"^").setParameterLength(2).setName("bitXor"),Uce=ue(nr,"<<").setParameterLength(2).setName("shiftLeft"),Dce=ue(nr,">>").setParameterLength(2).setName("shiftRight"),$ce=Ei(([t])=>(t.addAssign(1),t)),Gce=Ei(([t])=>(t.subAssign(1),t)),jce=Ei(([t])=>{let e=Pd(t).toConst();return t.addAssign(1),e}),Wce=Ei(([t])=>{let e=Pd(t).toConst();return t.subAssign(1),e});H("add",EI),H("sub",Kb),H("mul",QT),H("div",PI),H("mod",gy),H("equal",FI),H("notEqual",Ace),H("lessThan",Cce),H("greaterThan",Rce),H("lessThanEqual",Ece),H("greaterThanEqual",Pce),H("and",Fce),H("or",Lce),H("not",Ice),H("xor",zce),H("bitAnd",Bce),H("bitNot",Vce),H("bitOr",Oce),H("bitXor",kce),H("shiftLeft",Uce),H("shiftRight",Dce),H("incrementBefore",$ce),H("decrementBefore",Gce),H("increment",jce),H("decrement",Wce);const Hce=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),gy(t,e)),qce=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),gy(Pd(t),Pd(e)));H("remainder",Hce),H("modInt",qce);var U=class Mt extends ti{static get type(){return"MathNode"}constructor(e,r,s=null,i=null){if(super(),(e===Mt.MAX||e===Mt.MIN)&&arguments.length>3){let n=new Mt(e,r,s);for(let a=2;a<arguments.length-1;a++)n=new Mt(e,n,arguments[a]);r=n,s=arguments[arguments.length-1],i=null}this.method=e,this.aNode=r,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(e){let r=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(i)?0:e.getTypeLength(i);return n>a&&n>o?r:a>o?s:o>n?i:r}getNodeType(e){let r=this.method;return r===Mt.LENGTH||r===Mt.DISTANCE||r===Mt.DOT?"float":r===Mt.CROSS?"vec3":r===Mt.ALL||r===Mt.ANY?"bool":r===Mt.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:r,bNode:s,method:i}=this,n=null;if(i===Mt.ONE_MINUS)n=Kb(1,r);else if(i===Mt.RECIPROCAL)n=PI(1,r);else if(i===Mt.DIFFERENCE)n=KT(Kb(r,s));else if(i===Mt.TRANSFORM_DIRECTION){let a=r,o=s;e.isMatrix(a.getNodeType(e))?o=vl(Wh(o),0):a=vl(Wh(a),0);let l=QT(a,o).xyz;n=LI(l)}return n===null?super.setup(e):n}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let i=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(i===Mt.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{let c=[];return i===Mt.CROSS?c.push(o.build(e,n),l.build(e,n)):u===ll&&i===Mt.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===ll&&(i===Mt.MIN||i===Mt.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):i===Mt.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):i===Mt.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Hb&&i===Mt.ATAN&&l!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===Mt.DFDX||i===Mt.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${e.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(e,a)),l!==null&&c.push(l.build(e,a)),h!==null&&c.push(h.build(e,a))),e.format(`${e.getMethod(i,n)}( ${c.join(", ")} )`,n,r)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};U.ALL="all",U.ANY="any",U.RADIANS="radians",U.DEGREES="degrees",U.EXP="exp",U.EXP2="exp2",U.LOG="log",U.LOG2="log2",U.SQRT="sqrt",U.INVERSE_SQRT="inversesqrt",U.FLOOR="floor",U.CEIL="ceil",U.NORMALIZE="normalize",U.FRACT="fract",U.SIN="sin",U.COS="cos",U.TAN="tan",U.ASIN="asin",U.ACOS="acos",U.ATAN="atan",U.ABS="abs",U.SIGN="sign",U.LENGTH="length",U.NEGATE="negate",U.ONE_MINUS="oneMinus",U.DFDX="dFdx",U.DFDY="dFdy",U.ROUND="round",U.RECIPROCAL="reciprocal",U.TRUNC="trunc",U.FWIDTH="fwidth",U.TRANSPOSE="transpose",U.BITCAST="bitcast",U.EQUALS="equals",U.MIN="min",U.MAX="max",U.STEP="step",U.REFLECT="reflect",U.DISTANCE="distance",U.DIFFERENCE="difference",U.DOT="dot",U.CROSS="cross",U.POW="pow",U.TRANSFORM_DIRECTION="transformDirection",U.MIX="mix",U.CLAMP="clamp",U.REFRACT="refract",U.SMOOTHSTEP="smoothstep",U.FACEFORWARD="faceforward";const Xce=zn(Math.PI);zn(Math.PI*2);const Yce=ue(U,U.ALL).setParameterLength(1),Zce=ue(U,U.ANY).setParameterLength(1),Jce=ue(U,U.RADIANS).setParameterLength(1),Qce=ue(U,U.DEGREES).setParameterLength(1),Kce=ue(U,U.EXP).setParameterLength(1),ede=ue(U,U.EXP2).setParameterLength(1),tde=ue(U,U.LOG).setParameterLength(1),rde=ue(U,U.LOG2).setParameterLength(1),sde=ue(U,U.SQRT).setParameterLength(1),ide=ue(U,U.INVERSE_SQRT).setParameterLength(1),nde=ue(U,U.FLOOR).setParameterLength(1),ade=ue(U,U.CEIL).setParameterLength(1),LI=ue(U,U.NORMALIZE).setParameterLength(1),II=ue(U,U.FRACT).setParameterLength(1),zI=ue(U,U.SIN).setParameterLength(1),ode=ue(U,U.COS).setParameterLength(1),lde=ue(U,U.TAN).setParameterLength(1),ude=ue(U,U.ASIN).setParameterLength(1),hde=ue(U,U.ACOS).setParameterLength(1),BI=ue(U,U.ATAN).setParameterLength(1,2),KT=ue(U,U.ABS).setParameterLength(1),VI=ue(U,U.SIGN).setParameterLength(1),cde=ue(U,U.LENGTH).setParameterLength(1),dde=ue(U,U.NEGATE).setParameterLength(1),pde=ue(U,U.ONE_MINUS).setParameterLength(1),mde=ue(U,U.DFDX).setParameterLength(1),fde=ue(U,U.DFDY).setParameterLength(1),gde=ue(U,U.ROUND).setParameterLength(1),yde=ue(U,U.RECIPROCAL).setParameterLength(1),xde=ue(U,U.TRUNC).setParameterLength(1),bde=ue(U,U.FWIDTH).setParameterLength(1),vde=ue(U,U.TRANSPOSE).setParameterLength(1),Tde=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),FI(t,e)),wde=ue(U,U.MIN).setParameterLength(2,1/0),Sde=ue(U,U.MAX).setParameterLength(2,1/0),Mde=ue(U,U.STEP).setParameterLength(2),_de=ue(U,U.REFLECT).setParameterLength(2),Nde=ue(U,U.DISTANCE).setParameterLength(2),Ade=ue(U,U.DIFFERENCE).setParameterLength(2),bp=ue(U,U.DOT).setParameterLength(2),Cde=ue(U,U.CROSS).setParameterLength(2),OI=ue(U,U.POW).setParameterLength(2),Rde=ue(U,U.POW,2).setParameterLength(1),Ede=ue(U,U.POW,3).setParameterLength(1),Pde=ue(U,U.POW,4).setParameterLength(1),Fde=ue(U,U.TRANSFORM_DIRECTION).setParameterLength(2),Lde=t=>QT(VI(t),OI(KT(t),1/3)),Ide=t=>bp(t,t),yy=ue(U,U.MIX).setParameterLength(3),kI=(t,e=0,r=1)=>Ne(new U(U.CLAMP,Ne(t),Ne(e),Ne(r))),zde=t=>kI(t),Bde=ue(U,U.REFRACT).setParameterLength(3),Vde=ue(U,U.SMOOTHSTEP).setParameterLength(3),Ode=ue(U,U.FACEFORWARD).setParameterLength(3),kde=Ei(([t])=>{let e=12.9898,r=78.233,s=43758.5453,i=bp(t.xy,CI(e,r)),n=gy(i,Xce);return II(zI(n).mul(s))}),Ude=(t,e,r)=>yy(e,r,t),Dde=(t,e,r)=>Vde(e,r,t),$de=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),BI(t,e));H("all",Yce),H("any",Zce),H("equals",Tde),H("radians",Jce),H("degrees",Qce),H("exp",Kce),H("exp2",ede),H("log",tde),H("log2",rde),H("sqrt",sde),H("inverseSqrt",ide),H("floor",nde),H("ceil",ade),H("normalize",LI),H("fract",II),H("sin",zI),H("cos",ode),H("tan",lde),H("asin",ude),H("acos",hde),H("atan",BI),H("abs",KT),H("sign",VI),H("length",cde),H("lengthSq",Ide),H("negate",dde),H("oneMinus",pde),H("dFdx",mde),H("dFdy",fde),H("round",gde),H("reciprocal",yde),H("trunc",xde),H("fwidth",bde),H("atan2",$de),H("min",wde),H("max",Sde),H("step",Mde),H("reflect",_de),H("distance",Nde),H("dot",bp),H("cross",Cde),H("pow",OI),H("pow2",Rde),H("pow3",Ede),H("pow4",Pde),H("transformDirection",Fde),H("mix",Ude),H("clamp",kI),H("refract",Bde),H("smoothstep",Dde),H("faceForward",Ode),H("difference",Ade),H("saturate",zde),H("cbrt",Lde),H("transpose",vde),H("rand",kde);var NN=class extends ti{static get type(){return"ArrayNode"}constructor(t,e,r=null){super(t),this.count=e,this.values=r,this.isArrayNode=!0}getNodeType(t){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(t)),this.nodeType}getElementType(t){return this.getNodeType(t)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}};const Gde=(...t)=>{let e;if(t.length===1){let r=t[0];e=new NN(null,r.length,r)}else{let r=t[0],s=t[1];e=new NN(r,s)}return Ne(e)};H("toArray",(t,e)=>Gde(Array(e).fill(t)));var UI=class extends yr{static get type(){return"UniformGroupNode"}constructor(t,e=!1,r=1){super("string"),this.name=t,this.shared=e,this.order=r,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}};const jde=t=>new UI(t),Wde=(t,e=0)=>new UI(t,!0,e),Hde=Wde("render"),qde=jde("object");var Xde=class extends XT{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=qde}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){let r=this.getSelf();return t=t.bind(r),super.onUpdate(s=>{let i=t(s,r);i!==void 0&&(this.value=i)},e)}generate(t,e){let r=this.getNodeType(t),s=this.getUniformHash(t),i=t.getNodeFromHash(s);i===void 0&&(t.setHashNode(this,s),i=this);let n=i.getInputType(t),a=t.getUniformFromNode(i,n,t.shaderStage,this.name||t.context.label),o=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(o,r,e)}};const Yde=(t,e)=>{let r=ace(e||t),s=t;return Ne(new Xde(s,r))};var Zde=class extends yr{static get type(){return"PropertyNode"}constructor(t,e=null,r=!1){super(t),this.name=e,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}};const Jde=(t,e)=>Ne(new Zde(t,e));var Qde=class extends ti{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e==="void"?"void":this.targetNode.getNodeType(t)}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let r=t.getTypeLength(e.node.getNodeType(t));return yp.join("").slice(0,r)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:r}=this,s=t.getNodeProperties(this);s.sourceNode=r,s.targetNode=e.context({assign:!0})}generate(t,e){let{targetNode:r,sourceNode:s}=t.getNodeProperties(this),i=this.needsSplitAssign(t),n=r.getNodeType(t),a=r.build(t),o=s.build(t,n),l=s.getNodeType(t),h=t.getDataFromNode(this),u;if(h.initialized===!0)e!=="void"&&(u=a);else if(i){let c=t.getVarFromNode(this,null,n),d=t.getPropertyName(c);t.addLineFlowCode(`${d} = ${o}`,this);let p=r.node,m=p.node.context({assign:!0}),f=m.build(t);for(let g=0;g<p.components.length;g++){let b=p.components[g];t.addLineFlowCode(`${f}.${b} = ${d}[ ${g} ]`,this)}e!=="void"&&(u=a)}else u=`${a} = ${o}`,(e==="void"||l==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=a));return h.initialized=!0,t.format(u,n,e)}};const Kde=ue(Qde).setParameterLength(2);H("assign",Kde);var epe=class extends ti{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){let e=[],r=this.functionNode,s=r.getInputs(t),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(t):o.build(t,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(zn(0));for(let o=0;o<i.length;o++)e.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),e.push(n(zn(0),o))):e.push(n(l,o))}return`${r.build(t,"property")}( ${e.join(", ")} )`}};const tpe=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?wf(e):fy(e[0]),Ne(new epe(Ne(t),e)));H("call",tpe);var rpe=class extends yr{static get type(){return"ConditionalNode"}constructor(t,e,r=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=r}getNodeType(t){let{ifNode:e,elseNode:r}=t.getNodeProperties(this);if(e===void 0)return this.setup(t),this.getNodeType(t);let s=e.getNodeType(t);if(r!==null){let i=r.getNodeType(t);if(t.getTypeLength(i)>t.getTypeLength(s))return i}return s}setup(t){let e=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=t.context.nodeBlock;t.getDataFromNode(r).parentNodeBlock=i,s!==null&&(t.getDataFromNode(s).parentNodeBlock=i);let n=t.getNodeProperties(this);n.condNode=e,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(t,e){let r=this.getNodeType(t),s=t.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?Jde(r).build(t):"";s.nodeProperty=h;let u=i.build(t,"bool");t.addFlowCode(`
491
491
  ${t.tab}if ( ${u} ) {
492
492
 
493
493
  `).addFlowTab();let c=n.build(t,r);if(c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),t.removeFlowTab().addFlowCode(t.tab+" "+c+`