shaders 2.0.632 → 2.0.634
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +60 -60
- package/dist/react/index.js.map +1 -1
- package/dist/svelte/components/Circle.svelte +2 -2
- package/dist/svelte/components/DotGrid.svelte +2 -2
- package/dist/svelte/components/FilmGrain.svelte +2 -2
- package/dist/svelte/components/GlassTiles.svelte +2 -2
- package/dist/svelte/components/Grayscale.svelte +2 -2
- package/dist/svelte/components/HueShift.svelte +2 -2
- package/dist/svelte/components/Invert.svelte +2 -2
- package/dist/svelte/components/LinearGradient.svelte +2 -2
- package/dist/svelte/components/MouseDistortion.svelte +2 -2
- package/dist/svelte/components/Posterize.svelte +2 -2
- package/dist/svelte/components/Saturation.svelte +2 -2
- package/dist/svelte/components/SolidColor.svelte +2 -2
- package/dist/svelte/components/Swirl.svelte +2 -2
- package/dist/svelte/components/Twirl.svelte +2 -2
- package/dist/svelte/components/Vibrance.svelte +2 -2
- package/dist/svelte/engine/component.template.svelte +2 -2
- package/dist/vue/components/Circle.vue.d.ts +0 -3
- package/dist/vue/components/Circle.vue.d.ts.map +1 -1
- package/dist/vue/components/DotGrid.vue.d.ts +0 -3
- package/dist/vue/components/DotGrid.vue.d.ts.map +1 -1
- package/dist/vue/components/FilmGrain.vue.d.ts +0 -3
- package/dist/vue/components/FilmGrain.vue.d.ts.map +1 -1
- package/dist/vue/components/GlassTiles.vue.d.ts +0 -3
- package/dist/vue/components/GlassTiles.vue.d.ts.map +1 -1
- package/dist/vue/components/Grayscale.vue.d.ts +0 -3
- package/dist/vue/components/Grayscale.vue.d.ts.map +1 -1
- package/dist/vue/components/HueShift.vue.d.ts +0 -3
- package/dist/vue/components/HueShift.vue.d.ts.map +1 -1
- package/dist/vue/components/Invert.vue.d.ts +0 -3
- package/dist/vue/components/Invert.vue.d.ts.map +1 -1
- package/dist/vue/components/LinearGradient.vue.d.ts +0 -3
- package/dist/vue/components/LinearGradient.vue.d.ts.map +1 -1
- package/dist/vue/components/MouseDistortion.vue.d.ts +0 -3
- package/dist/vue/components/MouseDistortion.vue.d.ts.map +1 -1
- package/dist/vue/components/Posterize.vue.d.ts +0 -3
- package/dist/vue/components/Posterize.vue.d.ts.map +1 -1
- package/dist/vue/components/Saturation.vue.d.ts +0 -3
- package/dist/vue/components/Saturation.vue.d.ts.map +1 -1
- package/dist/vue/components/SolidColor.vue.d.ts +0 -3
- package/dist/vue/components/SolidColor.vue.d.ts.map +1 -1
- package/dist/vue/components/Swirl.vue.d.ts +0 -3
- package/dist/vue/components/Swirl.vue.d.ts.map +1 -1
- package/dist/vue/components/Twirl.vue.d.ts +0 -3
- package/dist/vue/components/Twirl.vue.d.ts.map +1 -1
- package/dist/vue/components/Vibrance.vue.d.ts +0 -3
- package/dist/vue/components/Vibrance.vue.d.ts.map +1 -1
- package/dist/vue/index.js +33 -33
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -147,7 +147,7 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
147
147
|
* @license
|
|
148
148
|
* Copyright 2010-2025 Three.js Authors
|
|
149
149
|
* SPDX-License-Identifier: MIT
|
|
150
|
-
*/y.BRDF_GGX;y.BRDF_Lambert;y.BasicShadowFilter;y.Break;y.Continue;y.DFGApprox;y.D_GGX;y.Discard;y.EPSILON;y.F_Schlick;y.Fn;y.INFINITY;y.If;y.Switch;y.Loop;y.NodeShaderStage;y.NodeType;y.NodeUpdateType;y.NodeAccess;y.PCFShadowFilter;y.PCFSoftShadowFilter;y.PI;y.PI2;y.Return;y.Schlick_to_F0;y.ScriptableNodeResources;y.ShaderNode;y.TBNViewMatrix;y.VSMShadowFilter;y.V_GGX_SmithCorrelated;y.abs;y.acesFilmicToneMapping;y.acos;y.add;y.addNodeElement;y.agxToneMapping;y.all;y.alphaT;y.and;y.anisotropy;y.anisotropyB;y.anisotropyT;y.any;y.append;y.array;y.arrayBuffer;y.asin;y.assign;y.atan;y.atan2;y.atomicAdd;y.atomicAnd;y.atomicFunc;y.atomicMax;y.atomicMin;y.atomicOr;y.atomicStore;y.atomicSub;y.atomicXor;y.atomicLoad;y.attenuationColor;y.attenuationDistance;y.attribute;y.attributeArray;y.backgroundBlurriness;y.backgroundIntensity;y.backgroundRotation;y.batch;y.billboarding;y.bitAnd;y.bitNot;y.bitOr;y.bitXor;y.bitangentGeometry;y.bitangentLocal;y.bitangentView;y.bitangentWorld;y.bitcast;y.blendBurn;y.blendColor;y.blendDodge;y.blendOverlay;y.blendScreen;y.blur;y.bool;y.buffer;y.bufferAttribute;y.bumpMap;y.burn;y.bvec2;y.bvec3;y.bvec4;y.bypass;y.cache;y.call;y.cameraFar;y.cameraIndex;y.cameraNear;y.cameraNormalMatrix;y.cameraPosition;y.cameraProjectionMatrix;y.cameraProjectionMatrixInverse;y.cameraViewMatrix;y.cameraWorldMatrix;y.cbrt;y.cdl;y.ceil;y.checker;y.cineonToneMapping;y.clamp;y.clearcoat;y.clearcoatRoughness;y.code;y.color;y.colorSpaceToWorking;y.colorToDirection;y.compute;y.computeSkinning;y.cond;y.Const;y.context;y.convert;y.convertColorSpace;y.convertToTexture;y.cos;y.cross;y.cubeTexture;y.dFdx;y.dFdy;y.dashSize;y.debug;y.decrement;y.decrementBefore;y.defaultBuildStages;y.defaultShaderStages;y.defined;y.degrees;y.deltaTime;y.densityFog;y.densityFogFactor;y.depth;y.depthPass;y.difference;y.diffuseColor;y.directPointLight;y.directionToColor;y.dispersion;y.distance;y.div;y.dodge;y.dot;y.drawIndex;y.dynamicBufferAttribute;y.element;y.emissive;y.equal;y.equals;y.equirectUV;y.exp;y.exp2;y.expression;y.faceDirection;y.faceForward;y.faceforward;y.float;y.floor;y.fog;y.fract;y.frameGroup;y.frameId;y.frontFacing;y.fwidth;y.gain;y.gapSize;y.getConstNodeType;y.getCurrentStack;y.getDirection;y.getDistanceAttenuation;y.getGeometryRoughness;y.getNormalFromDepth;y.getParallaxCorrectNormal;y.getRoughness;y.getScreenPosition;y.getShIrradianceAt;y.getTextureIndex;y.getViewPosition;y.getShadowMaterial;y.getShadowRenderObjectFunction;y.glsl;y.glslFn;y.grayscale;y.greaterThan;y.greaterThanEqual;y.hash;y.highpModelNormalViewMatrix;y.highpModelViewMatrix;y.hue;y.increment;y.incrementBefore;y.instance;y.instanceIndex;y.instancedArray;y.instancedBufferAttribute;y.instancedDynamicBufferAttribute;y.instancedMesh;y.int;y.inverseSqrt;y.inversesqrt;y.invocationLocalIndex;y.invocationSubgroupIndex;y.ior;y.iridescence;y.iridescenceIOR;y.iridescenceThickness;y.ivec2;y.ivec3;y.ivec4;y.js;y.label;y.length;y.lengthSq;y.lessThan;y.lessThanEqual;y.lightPosition;y.lightShadowMatrix;y.lightTargetDirection;y.lightTargetPosition;y.lightViewPosition;y.lightingContext;y.lights;y.linearDepth;y.linearToneMapping;y.localId;y.globalId;y.log;y.log2;y.logarithmicDepthToViewZ;y.loop;y.luminance;y.mediumpModelViewMatrix;y.mat2;y.mat3;y.mat4;y.matcapUV;y.materialAO;y.materialAlphaTest;y.materialAnisotropy;y.materialAnisotropyVector;y.materialAttenuationColor;y.materialAttenuationDistance;y.materialClearcoat;y.materialClearcoatNormal;y.materialClearcoatRoughness;y.materialColor;y.materialDispersion;y.materialEmissive;y.materialIOR;y.materialIridescence;y.materialIridescenceIOR;y.materialIridescenceThickness;y.materialLightMap;y.materialLineDashOffset;y.materialLineDashSize;y.materialLineGapSize;y.materialLineScale;y.materialLineWidth;y.materialMetalness;y.materialNormal;y.materialOpacity;y.materialPointSize;y.materialReference;y.materialReflectivity;y.materialRefractionRatio;y.materialRotation;y.materialRoughness;y.materialSheen;y.materialSheenRoughness;y.materialShininess;y.materialSpecular;y.materialSpecularColor;y.materialSpecularIntensity;y.materialSpecularStrength;y.materialThickness;y.materialTransmission;y.max;y.maxMipLevel;y.metalness;y.min;y.mix;y.mixElement;y.mod;y.modInt;y.modelDirection;y.modelNormalMatrix;y.modelPosition;y.modelRadius;y.modelScale;y.modelViewMatrix;y.modelViewPosition;y.modelViewProjection;y.modelWorldMatrix;y.modelWorldMatrixInverse;y.morphReference;y.mrt;y.mul;y.mx_aastep;y.mx_cell_noise_float;y.mx_contrast;y.mx_fractal_noise_float;y.mx_fractal_noise_vec2;y.mx_fractal_noise_vec3;y.mx_fractal_noise_vec4;y.mx_hsvtorgb;y.mx_noise_float;y.mx_noise_vec3;y.mx_noise_vec4;y.mx_ramplr;y.mx_ramptb;y.mx_rgbtohsv;y.mx_safepower;y.mx_splitlr;y.mx_splittb;y.mx_srgb_texture_to_lin_rec709;y.mx_transform_uv;y.mx_worley_noise_float;y.mx_worley_noise_vec2;y.mx_worley_noise_vec3;y.namespace;y.negate;y.neutralToneMapping;y.nodeArray;y.nodeImmutable;y.nodeObject;y.nodeObjects;y.nodeProxy;y.normalFlat;y.normalGeometry;y.normalLocal;y.normalMap;y.normalView;y.normalWorld;y.normalize;y.not;y.notEqual;y.numWorkgroups;y.objectDirection;y.objectGroup;y.objectPosition;y.objectRadius;y.objectScale;y.objectViewPosition;y.objectWorldMatrix;y.oneMinus;y.or;y.orthographicDepthToViewZ;y.oscSawtooth;y.oscSine;y.oscSquare;y.oscTriangle;y.output;y.outputStruct;y.overlay;y.overloadingFn;y.parabola;y.parallaxDirection;y.parallaxUV;y.parameter;y.pass;y.passTexture;y.pcurve;y.perspectiveDepthToViewZ;y.pmremTexture;y.pointUV;y.pointWidth;y.positionGeometry;y.positionLocal;y.positionPrevious;y.positionView;y.positionViewDirection;y.positionWorld;y.positionWorldDirection;y.posterize;y.pow;y.pow2;y.pow3;y.pow4;y.premult;y.property;y.radians;y.rand;y.range;y.rangeFog;y.rangeFogFactor;y.reciprocal;y.lightProjectionUV;y.reference;y.referenceBuffer;y.reflect;y.reflectVector;y.reflectView;y.reflector;y.refract;y.refractVector;y.refractView;y.reinhardToneMapping;y.remainder;y.remap;y.remapClamp;y.renderGroup;y.renderOutput;y.rendererReference;y.rotate;y.rotateUV;y.roughness;y.round;y.rtt;y.sRGBTransferEOTF;y.sRGBTransferOETF;y.sampler;y.samplerComparison;y.saturate;y.saturation;y.screen;y.screenCoordinate;y.screenSize;y.screenUV;y.scriptable;y.scriptableValue;y.select;y.setCurrentStack;y.shaderStages;y.shadow;y.pointShadow;y.shadowPositionWorld;y.sharedUniformGroup;y.shapeCircle;y.sheen;y.sheenRoughness;y.shiftLeft;y.shiftRight;y.shininess;y.sign;y.sin;y.sinc;y.skinning;y.smoothstep;y.smoothstepElement;y.specularColor;y.specularF90;y.spherizeUV;y.split;y.spritesheetUV;y.sqrt;y.stack;y.step;y.storage;y.storageBarrier;y.storageObject;y.storageTexture;y.string;y.struct;y.sub;y.subgroupIndex;y.subgroupSize;y.tan;y.tangentGeometry;y.tangentLocal;y.tangentView;y.tangentWorld;y.temp;y.texture;y.texture3D;y.textureBarrier;y.textureBicubic;y.textureCubeUV;y.textureLoad;y.textureSize;y.textureStore;y.thickness;y.time;y.timerDelta;y.timerGlobal;y.timerLocal;y.toneMapping;y.toneMappingExposure;y.toonOutlinePass;y.transformDirection;y.transformNormal;y.transformNormalToView;y.transformedBentNormalView;y.transformedBitangentView;y.transformedBitangentWorld;y.transformedClearcoatNormalView;y.transformedNormalView;y.transformedNormalWorld;y.transformedTangentView;y.transformedTangentWorld;y.transmission;y.transpose;y.triNoise3D;y.triplanarTexture;y.triplanarTextures;y.trunc;y.tslFn;y.uint;y.uniform;y.uniformCubeTexture;y.uniformArray;y.uniformGroup;y.uniformTexture;y.uniforms;y.unpremult;y.userData;y.uv;y.uvec2;y.uvec3;y.uvec4;y.Var;y.varying;y.varyingProperty;y.vec2;y.vec3;const Ltt=y.vec4;y.vectorComponents;y.velocity;y.vertexColor;y.vertexIndex;y.vibrance;y.viewZToLogarithmicDepth;y.viewZToOrthographicDepth;y.viewZToPerspectiveDepth;y.viewport;y.viewportBottomLeft;y.viewportCoordinate;y.viewportDepthTexture;y.viewportLinearDepth;y.viewportMipTexture;y.viewportResolution;y.viewportSafeUV;y.viewportSharedTexture;y.viewportSize;y.viewportTexture;y.viewportTopLeft;y.viewportUV;y.wgsl;y.wgslFn;y.workgroupArray;y.workgroupBarrier;y.workgroupId;y.workingToColorSpace;y.xor;const kt=H.createContext(null),Ptt=({children:r,hideNotice:t=!1,style:e={},className:s="",...i})=>{const n=H.useRef(null),a=H.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=H.useRef(null);o.current===null&&(o.current=Ar.shaderRenderer());const l=H.useMemo(()=>(f,x,b,w,S=null)=>{if(x===null){try{o.current.removeNode(f)}catch(_){console.warn("Error removing node:",_)}return}try{o.current.registerNode(f,x,b,w,S)}catch(_){console.error("Error registering node:",_,{id:f,parentId:b,metadata:w})}},[]),h=H.useMemo(()=>(f,x,b)=>{try{o.current.updateUniformValue(f,x,b)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=H.useMemo(()=>(f,x)=>{try{o.current.updateNodeMetadata(f,x)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=H.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=H.useRef(!1),p=H.useRef(!1);H.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const x=o.current;return x.initialize({canvas:f}).then(()=>{x.registerNode(a,({childNode:b})=>b||Ltt(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,t||x.showLicenseWarning()}).catch(b=>{console.error("[Shader] Initialization failed:",b),p.current=!1}),()=>{try{x.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(b){console.warn("[Shader] Error during cleanup:",b)}}},[a,t]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof e=="object"?e:{}};return hr.jsx(kt.Provider,{value:c,children:hr.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof e=="object"?e:{}},className:s,...i,children:[hr.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),r]})})};function Ftt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const _A={blendMode:"normal",opacity:1};try{pl&&pl.props&&Object.entries(pl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(_A[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Ott=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Ftt(r,_A),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(pl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,pl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},vl={name:"DotGrid",props:{color:{type:String,default:"#ffffff",description:"Dot color",transform:Qi},density:{type:Number,default:100,description:"Grid density (number of dots)"},dotSize:{type:Number,default:.2,description:"Size of each dot (0-1)"}},fragmentNode:({uniforms:r})=>{let{viewportUV:t,vec4:e,vec3:s,vec2:i,smoothstep:n,length:a,floor:o,float:l,viewportSize:h}=Rr,u=t,c=r.density.uniform,d=r.dotSize.uniform,p=r.color.uniform,m=h,f=m.x.div(m.y),x=i(u.x.mul(f),u.y),b=x.mul(c),w=b.sub(o(b)),S=a(w.sub(.5)),_=l(1).sub(n(d.mul(.45),d.mul(.5),S)),E=s(p).mul(_);return e(E,_)}};function ktt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const AA={blendMode:"normal",opacity:1};try{vl&&vl.props&&Object.entries(vl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(AA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Btt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>ktt(r,AA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(vl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,vl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},wl={name:"FilmGrain",props:{intensity:{type:Number,default:.25,description:"Grain intensity (0-1)"},power:{type:Number,default:.645,description:"Controls blending based on brightness"},speed:{type:Number,default:.5,description:"Animation speed of grain noise"}},fragmentNode:({uniforms:r,childNode:t})=>{let e=t||Uu(0,0,0,0),s=h0(),i=p=>wg(kn(bg(p,c0(12.9898,78.233))).mul(43758.5453)),n=p=>bg(p,Uu(.299,.587,.114,0)),a=i(s).add(u0.mul(r.speed.uniform)),o=wg(kn(a.mul(43758.5453))),l=dl(vg(.5),vg(.75),o).mul(r.intensity.uniform),h=DN(n(e),r.power.uniform),u=e.mul(l),c=BN(h,0,1),d=dl(u,e,c);return Uu(d.x,d.y,d.z,e.w)}};function Dtt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const zA={blendMode:"normal",opacity:1};try{wl&&wl.props&&Object.entries(wl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(zA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Utt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${wl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Dtt(r,zA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(wl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,wl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},fd=new WeakMap,Ml={name:"glassTiles",props:{intensity:{type:Number,default:1,description:"The intensity of the glass tiles effect"},tileCount:{type:Number,default:100,description:"Number of tiles across the shortest dimension"}},fragmentNode:({uniforms:r,childNode:t,onCleanup:e,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,uv:d,uniform:p}=Rr;if(!t)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(t),f=p(1),x=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};x();let b=fd.get(s);b||(b=new ResizeObserver(St=>{let Tt=St[0];if(!Tt)return;let{width:Ut,height:Lt}=Tt.contentRect,ft=window.devicePixelRatio||1;m.setSize(Ut*ft,Lt*ft),x()}),b.observe(s),fd.set(s,b)),e(()=>{let St=fd.get(s);St&&(St.disconnect(),fd.delete(s))});let w=d(),S=r.intensity.uniform,_=r.tileCount.uniform,E=i(f.greaterThanEqual(1).select(o(_,f),_),f.lessThan(1).select(l(_,f),_)),z=l(a(o(w,E)),E),A=h(w,z),L=i(.5,.5),tt=o(S,.025),nt=l(A,l(i(1),E)),it=h(nt,L),wt=o(it,tt),ht=u(A,wt),yt=u(ht,z);return n(m.sample(yt))}};function $tt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const CA={blendMode:"normal",opacity:1};try{Ml&&Ml.props&&Object.entries(Ml.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(CA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const jtt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Ml.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>$tt(r,CA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Ml,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Ml.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},gd={VERTEX:"vertex"},Ln={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Zh=["x","y","z","w"],vr="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 iw=1234567;const EA=Math.PI/180,VA=180/Math.PI;function Ld(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(vr[r&255]+vr[r>>8&255]+vr[r>>16&255]+vr[r>>24&255]+"-"+vr[t&255]+vr[t>>8&255]+"-"+vr[t>>16&15|64]+vr[t>>24&255]+"-"+vr[e&63|128]+vr[e>>8&255]+"-"+vr[e>>16&255]+vr[e>>24&255]+vr[s&255]+vr[s>>8&255]+vr[s>>16&255]+vr[s>>24&255]).toLowerCase()}function jt(r,t,e){return Math.max(t,Math.min(e,r))}function bx(r,t){return(r%t+t)%t}function Wtt(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function qtt(r,t,e){return r===t?0:(e-r)/(t-r)}function Gu(r,t,e){return(1-e)*r+e*t}function Htt(r,t,e,s){return Gu(r,t,1-Math.exp(-e*s))}function Gtt(r,t=1){return t-Math.abs(bx(r,t*2)-t)}function Xtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Ytt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Ztt(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Jtt(r,t){return r+Math.random()*(t-r)}function Qtt(r){return r*(.5-Math.random())}function Ktt(r){r!==void 0&&(iw=r);let t=iw+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function tet(r){return r*EA}function eet(r){return r*VA}function ret(r){return(r&r-1)==0&&r!==0}function set(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function iet(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function net(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Xs(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Zt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const aet={DEG2RAD:EA,RAD2DEG:VA,generateUUID:Ld,clamp:jt,euclideanModulo:bx,mapLinear:Wtt,inverseLerp:qtt,lerp:Gu,damp:Htt,pingpong:Gtt,smoothstep:Xtt,smootherstep:Ytt,randInt:Ztt,randFloat:Jtt,randFloatSpread:Qtt,seededRandom:Ktt,degToRad:tet,radToDeg:eet,isPowerOfTwo:ret,ceilPowerOfTwo:set,floorPowerOfTwo:iet,setQuaternionFromProperEuler:net,normalize:Zt,denormalize:Xs},Yg=0,oet=1015,Zg="",$s="srgb",nw="srgb-linear",aw="linear",Xu="srgb",yp=35044,Ra=2e3,Jg=2001;var Jh=class RA{constructor(t,e,s,i,n,a,o,l,h){RA.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,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(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.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],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],E=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*E,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*E,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*E,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*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 t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,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+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Zf.makeScale(t,e)),this}rotate(t){return this.premultiply(Zf.makeRotation(-t)),this}translate(t,e){return this.premultiply(Zf.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Zf=new Jh,ow={};function lw(r){r in ow||(ow[r]=!0,console.warn(r))}const uw=new Jh().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hw=new Jh().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uet(){let r={enabled:!0,workingColorSpace:nw,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Xu&&(i.r=Tl(i.r),i.g=Tl(i.g),i.b=Tl(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===Xu&&(i.r=Nl(i.r),i.g=Nl(i.g),i.b=Nl(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===Zg?aw: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 lw("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return lw("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[nw]:{primaries:t,whitePoint:s,transfer:aw,toXYZ:uw,fromXYZ:hw,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:$s},outputColorSpaceConfig:{drawingBufferColorSpace:$s}},[$s]:{primaries:t,whitePoint:s,transfer:Xu,toXYZ:uw,fromXYZ:hw,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:$s}}}),r}const ke=uet();function Tl(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function Nl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}const IA={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},En={h:0,s:0,l:0},yd={h:0,s:0,l:0};function Jf(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var vx=class{constructor(r,t,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,t,e)}set(r,t,e){if(t===void 0&&e===void 0){let s=r;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(r,t,e);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,t=$s){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,ke.colorSpaceToWorking(this,t),this}setRGB(r,t,e,s=ke.workingColorSpace){return this.r=r,this.g=t,this.b=e,ke.colorSpaceToWorking(this,s),this}setHSL(r,t,e,s=ke.workingColorSpace){if(r=bx(r,1),t=jt(t,0,1),e=jt(e,0,1),t===0)this.r=this.g=this.b=e;else{let i=e<=.5?e*(1+t):e+t-e*t,n=2*e-i;this.r=Jf(n,i,r+1/3),this.g=Jf(n,i,r),this.b=Jf(n,i,r-1/3)}return ke.colorSpaceToWorking(this,s),this}setStyle(r,t=$s){function e(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+r+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(r)){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 e(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+r)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(r)){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,t);if(n===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,t);return this}setColorName(r,t=$s){let e=IA[r.toLowerCase()];return e===void 0?console.warn("THREE.Color: Unknown color "+r):this.setHex(e,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=Tl(r.r),this.g=Tl(r.g),this.b=Tl(r.b),this}copyLinearToSRGB(r){return this.r=Nl(r.r),this.g=Nl(r.g),this.b=Nl(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=$s){return ke.workingToColorSpace(wr.copy(this),r),Math.round(jt(wr.r*255,0,255))*65536+Math.round(jt(wr.g*255,0,255))*256+Math.round(jt(wr.b*255,0,255))}getHexString(r=$s){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,t=ke.workingColorSpace){ke.workingToColorSpace(wr.copy(this),t);let e=wr.r,s=wr.g,i=wr.b,n=Math.max(e,s,i),a=Math.min(e,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 e:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-e)/u+2;break;case i:o=(e-s)/u+4;break}o/=6}return r.h=o,r.s=l,r.l=h,r}getRGB(r,t=ke.workingColorSpace){return ke.workingToColorSpace(wr.copy(this),t),r.r=wr.r,r.g=wr.g,r.b=wr.b,r}getStyle(r=$s){ke.workingToColorSpace(wr.copy(this),r);let t=wr.r,e=wr.g,s=wr.b;return r===$s?`rgb(${Math.round(t*255)},${Math.round(e*255)},${Math.round(s*255)})`:`color(${r} ${t.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(r,t,e){return this.getHSL(En),this.setHSL(En.h+r,En.s+t,En.l+e)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,t){return this.r=r.r+t.r,this.g=r.g+t.g,this.b=r.b+t.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,t){return this.r+=(r.r-this.r)*t,this.g+=(r.g-this.g)*t,this.b+=(r.b-this.b)*t,this}lerpColors(r,t,e){return this.r=r.r+(t.r-r.r)*e,this.g=r.g+(t.g-r.g)*e,this.b=r.b+(t.b-r.b)*e,this}lerpHSL(r,t){this.getHSL(En),r.getHSL(yd);let e=Gu(En.h,yd.h,t),s=Gu(En.s,yd.s,t),i=Gu(En.l,yd.l,t);return this.setHSL(e,s,i),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){let t=this.r,e=this.g,s=this.b,i=r.elements;return this.r=i[0]*t+i[3]*e+i[6]*s,this.g=i[1]*t+i[4]*e+i[7]*s,this.b=i[2]*t+i[5]*e+i[8]*s,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,t=0){return this.r=r[t],this.g=r[t+1],this.b=r[t+2],this}toArray(r=[],t=0){return r[t]=this.r,r[t+1]=this.g,r[t+2]=this.b,r}fromBufferAttribute(r,t){return this.r=r.getX(t),this.g=r.getY(t),this.b=r.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const wr=new vx;vx.NAMES=IA;var het=class LA{constructor(t,e,s,i){LA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}},cet=class{constructor(r=0,t=0,e=0,s=1){this.isQuaternion=!0,this._x=r,this._y=t,this._z=e,this._w=s}static slerpFlat(r,t,e,s,i,n,a){let o=e[s+0],l=e[s+1],h=e[s+2],u=e[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){r[t+0]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u;return}if(a===1){r[t+0]=c,r[t+1]=d,r[t+2]=p,r[t+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,x=o*c+l*d+h*p+u*m,b=x>=0?1:-1,w=1-x*x;if(w>2**-52){let _=Math.sqrt(w),E=Math.atan2(_,x*b);f=Math.sin(f*E)/_,a=Math.sin(a*E)/_}let S=a*b;if(o=o*f+c*S,l=l*f+d*S,h=h*f+p*S,u=u*f+m*S,f===1-a){let _=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=_,l*=_,h*=_,u*=_}}r[t]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u}static multiplyQuaternionsFlat(r,t,e,s,i,n){let a=e[s],o=e[s+1],l=e[s+2],h=e[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return r[t]=a*p+h*u+o*d-l*c,r[t+1]=o*p+h*c+l*u-a*d,r[t+2]=l*p+h*d+a*c-o*u,r[t+3]=h*p-a*u-o*c-l*d,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,t,e,s){return this._x=r,this._y=t,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,t=!0){let e=r._x,s=r._y,i=r._z,n=r._order,a=Math.cos,o=Math.sin,l=a(e/2),h=a(s/2),u=a(i/2),c=o(e/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 t===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,t){let e=t/2,s=Math.sin(e);return this._x=r.x*s,this._y=r.y*s,this._z=r.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(r){let t=r.elements,e=t[0],s=t[4],i=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],c=e+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(e>a&&e>u){let d=2*Math.sqrt(1+e-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-e-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-e-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(r,t){let e=r.dot(t)+1;return e<2**-52?(e=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=e):(this._x=0,this._y=-r.z,this._z=r.y,this._w=e)):(this._x=r.y*t.z-r.z*t.y,this._y=r.z*t.x-r.x*t.z,this._z=r.x*t.y-r.y*t.x,this._w=e),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(jt(this.dot(r),-1,1)))}rotateTowards(r,t){let e=this.angleTo(r);if(e===0)return this;let s=Math.min(1,t/e);return this.slerp(r,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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x*=r,this._y*=r,this._z*=r,this._w*=r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,t){let e=r._x,s=r._y,i=r._z,n=r._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=e*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-e*l,this._z=i*h+n*l+e*o-s*a,this._w=n*h-e*a-s*o-i*l,this._onChangeCallback(),this}slerp(r,t){if(t===0)return this;if(t===1)return this.copy(r);let e=this._x,s=this._y,i=this._z,n=this._w,a=n*r._w+e*r._x+s*r._y+i*r._z;if(a<0?(this._w=-r._w,this._x=-r._x,this._y=-r._y,this._z=-r._z,a=-a):this.copy(r),a>=1)return this._w=n,this._x=e,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-t;return this._w=d*n+t*this._w,this._x=d*e+t*this._x,this._y=d*s+t*this._y,this._z=d*i+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(r,t,e){return this.copy(r).slerp(t,e)}random(){let r=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(r),s*Math.cos(r),i*Math.sin(t),i*Math.cos(t))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,t=0){return this._x=r[t],this._y=r[t+1],this._z=r[t+2],this._w=r[t+3],this._onChangeCallback(),this}toArray(r=[],t=0){return r[t]=this._x,r[t+1]=this._y,r[t+2]=this._z,r[t+3]=this._w,r}fromBufferAttribute(r,t){return this._x=r.getX(t),this._y=r.getY(t),this._z=r.getZ(t),this._w=r.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ei=class PA{constructor(t=0,e=0,s=0){PA.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(cw.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(cw.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+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(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Qf.copy(this).projectOnVector(t),this.sub(Qf)}reflect(t){return this.sub(Qf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(jt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Qf=new ei,cw=new cet;var FA=class Qg{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Qg.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,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]=x,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 Qg().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/Go.setFromMatrixColumn(t,0).length(),n=1/Go.setFromMatrixColumn(t,1).length(),a=1/Go.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.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(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(det,t,pet)}lookAt(t,e,s){let i=this.elements;return Xr.subVectors(t,e),Xr.lengthSq()===0&&(Xr.z=1),Xr.normalize(),Vn.crossVectors(s,Xr),Vn.lengthSq()===0&&(Math.abs(s.z)===1?Xr.x+=1e-4:Xr.z+=1e-4,Xr.normalize(),Vn.crossVectors(s,Xr)),Vn.normalize(),xd.crossVectors(Xr,Vn),i[0]=Vn.x,i[4]=xd.x,i[8]=Xr.x,i[1]=Vn.y,i[5]=xd.y,i[9]=Xr.y,i[2]=Vn.z,i[6]=xd.z,i[10]=Xr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.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],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],E=s[15],z=i[0],A=i[4],L=i[8],tt=i[12],nt=i[1],it=i[5],wt=i[9],ht=i[13],yt=i[2],St=i[6],Tt=i[10],Ut=i[14],Lt=i[3],ft=i[7],gt=i[11],zt=i[15];return n[0]=a*z+o*nt+l*yt+h*Lt,n[4]=a*A+o*it+l*St+h*ft,n[8]=a*L+o*wt+l*Tt+h*gt,n[12]=a*tt+o*ht+l*Ut+h*zt,n[1]=u*z+c*nt+d*yt+p*Lt,n[5]=u*A+c*it+d*St+p*ft,n[9]=u*L+c*wt+d*Tt+p*gt,n[13]=u*tt+c*ht+d*Ut+p*zt,n[2]=m*z+f*nt+x*yt+b*Lt,n[6]=m*A+f*it+x*St+b*ft,n[10]=m*L+f*wt+x*Tt+b*gt,n[14]=m*tt+f*ht+x*Ut+b*zt,n[3]=w*z+S*nt+_*yt+E*Lt,n[7]=w*A+S*it+_*St+E*ft,n[11]=w*L+S*wt+_*Tt+E*gt,n[15]=w*tt+S*ht+_*Ut+E*zt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,E=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*E;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=E*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.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(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,E=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*E,i[1]=(p+_)*E,i[2]=(m-S)*E,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=Go.set(i[0],i[1],i[2]).length(),a=Go.set(i[4],i[5],i[6]).length(),o=Go.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Fs.copy(this);let h=1/n,u=1/a,c=1/o;return Fs.elements[0]*=h,Fs.elements[1]*=h,Fs.elements[2]*=h,Fs.elements[4]*=u,Fs.elements[5]*=u,Fs.elements[6]*=u,Fs.elements[8]*=c,Fs.elements[9]*=c,Fs.elements[10]*=c,e.setFromRotationMatrix(Fs),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Ra){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===Ra)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Jg)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(t,e,s,i,n,a,o=Ra){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===Ra)m=(a+n)*c,f=-2*c;else if(o===Jg)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(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const Go=new ei,Fs=new FA,det=new ei(0,0,0),pet=new ei(1,1,1),Vn=new ei,xd=new ei,Xr=new ei;var OA=class kA{constructor(t=0,e=0){kA.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(jt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},met=class BA{constructor(t=0,e=0,s=0,i=1){BA.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}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===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,E=(b+1)/2,z=(u+d)/4,A=(c+f)/4,L=(m+x)/4;return S>_&&S>E?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>E?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=L/i):E<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(E),s=A/n,i=L/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this.w=jt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this.w=jt(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(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)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}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}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}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 Kg(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const DA=(...r)=>Kg(r);function fet(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of ty(r))e.push(Kg(s.slice(0,-4)),i.getCacheKey(t));return Kg(e)}function*ty(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function ey(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function UA(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new vx(...t):e==="vec2"?new OA(...t):e==="vec3"?new ei(...t):e==="vec4"?new met(...t):e==="mat2"?new het(...t):e==="mat3"?new Jh(...t):e==="mat4"?new FA(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?yet(t[0]):null}function get(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function yet(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}var xet=class{addEventListener(r,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[r]===void 0&&(e[r]=[]),e[r].indexOf(t)===-1&&e[r].push(t)}hasEventListener(r,t){let e=this._listeners;return e===void 0?!1:e[r]!==void 0&&e[r].indexOf(t)!==-1}removeEventListener(r,t){let e=this._listeners;if(e===void 0)return;let s=e[r];if(s!==void 0){let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(r){let t=this._listeners;if(t===void 0)return;let e=t[r.type];if(e!==void 0){r.target=this;let s=e.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,r);r.target=null}}};const bet={analyze:"setup",generate:"analyze"};let vet=0;var wet=class extends xet{static get type(){return"Node"}constructor(r=null){super(),this.nodeType=r,this.updateType=Ln.NONE,this.updateBeforeType=Ln.NONE,this.updateAfterType=Ln.NONE,this.uuid=aet.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:vet++})}set needsUpdate(r){r===!0&&this.version++}get type(){return this.constructor.type}onUpdate(r,t){return this.updateType=t,this.update=r.bind(this.getSelf()),this}onFrameUpdate(r){return this.onUpdate(r,Ln.FRAME)}onRenderUpdate(r){return this.onUpdate(r,Ln.RENDER)}onObjectUpdate(r){return this.onUpdate(r,Ln.OBJECT)}onReference(r){return this.updateReference=r.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:r}of ty(this))yield r}dispose(){this.dispatchEvent({type:"dispose"})}traverse(r){r(this);for(let t of this.getChildren())t.traverse(r)}getCacheKey(r=!1){return r||(r=this.version!==this._cacheKeyVersion),(r===!0||this._cacheKey===null)&&(this._cacheKey=DA(fet(this,r),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(r){let t=this.getNodeType(r);return r.getElementType(t)}getMemberType(){return"void"}getNodeType(r){let t=r.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(r):this.nodeType}getShared(r){let t=this.getHash(r);return r.getNodeFromHash(t)||this}setup(r){let t=r.getNodeProperties(this),e=0;for(let s of this.getChildren())t["node"+e++]=s;return t.outputNode||null}analyze(r,t=null){let e=r.increaseUsage(this);if(this.parents===!0){let s=r.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[r.shaderStage]=s.stages[r.shaderStage]||[],s.stages[r.shaderStage].push(t)}if(e===1){let s=r.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(r,this)}}generate(r,t){let{outputNode:e}=r.getNodeProperties(this);if(e&&e.isNode===!0)return e.build(r,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(r,t=null){let e=this.getShared(r);if(this!==e)return e.build(r,t);let s=r.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[r.buildStage]=!0;let i=bet[r.buildStage];if(i&&s.buildStages[i]!==!0){let o=r.getBuildStage();r.setBuildStage(i),this.build(r),r.setBuildStage(o)}r.addNode(this),r.addChain(this);let n=null,a=r.getBuildStage();if(a==="setup"){this.updateReference(r);let o=r.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(r)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=r.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(r)}}n=o.outputNode}else if(a==="analyze")this.analyze(r,t);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(r),h=r.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(r)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&r.context.nodeBlock!==void 0&&r.addFlowCodeHierarchy(this,r.context.nodeBlock),n=r.format(n,l,t)}else n=this.generate(r,t)||"";return r.removeChain(this),r.addSequentialNode(this),n}getSerializeChildren(){return ty(this)}serialize(r){let t=this.getSerializeChildren(),e={};for(let{property:s,index:i,childNode:n}of t)i===void 0?e[s]=n.toJSON(r.meta).uuid:(e[s]===void 0&&(e[s]=Number.isInteger(i)?[]:{}),e[s][i]=n.toJSON(r.meta).uuid);Object.keys(e).length>0&&(r.inputNodes=e)}deserialize(r){if(r.inputNodes!==void 0){let t=r.meta.nodes;for(let e in r.inputNodes)if(Array.isArray(r.inputNodes[e])){let s=[];for(let i of r.inputNodes[e])s.push(t[i]);this[e]=s}else if(typeof r.inputNodes[e]=="object"){let s={};for(let i in r.inputNodes[e]){let n=r.inputNodes[e][i];s[i]=t[n]}this[e]=s}else{let s=r.inputNodes[e];this[e]=t[s]}}}toJSON(r){let{uuid:t,type:e}=this,s=r===void 0||typeof r=="string";s&&(r={textures:{},images:{},nodes:{}});let i=r.nodes[t];i===void 0&&(i={uuid:t,type:e,meta:r,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(r.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(r.textures),o=n(r.images),l=n(r.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},je=wet,Met=class extends je{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},as=Met,Tet=class extends je{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},wx=Tet,Net=class extends je{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},$A=Net,_et=class extends as{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}},Aet=_et;const zet=Zh.join("");var Cet=class extends je{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max(Zh.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===zet.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},dw=Cet,Eet=class extends as{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=Zh[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},Vet=Eet,Ret=class extends as{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=Zh[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},Iet=Ret,Let=class extends je{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?ey(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=ey(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=get(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?UA(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}},Mx=Let;const pw=/float|u?int/;var Pet=class extends Mx{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return pw.test(e)&&pw.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},gn=Pet,Fet=class extends je{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}},Oet=Fet;let ket=null;const nl=new Map;function j(r,t){if(nl.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);nl.set(r,t)}const jA=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),mw=r=>jA(r).split("").sort().join(""),WA={setup(r,t){let e=t.shift();return r(om(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(ket.assign(e,...s),e);if(nl.has(t)){let s=nl.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&nl.has(t.slice(0,t.length-6))){let s=nl.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=jA(t),ct(new dw(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=mw(t.slice(3).toLowerCase()),s=>ct(new Vet(r,t,ct(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=mw(t.slice(4).toLowerCase()),()=>ct(new Iet(ct(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),ct(new dw(r,t));if(/^\d+$/.test(t)===!0)return ct(new wx(e,new gn(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>ct(new Oet(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},Kf=new WeakMap,fw=new WeakMap,Bet=function(r,t=null){let e=ey(r);if(e==="node"){let s=Kf.get(r);return s===void 0&&(s=new Proxy(r,WA),Kf.set(r,s),Kf.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return ct(ry(r,t));if(e==="shader")return Cs(r)}return r},Det=function(r,t=null){for(let e in r)r[e]=ct(r[e],t);return r},Uet=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=ct(r[s],t);return r},$et=function(r,t=null,e=null,s=null){let i=u=>ct(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.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 t===null?n=(...u)=>i(new r(...Pd(h(u)))):e===null?n=(...u)=>i(new r(t,...Pd(h(u)))):(e=ct(e),n=(...u)=>i(new r(t,...Pd(h(u)),e))),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 jet=class extends je{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=fw.get(r.constructor);a===void 0&&(a=new WeakMap,fw.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=ct(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=ct(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=ct(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},Wet=class extends je{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return om(r),ct(new jet(this,r))}setup(){return this.call()}};const qet=[!1,!0],Het=[0,1,2,3],Get=[-1,-2],qA=[.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],Tx=new Map;for(let r of qet)Tx.set(r,new gn(r));const Nx=new Map;for(let r of Het)Nx.set(r,new gn(r,"uint"));const Sx=new Map([...Nx].map(r=>new gn(r.value,"int")));for(let r of Get)Sx.set(r,new gn(r,"int"));const nm=new Map([...Sx].map(r=>new gn(r.value)));for(let r of qA)nm.set(r,new gn(r));for(let r of qA)nm.set(-r,new gn(-r));const am={bool:Tx,uint:Nx,ints:Sx,float:nm},gw=new Map([...Tx,...nm]),ry=(r,t)=>gw.has(r)?gw.get(r):r.isNode===!0?r:new gn(r,t),Xet=r=>{try{return r.getNodeType()}catch{return}},We=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[UA(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return ct(t.get(e[0]));if(e.length===1){let i=ry(e[0],r);return Xet(i)===r?ct(i):ct(new $A(i,r))}let s=e.map(i=>ry(i));return ct(new Aet(s,r))}},Yet=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Zet(r,t){return new Proxy(new Wet(r,t),WA)}const ct=(r,t=null)=>Bet(r,t),om=(r,t=null)=>new Det(r,t),Pd=(r,t=null)=>new Uet(r,t),et=(...r)=>new $et(...r);let Jet=0;const Cs=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Zet(r,e),i=(...n)=>{let a;om(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="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),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+Jet++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i};function Qet(r){return r}j("toStack",Qet);const Ket=new We("color"),Ti=new We("float",am.float),ch=new We("int",am.ints),trt=new We("uint",am.uint),ert=new We("bool",am.bool),HA=new We("vec2"),rrt=new We("ivec2"),srt=new We("uvec2"),irt=new We("bvec2"),Wl=new We("vec3"),nrt=new We("ivec3"),art=new We("uvec3"),ort=new We("bvec3"),$a=new We("vec4"),lrt=new We("ivec4"),urt=new We("uvec4"),hrt=new We("bvec4"),crt=new We("mat2"),GA=new We("mat3"),drt=new We("mat4");j("toColor",Ket),j("toFloat",Ti),j("toInt",ch),j("toUint",trt),j("toBool",ert),j("toVec2",HA),j("toIVec2",rrt),j("toUVec2",srt),j("toBVec2",irt),j("toVec3",Wl),j("toIVec3",nrt),j("toUVec3",art),j("toBVec3",ort),j("toVec4",$a),j("toIVec4",lrt),j("toUVec4",urt),j("toBVec4",hrt),j("toMat2",crt),j("toMat3",GA),j("toMat4",drt);const prt=et(wx).setParameterLength(2),mrt=(r,t)=>ct(new $A(ct(r),t));j("element",prt),j("convert",mrt),j("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),r));const frt={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Le=class sy extends as{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new sy(t,e,s);for(let a=0;a<i.length-1;a++)n=new sy(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(frt[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===Ra;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const XA=et(Le,"+").setParameterLength(2,1/0).setName("add"),iy=et(Le,"-").setParameterLength(2,1/0).setName("sub"),_x=et(Le,"*").setParameterLength(2,1/0).setName("mul"),YA=et(Le,"/").setParameterLength(2,1/0).setName("div"),lm=et(Le,"%").setParameterLength(2).setName("mod"),ZA=et(Le,"==").setParameterLength(2).setName("equal"),grt=et(Le,"!=").setParameterLength(2).setName("notEqual"),yrt=et(Le,"<").setParameterLength(2).setName("lessThan"),xrt=et(Le,">").setParameterLength(2).setName("greaterThan"),brt=et(Le,"<=").setParameterLength(2).setName("lessThanEqual"),vrt=et(Le,">=").setParameterLength(2).setName("greaterThanEqual"),wrt=et(Le,"&&").setParameterLength(2,1/0).setName("and"),Mrt=et(Le,"||").setParameterLength(2,1/0).setName("or"),Trt=et(Le,"!").setParameterLength(1).setName("not"),Nrt=et(Le,"^^").setParameterLength(2).setName("xor"),Srt=et(Le,"&").setParameterLength(2).setName("bitAnd"),_rt=et(Le,"~").setParameterLength(2).setName("bitNot"),Art=et(Le,"|").setParameterLength(2).setName("bitOr"),zrt=et(Le,"^").setParameterLength(2).setName("bitXor"),Crt=et(Le,"<<").setParameterLength(2).setName("shiftLeft"),Ert=et(Le,">>").setParameterLength(2).setName("shiftRight"),Vrt=Cs(([r])=>(r.addAssign(1),r)),Rrt=Cs(([r])=>(r.subAssign(1),r)),Irt=Cs(([r])=>{let t=ch(r).toConst();return r.addAssign(1),t}),Lrt=Cs(([r])=>{let t=ch(r).toConst();return r.subAssign(1),t});j("add",XA),j("sub",iy),j("mul",_x),j("div",YA),j("mod",lm),j("equal",ZA),j("notEqual",grt),j("lessThan",yrt),j("greaterThan",xrt),j("lessThanEqual",brt),j("greaterThanEqual",vrt),j("and",wrt),j("or",Mrt),j("not",Trt),j("xor",Nrt),j("bitAnd",Srt),j("bitNot",_rt),j("bitOr",Art),j("bitXor",zrt),j("shiftLeft",Crt),j("shiftRight",Ert),j("incrementBefore",Vrt),j("decrementBefore",Rrt),j("increment",Irt),j("decrement",Lrt);const Prt=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),lm(r,t)),Frt=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),lm(ch(r),ch(t)));j("remainder",Prt),j("modInt",Frt);var O=class ie extends as{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===ie.MAX||t===ie.MIN)&&arguments.length>3){let n=new ie(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new ie(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===ie.LENGTH||e===ie.DISTANCE||e===ie.DOT?"float":e===ie.CROSS?"vec3":e===ie.ALL||e===ie.ANY?"bool":e===ie.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===ie.ONE_MINUS)n=iy(1,e);else if(i===ie.RECIPROCAL)n=YA(1,e);else if(i===ie.DIFFERENCE)n=Ax(iy(e,s));else if(i===ie.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=$a(Wl(o),0):a=$a(Wl(a),0);let l=_x(a,o).xyz;n=JA(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===ie.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===ie.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Ra&&i===ie.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Ra&&(i===ie.MIN||i===ie.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===ie.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===ie.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===Jg&&i===ie.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ie.DFDX||i===ie.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};O.ALL="all",O.ANY="any",O.RADIANS="radians",O.DEGREES="degrees",O.EXP="exp",O.EXP2="exp2",O.LOG="log",O.LOG2="log2",O.SQRT="sqrt",O.INVERSE_SQRT="inversesqrt",O.FLOOR="floor",O.CEIL="ceil",O.NORMALIZE="normalize",O.FRACT="fract",O.SIN="sin",O.COS="cos",O.TAN="tan",O.ASIN="asin",O.ACOS="acos",O.ATAN="atan",O.ABS="abs",O.SIGN="sign",O.LENGTH="length",O.NEGATE="negate",O.ONE_MINUS="oneMinus",O.DFDX="dFdx",O.DFDY="dFdy",O.ROUND="round",O.RECIPROCAL="reciprocal",O.TRUNC="trunc",O.FWIDTH="fwidth",O.TRANSPOSE="transpose",O.BITCAST="bitcast",O.EQUALS="equals",O.MIN="min",O.MAX="max",O.STEP="step",O.REFLECT="reflect",O.DISTANCE="distance",O.DIFFERENCE="difference",O.DOT="dot",O.CROSS="cross",O.POW="pow",O.TRANSFORM_DIRECTION="transformDirection",O.MIX="mix",O.CLAMP="clamp",O.REFRACT="refract",O.SMOOTHSTEP="smoothstep",O.FACEFORWARD="faceforward";const Ort=Ti(Math.PI);Ti(Math.PI*2);const krt=et(O,O.ALL).setParameterLength(1),Brt=et(O,O.ANY).setParameterLength(1),Drt=et(O,O.RADIANS).setParameterLength(1),Urt=et(O,O.DEGREES).setParameterLength(1),$rt=et(O,O.EXP).setParameterLength(1),jrt=et(O,O.EXP2).setParameterLength(1),Wrt=et(O,O.LOG).setParameterLength(1),qrt=et(O,O.LOG2).setParameterLength(1),Hrt=et(O,O.SQRT).setParameterLength(1),Grt=et(O,O.INVERSE_SQRT).setParameterLength(1),Xrt=et(O,O.FLOOR).setParameterLength(1),Yrt=et(O,O.CEIL).setParameterLength(1),JA=et(O,O.NORMALIZE).setParameterLength(1),QA=et(O,O.FRACT).setParameterLength(1),KA=et(O,O.SIN).setParameterLength(1),Zrt=et(O,O.COS).setParameterLength(1),Jrt=et(O,O.TAN).setParameterLength(1),Qrt=et(O,O.ASIN).setParameterLength(1),Krt=et(O,O.ACOS).setParameterLength(1),tz=et(O,O.ATAN).setParameterLength(1,2),Ax=et(O,O.ABS).setParameterLength(1),ez=et(O,O.SIGN).setParameterLength(1),tst=et(O,O.LENGTH).setParameterLength(1),est=et(O,O.NEGATE).setParameterLength(1),rst=et(O,O.ONE_MINUS).setParameterLength(1),sst=et(O,O.DFDX).setParameterLength(1),ist=et(O,O.DFDY).setParameterLength(1),nst=et(O,O.ROUND).setParameterLength(1),ast=et(O,O.RECIPROCAL).setParameterLength(1),ost=et(O,O.TRUNC).setParameterLength(1),lst=et(O,O.FWIDTH).setParameterLength(1),ust=et(O,O.TRANSPOSE).setParameterLength(1),hst=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ZA(r,t)),cst=et(O,O.MIN).setParameterLength(2,1/0),dst=et(O,O.MAX).setParameterLength(2,1/0),pst=et(O,O.STEP).setParameterLength(2),mst=et(O,O.REFLECT).setParameterLength(2),fst=et(O,O.DISTANCE).setParameterLength(2),gst=et(O,O.DIFFERENCE).setParameterLength(2),Qh=et(O,O.DOT).setParameterLength(2),yst=et(O,O.CROSS).setParameterLength(2),rz=et(O,O.POW).setParameterLength(2),xst=et(O,O.POW,2).setParameterLength(1),bst=et(O,O.POW,3).setParameterLength(1),vst=et(O,O.POW,4).setParameterLength(1),wst=et(O,O.TRANSFORM_DIRECTION).setParameterLength(2),Mst=r=>_x(ez(r),rz(Ax(r),1/3)),Tst=r=>Qh(r,r),um=et(O,O.MIX).setParameterLength(3),sz=(r,t=0,e=1)=>ct(new O(O.CLAMP,ct(r),ct(t),ct(e))),Nst=r=>sz(r),Sst=et(O,O.REFRACT).setParameterLength(3),_st=et(O,O.SMOOTHSTEP).setParameterLength(3),Ast=et(O,O.FACEFORWARD).setParameterLength(3),zst=Cs(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=Qh(r.xy,HA(t,e)),n=lm(i,Ort);return QA(KA(n).mul(s))}),Cst=(r,t,e)=>um(t,e,r),Est=(r,t,e)=>_st(t,e,r),Vst=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),tz(r,t));j("all",krt),j("any",Brt),j("equals",hst),j("radians",Drt),j("degrees",Urt),j("exp",$rt),j("exp2",jrt),j("log",Wrt),j("log2",qrt),j("sqrt",Hrt),j("inverseSqrt",Grt),j("floor",Xrt),j("ceil",Yrt),j("normalize",JA),j("fract",QA),j("sin",KA),j("cos",Zrt),j("tan",Jrt),j("asin",Qrt),j("acos",Krt),j("atan",tz),j("abs",Ax),j("sign",ez),j("length",tst),j("lengthSq",Tst),j("negate",est),j("oneMinus",rst),j("dFdx",sst),j("dFdy",ist),j("round",nst),j("reciprocal",ast),j("trunc",ost),j("fwidth",lst),j("atan2",Vst),j("min",cst),j("max",dst),j("step",pst),j("reflect",mst),j("distance",fst),j("dot",Qh),j("cross",yst),j("pow",rz),j("pow2",xst),j("pow3",bst),j("pow4",vst),j("transformDirection",wst),j("mix",Cst),j("clamp",sz),j("refract",Sst),j("smoothstep",Est),j("faceForward",Ast),j("difference",gst),j("saturate",Nst),j("cbrt",Mst),j("transpose",ust),j("rand",zst);var yw=class extends as{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const Rst=(...r)=>{let t;if(r.length===1){let e=r[0];t=new yw(null,e.length,e)}else{let e=r[0],s=r[1];t=new yw(e,s)}return ct(t)};j("toArray",(r,t)=>Rst(Array(t).fill(r)));var iz=class extends je{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const Ist=r=>new iz(r),Lst=(r,t=0)=>new iz(r,!0,t),Pst=Lst("render"),Fst=Ist("object");var Ost=class extends Mx{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=Fst}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const kst=(r,t)=>{let e=Yet(t||r),s=r;return ct(new Ost(s,e))};var Bst=class extends je{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const Dst=(r,t)=>ct(new Bst(r,t));var Ust=class extends as{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return Zh.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const $st=et(Ust).setParameterLength(2);j("assign",$st);var jst=class extends as{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,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(Ti(0));for(let o=0;o<i.length;o++)t.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()'.`),t.push(n(Ti(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const Wst=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Pd(t):om(t[0]),ct(new jst(ct(r),t)));j("call",Wst);var qst=class extends je{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?Dst(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
150
|
+
*/y.BRDF_GGX;y.BRDF_Lambert;y.BasicShadowFilter;y.Break;y.Continue;y.DFGApprox;y.D_GGX;y.Discard;y.EPSILON;y.F_Schlick;y.Fn;y.INFINITY;y.If;y.Switch;y.Loop;y.NodeShaderStage;y.NodeType;y.NodeUpdateType;y.NodeAccess;y.PCFShadowFilter;y.PCFSoftShadowFilter;y.PI;y.PI2;y.Return;y.Schlick_to_F0;y.ScriptableNodeResources;y.ShaderNode;y.TBNViewMatrix;y.VSMShadowFilter;y.V_GGX_SmithCorrelated;y.abs;y.acesFilmicToneMapping;y.acos;y.add;y.addNodeElement;y.agxToneMapping;y.all;y.alphaT;y.and;y.anisotropy;y.anisotropyB;y.anisotropyT;y.any;y.append;y.array;y.arrayBuffer;y.asin;y.assign;y.atan;y.atan2;y.atomicAdd;y.atomicAnd;y.atomicFunc;y.atomicMax;y.atomicMin;y.atomicOr;y.atomicStore;y.atomicSub;y.atomicXor;y.atomicLoad;y.attenuationColor;y.attenuationDistance;y.attribute;y.attributeArray;y.backgroundBlurriness;y.backgroundIntensity;y.backgroundRotation;y.batch;y.billboarding;y.bitAnd;y.bitNot;y.bitOr;y.bitXor;y.bitangentGeometry;y.bitangentLocal;y.bitangentView;y.bitangentWorld;y.bitcast;y.blendBurn;y.blendColor;y.blendDodge;y.blendOverlay;y.blendScreen;y.blur;y.bool;y.buffer;y.bufferAttribute;y.bumpMap;y.burn;y.bvec2;y.bvec3;y.bvec4;y.bypass;y.cache;y.call;y.cameraFar;y.cameraIndex;y.cameraNear;y.cameraNormalMatrix;y.cameraPosition;y.cameraProjectionMatrix;y.cameraProjectionMatrixInverse;y.cameraViewMatrix;y.cameraWorldMatrix;y.cbrt;y.cdl;y.ceil;y.checker;y.cineonToneMapping;y.clamp;y.clearcoat;y.clearcoatRoughness;y.code;y.color;y.colorSpaceToWorking;y.colorToDirection;y.compute;y.computeSkinning;y.cond;y.Const;y.context;y.convert;y.convertColorSpace;y.convertToTexture;y.cos;y.cross;y.cubeTexture;y.dFdx;y.dFdy;y.dashSize;y.debug;y.decrement;y.decrementBefore;y.defaultBuildStages;y.defaultShaderStages;y.defined;y.degrees;y.deltaTime;y.densityFog;y.densityFogFactor;y.depth;y.depthPass;y.difference;y.diffuseColor;y.directPointLight;y.directionToColor;y.dispersion;y.distance;y.div;y.dodge;y.dot;y.drawIndex;y.dynamicBufferAttribute;y.element;y.emissive;y.equal;y.equals;y.equirectUV;y.exp;y.exp2;y.expression;y.faceDirection;y.faceForward;y.faceforward;y.float;y.floor;y.fog;y.fract;y.frameGroup;y.frameId;y.frontFacing;y.fwidth;y.gain;y.gapSize;y.getConstNodeType;y.getCurrentStack;y.getDirection;y.getDistanceAttenuation;y.getGeometryRoughness;y.getNormalFromDepth;y.getParallaxCorrectNormal;y.getRoughness;y.getScreenPosition;y.getShIrradianceAt;y.getTextureIndex;y.getViewPosition;y.getShadowMaterial;y.getShadowRenderObjectFunction;y.glsl;y.glslFn;y.grayscale;y.greaterThan;y.greaterThanEqual;y.hash;y.highpModelNormalViewMatrix;y.highpModelViewMatrix;y.hue;y.increment;y.incrementBefore;y.instance;y.instanceIndex;y.instancedArray;y.instancedBufferAttribute;y.instancedDynamicBufferAttribute;y.instancedMesh;y.int;y.inverseSqrt;y.inversesqrt;y.invocationLocalIndex;y.invocationSubgroupIndex;y.ior;y.iridescence;y.iridescenceIOR;y.iridescenceThickness;y.ivec2;y.ivec3;y.ivec4;y.js;y.label;y.length;y.lengthSq;y.lessThan;y.lessThanEqual;y.lightPosition;y.lightShadowMatrix;y.lightTargetDirection;y.lightTargetPosition;y.lightViewPosition;y.lightingContext;y.lights;y.linearDepth;y.linearToneMapping;y.localId;y.globalId;y.log;y.log2;y.logarithmicDepthToViewZ;y.loop;y.luminance;y.mediumpModelViewMatrix;y.mat2;y.mat3;y.mat4;y.matcapUV;y.materialAO;y.materialAlphaTest;y.materialAnisotropy;y.materialAnisotropyVector;y.materialAttenuationColor;y.materialAttenuationDistance;y.materialClearcoat;y.materialClearcoatNormal;y.materialClearcoatRoughness;y.materialColor;y.materialDispersion;y.materialEmissive;y.materialIOR;y.materialIridescence;y.materialIridescenceIOR;y.materialIridescenceThickness;y.materialLightMap;y.materialLineDashOffset;y.materialLineDashSize;y.materialLineGapSize;y.materialLineScale;y.materialLineWidth;y.materialMetalness;y.materialNormal;y.materialOpacity;y.materialPointSize;y.materialReference;y.materialReflectivity;y.materialRefractionRatio;y.materialRotation;y.materialRoughness;y.materialSheen;y.materialSheenRoughness;y.materialShininess;y.materialSpecular;y.materialSpecularColor;y.materialSpecularIntensity;y.materialSpecularStrength;y.materialThickness;y.materialTransmission;y.max;y.maxMipLevel;y.metalness;y.min;y.mix;y.mixElement;y.mod;y.modInt;y.modelDirection;y.modelNormalMatrix;y.modelPosition;y.modelRadius;y.modelScale;y.modelViewMatrix;y.modelViewPosition;y.modelViewProjection;y.modelWorldMatrix;y.modelWorldMatrixInverse;y.morphReference;y.mrt;y.mul;y.mx_aastep;y.mx_cell_noise_float;y.mx_contrast;y.mx_fractal_noise_float;y.mx_fractal_noise_vec2;y.mx_fractal_noise_vec3;y.mx_fractal_noise_vec4;y.mx_hsvtorgb;y.mx_noise_float;y.mx_noise_vec3;y.mx_noise_vec4;y.mx_ramplr;y.mx_ramptb;y.mx_rgbtohsv;y.mx_safepower;y.mx_splitlr;y.mx_splittb;y.mx_srgb_texture_to_lin_rec709;y.mx_transform_uv;y.mx_worley_noise_float;y.mx_worley_noise_vec2;y.mx_worley_noise_vec3;y.namespace;y.negate;y.neutralToneMapping;y.nodeArray;y.nodeImmutable;y.nodeObject;y.nodeObjects;y.nodeProxy;y.normalFlat;y.normalGeometry;y.normalLocal;y.normalMap;y.normalView;y.normalWorld;y.normalize;y.not;y.notEqual;y.numWorkgroups;y.objectDirection;y.objectGroup;y.objectPosition;y.objectRadius;y.objectScale;y.objectViewPosition;y.objectWorldMatrix;y.oneMinus;y.or;y.orthographicDepthToViewZ;y.oscSawtooth;y.oscSine;y.oscSquare;y.oscTriangle;y.output;y.outputStruct;y.overlay;y.overloadingFn;y.parabola;y.parallaxDirection;y.parallaxUV;y.parameter;y.pass;y.passTexture;y.pcurve;y.perspectiveDepthToViewZ;y.pmremTexture;y.pointUV;y.pointWidth;y.positionGeometry;y.positionLocal;y.positionPrevious;y.positionView;y.positionViewDirection;y.positionWorld;y.positionWorldDirection;y.posterize;y.pow;y.pow2;y.pow3;y.pow4;y.premult;y.property;y.radians;y.rand;y.range;y.rangeFog;y.rangeFogFactor;y.reciprocal;y.lightProjectionUV;y.reference;y.referenceBuffer;y.reflect;y.reflectVector;y.reflectView;y.reflector;y.refract;y.refractVector;y.refractView;y.reinhardToneMapping;y.remainder;y.remap;y.remapClamp;y.renderGroup;y.renderOutput;y.rendererReference;y.rotate;y.rotateUV;y.roughness;y.round;y.rtt;y.sRGBTransferEOTF;y.sRGBTransferOETF;y.sampler;y.samplerComparison;y.saturate;y.saturation;y.screen;y.screenCoordinate;y.screenSize;y.screenUV;y.scriptable;y.scriptableValue;y.select;y.setCurrentStack;y.shaderStages;y.shadow;y.pointShadow;y.shadowPositionWorld;y.sharedUniformGroup;y.shapeCircle;y.sheen;y.sheenRoughness;y.shiftLeft;y.shiftRight;y.shininess;y.sign;y.sin;y.sinc;y.skinning;y.smoothstep;y.smoothstepElement;y.specularColor;y.specularF90;y.spherizeUV;y.split;y.spritesheetUV;y.sqrt;y.stack;y.step;y.storage;y.storageBarrier;y.storageObject;y.storageTexture;y.string;y.struct;y.sub;y.subgroupIndex;y.subgroupSize;y.tan;y.tangentGeometry;y.tangentLocal;y.tangentView;y.tangentWorld;y.temp;y.texture;y.texture3D;y.textureBarrier;y.textureBicubic;y.textureCubeUV;y.textureLoad;y.textureSize;y.textureStore;y.thickness;y.time;y.timerDelta;y.timerGlobal;y.timerLocal;y.toneMapping;y.toneMappingExposure;y.toonOutlinePass;y.transformDirection;y.transformNormal;y.transformNormalToView;y.transformedBentNormalView;y.transformedBitangentView;y.transformedBitangentWorld;y.transformedClearcoatNormalView;y.transformedNormalView;y.transformedNormalWorld;y.transformedTangentView;y.transformedTangentWorld;y.transmission;y.transpose;y.triNoise3D;y.triplanarTexture;y.triplanarTextures;y.trunc;y.tslFn;y.uint;y.uniform;y.uniformCubeTexture;y.uniformArray;y.uniformGroup;y.uniformTexture;y.uniforms;y.unpremult;y.userData;y.uv;y.uvec2;y.uvec3;y.uvec4;y.Var;y.varying;y.varyingProperty;y.vec2;y.vec3;const Ltt=y.vec4;y.vectorComponents;y.velocity;y.vertexColor;y.vertexIndex;y.vibrance;y.viewZToLogarithmicDepth;y.viewZToOrthographicDepth;y.viewZToPerspectiveDepth;y.viewport;y.viewportBottomLeft;y.viewportCoordinate;y.viewportDepthTexture;y.viewportLinearDepth;y.viewportMipTexture;y.viewportResolution;y.viewportSafeUV;y.viewportSharedTexture;y.viewportSize;y.viewportTexture;y.viewportTopLeft;y.viewportUV;y.wgsl;y.wgslFn;y.workgroupArray;y.workgroupBarrier;y.workgroupId;y.workingToColorSpace;y.xor;const kt=H.createContext(null),Ptt=({children:r,hideNotice:t=!1,style:e={},className:s="",...i})=>{const n=H.useRef(null),a=H.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=H.useRef(null);o.current===null&&(o.current=Ar.shaderRenderer());const l=H.useMemo(()=>(f,x,b,w,S=null)=>{if(x===null){try{o.current.removeNode(f)}catch(_){console.warn("Error removing node:",_)}return}try{o.current.registerNode(f,x,b,w,S)}catch(_){console.error("Error registering node:",_,{id:f,parentId:b,metadata:w})}},[]),h=H.useMemo(()=>(f,x,b)=>{try{o.current.updateUniformValue(f,x,b)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=H.useMemo(()=>(f,x)=>{try{o.current.updateNodeMetadata(f,x)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=H.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=H.useRef(!1),p=H.useRef(!1);H.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const x=o.current;return x.initialize({canvas:f}).then(()=>{x.registerNode(a,({childNode:b})=>b||Ltt(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,t||x.showLicenseWarning()}).catch(b=>{console.error("[Shader] Initialization failed:",b),p.current=!1}),()=>{try{x.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(b){console.warn("[Shader] Error during cleanup:",b)}}},[a,t]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof e=="object"?e:{}};return hr.jsx(kt.Provider,{value:c,children:hr.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof e=="object"?e:{}},className:s,...i,children:[hr.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),r]})})};function Ftt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const _A={blendMode:"normal"};try{pl&&pl.props&&Object.entries(pl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(_A[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Ott=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Ftt(r,_A),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(pl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,pl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},vl={name:"DotGrid",props:{color:{type:String,default:"#ffffff",description:"Dot color",transform:Qi},density:{type:Number,default:100,description:"Grid density (number of dots)"},dotSize:{type:Number,default:.2,description:"Size of each dot (0-1)"}},fragmentNode:({uniforms:r})=>{let{viewportUV:t,vec4:e,vec3:s,vec2:i,smoothstep:n,length:a,floor:o,float:l,viewportSize:h}=Rr,u=t,c=r.density.uniform,d=r.dotSize.uniform,p=r.color.uniform,m=h,f=m.x.div(m.y),x=i(u.x.mul(f),u.y),b=x.mul(c),w=b.sub(o(b)),S=a(w.sub(.5)),_=l(1).sub(n(d.mul(.45),d.mul(.5),S)),E=s(p).mul(_);return e(E,_)}};function ktt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const AA={blendMode:"normal"};try{vl&&vl.props&&Object.entries(vl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(AA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Btt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>ktt(r,AA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(vl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,vl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},wl={name:"FilmGrain",props:{intensity:{type:Number,default:.25,description:"Grain intensity (0-1)"},power:{type:Number,default:.645,description:"Controls blending based on brightness"},speed:{type:Number,default:.5,description:"Animation speed of grain noise"}},fragmentNode:({uniforms:r,childNode:t})=>{let e=t||Uu(0,0,0,0),s=h0(),i=p=>wg(kn(bg(p,c0(12.9898,78.233))).mul(43758.5453)),n=p=>bg(p,Uu(.299,.587,.114,0)),a=i(s).add(u0.mul(r.speed.uniform)),o=wg(kn(a.mul(43758.5453))),l=dl(vg(.5),vg(.75),o).mul(r.intensity.uniform),h=DN(n(e),r.power.uniform),u=e.mul(l),c=BN(h,0,1),d=dl(u,e,c);return Uu(d.x,d.y,d.z,e.w)}};function Dtt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const zA={blendMode:"normal"};try{wl&&wl.props&&Object.entries(wl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(zA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Utt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${wl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Dtt(r,zA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(wl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,wl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},fd=new WeakMap,Ml={name:"glassTiles",props:{intensity:{type:Number,default:1,description:"The intensity of the glass tiles effect"},tileCount:{type:Number,default:100,description:"Number of tiles across the shortest dimension"}},fragmentNode:({uniforms:r,childNode:t,onCleanup:e,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,uv:d,uniform:p}=Rr;if(!t)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(t),f=p(1),x=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};x();let b=fd.get(s);b||(b=new ResizeObserver(St=>{let Tt=St[0];if(!Tt)return;let{width:Ut,height:Lt}=Tt.contentRect,ft=window.devicePixelRatio||1;m.setSize(Ut*ft,Lt*ft),x()}),b.observe(s),fd.set(s,b)),e(()=>{let St=fd.get(s);St&&(St.disconnect(),fd.delete(s))});let w=d(),S=r.intensity.uniform,_=r.tileCount.uniform,E=i(f.greaterThanEqual(1).select(o(_,f),_),f.lessThan(1).select(l(_,f),_)),z=l(a(o(w,E)),E),A=h(w,z),L=i(.5,.5),tt=o(S,.025),nt=l(A,l(i(1),E)),it=h(nt,L),wt=o(it,tt),ht=u(A,wt),yt=u(ht,z);return n(m.sample(yt))}};function $tt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const CA={blendMode:"normal"};try{Ml&&Ml.props&&Object.entries(Ml.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(CA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const jtt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Ml.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>$tt(r,CA),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Ml,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Ml.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},gd={VERTEX:"vertex"},Ln={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Zh=["x","y","z","w"],vr="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 iw=1234567;const EA=Math.PI/180,VA=180/Math.PI;function Ld(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(vr[r&255]+vr[r>>8&255]+vr[r>>16&255]+vr[r>>24&255]+"-"+vr[t&255]+vr[t>>8&255]+"-"+vr[t>>16&15|64]+vr[t>>24&255]+"-"+vr[e&63|128]+vr[e>>8&255]+"-"+vr[e>>16&255]+vr[e>>24&255]+vr[s&255]+vr[s>>8&255]+vr[s>>16&255]+vr[s>>24&255]).toLowerCase()}function jt(r,t,e){return Math.max(t,Math.min(e,r))}function bx(r,t){return(r%t+t)%t}function Wtt(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function qtt(r,t,e){return r===t?0:(e-r)/(t-r)}function Gu(r,t,e){return(1-e)*r+e*t}function Htt(r,t,e,s){return Gu(r,t,1-Math.exp(-e*s))}function Gtt(r,t=1){return t-Math.abs(bx(r,t*2)-t)}function Xtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Ytt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Ztt(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Jtt(r,t){return r+Math.random()*(t-r)}function Qtt(r){return r*(.5-Math.random())}function Ktt(r){r!==void 0&&(iw=r);let t=iw+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function tet(r){return r*EA}function eet(r){return r*VA}function ret(r){return(r&r-1)==0&&r!==0}function set(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function iet(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function net(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Xs(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Zt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const aet={DEG2RAD:EA,RAD2DEG:VA,generateUUID:Ld,clamp:jt,euclideanModulo:bx,mapLinear:Wtt,inverseLerp:qtt,lerp:Gu,damp:Htt,pingpong:Gtt,smoothstep:Xtt,smootherstep:Ytt,randInt:Ztt,randFloat:Jtt,randFloatSpread:Qtt,seededRandom:Ktt,degToRad:tet,radToDeg:eet,isPowerOfTwo:ret,ceilPowerOfTwo:set,floorPowerOfTwo:iet,setQuaternionFromProperEuler:net,normalize:Zt,denormalize:Xs},Yg=0,oet=1015,Zg="",$s="srgb",nw="srgb-linear",aw="linear",Xu="srgb",yp=35044,Ra=2e3,Jg=2001;var Jh=class RA{constructor(t,e,s,i,n,a,o,l,h){RA.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,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(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.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],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],E=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*E,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*E,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*E,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*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 t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,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+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Zf.makeScale(t,e)),this}rotate(t){return this.premultiply(Zf.makeRotation(-t)),this}translate(t,e){return this.premultiply(Zf.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Zf=new Jh,ow={};function lw(r){r in ow||(ow[r]=!0,console.warn(r))}const uw=new Jh().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hw=new Jh().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uet(){let r={enabled:!0,workingColorSpace:nw,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Xu&&(i.r=Tl(i.r),i.g=Tl(i.g),i.b=Tl(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===Xu&&(i.r=Nl(i.r),i.g=Nl(i.g),i.b=Nl(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===Zg?aw: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 lw("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return lw("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[nw]:{primaries:t,whitePoint:s,transfer:aw,toXYZ:uw,fromXYZ:hw,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:$s},outputColorSpaceConfig:{drawingBufferColorSpace:$s}},[$s]:{primaries:t,whitePoint:s,transfer:Xu,toXYZ:uw,fromXYZ:hw,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:$s}}}),r}const ke=uet();function Tl(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function Nl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}const IA={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},En={h:0,s:0,l:0},yd={h:0,s:0,l:0};function Jf(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var vx=class{constructor(r,t,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,t,e)}set(r,t,e){if(t===void 0&&e===void 0){let s=r;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(r,t,e);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,t=$s){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,ke.colorSpaceToWorking(this,t),this}setRGB(r,t,e,s=ke.workingColorSpace){return this.r=r,this.g=t,this.b=e,ke.colorSpaceToWorking(this,s),this}setHSL(r,t,e,s=ke.workingColorSpace){if(r=bx(r,1),t=jt(t,0,1),e=jt(e,0,1),t===0)this.r=this.g=this.b=e;else{let i=e<=.5?e*(1+t):e+t-e*t,n=2*e-i;this.r=Jf(n,i,r+1/3),this.g=Jf(n,i,r),this.b=Jf(n,i,r-1/3)}return ke.colorSpaceToWorking(this,s),this}setStyle(r,t=$s){function e(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+r+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(r)){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 e(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+r)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(r)){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,t);if(n===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,t);return this}setColorName(r,t=$s){let e=IA[r.toLowerCase()];return e===void 0?console.warn("THREE.Color: Unknown color "+r):this.setHex(e,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=Tl(r.r),this.g=Tl(r.g),this.b=Tl(r.b),this}copyLinearToSRGB(r){return this.r=Nl(r.r),this.g=Nl(r.g),this.b=Nl(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=$s){return ke.workingToColorSpace(wr.copy(this),r),Math.round(jt(wr.r*255,0,255))*65536+Math.round(jt(wr.g*255,0,255))*256+Math.round(jt(wr.b*255,0,255))}getHexString(r=$s){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,t=ke.workingColorSpace){ke.workingToColorSpace(wr.copy(this),t);let e=wr.r,s=wr.g,i=wr.b,n=Math.max(e,s,i),a=Math.min(e,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 e:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-e)/u+2;break;case i:o=(e-s)/u+4;break}o/=6}return r.h=o,r.s=l,r.l=h,r}getRGB(r,t=ke.workingColorSpace){return ke.workingToColorSpace(wr.copy(this),t),r.r=wr.r,r.g=wr.g,r.b=wr.b,r}getStyle(r=$s){ke.workingToColorSpace(wr.copy(this),r);let t=wr.r,e=wr.g,s=wr.b;return r===$s?`rgb(${Math.round(t*255)},${Math.round(e*255)},${Math.round(s*255)})`:`color(${r} ${t.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(r,t,e){return this.getHSL(En),this.setHSL(En.h+r,En.s+t,En.l+e)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,t){return this.r=r.r+t.r,this.g=r.g+t.g,this.b=r.b+t.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,t){return this.r+=(r.r-this.r)*t,this.g+=(r.g-this.g)*t,this.b+=(r.b-this.b)*t,this}lerpColors(r,t,e){return this.r=r.r+(t.r-r.r)*e,this.g=r.g+(t.g-r.g)*e,this.b=r.b+(t.b-r.b)*e,this}lerpHSL(r,t){this.getHSL(En),r.getHSL(yd);let e=Gu(En.h,yd.h,t),s=Gu(En.s,yd.s,t),i=Gu(En.l,yd.l,t);return this.setHSL(e,s,i),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){let t=this.r,e=this.g,s=this.b,i=r.elements;return this.r=i[0]*t+i[3]*e+i[6]*s,this.g=i[1]*t+i[4]*e+i[7]*s,this.b=i[2]*t+i[5]*e+i[8]*s,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,t=0){return this.r=r[t],this.g=r[t+1],this.b=r[t+2],this}toArray(r=[],t=0){return r[t]=this.r,r[t+1]=this.g,r[t+2]=this.b,r}fromBufferAttribute(r,t){return this.r=r.getX(t),this.g=r.getY(t),this.b=r.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const wr=new vx;vx.NAMES=IA;var het=class LA{constructor(t,e,s,i){LA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}},cet=class{constructor(r=0,t=0,e=0,s=1){this.isQuaternion=!0,this._x=r,this._y=t,this._z=e,this._w=s}static slerpFlat(r,t,e,s,i,n,a){let o=e[s+0],l=e[s+1],h=e[s+2],u=e[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){r[t+0]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u;return}if(a===1){r[t+0]=c,r[t+1]=d,r[t+2]=p,r[t+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,x=o*c+l*d+h*p+u*m,b=x>=0?1:-1,w=1-x*x;if(w>2**-52){let _=Math.sqrt(w),E=Math.atan2(_,x*b);f=Math.sin(f*E)/_,a=Math.sin(a*E)/_}let S=a*b;if(o=o*f+c*S,l=l*f+d*S,h=h*f+p*S,u=u*f+m*S,f===1-a){let _=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=_,l*=_,h*=_,u*=_}}r[t]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u}static multiplyQuaternionsFlat(r,t,e,s,i,n){let a=e[s],o=e[s+1],l=e[s+2],h=e[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return r[t]=a*p+h*u+o*d-l*c,r[t+1]=o*p+h*c+l*u-a*d,r[t+2]=l*p+h*d+a*c-o*u,r[t+3]=h*p-a*u-o*c-l*d,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,t,e,s){return this._x=r,this._y=t,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,t=!0){let e=r._x,s=r._y,i=r._z,n=r._order,a=Math.cos,o=Math.sin,l=a(e/2),h=a(s/2),u=a(i/2),c=o(e/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 t===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,t){let e=t/2,s=Math.sin(e);return this._x=r.x*s,this._y=r.y*s,this._z=r.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(r){let t=r.elements,e=t[0],s=t[4],i=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],c=e+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(e>a&&e>u){let d=2*Math.sqrt(1+e-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-e-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-e-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(r,t){let e=r.dot(t)+1;return e<2**-52?(e=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=e):(this._x=0,this._y=-r.z,this._z=r.y,this._w=e)):(this._x=r.y*t.z-r.z*t.y,this._y=r.z*t.x-r.x*t.z,this._z=r.x*t.y-r.y*t.x,this._w=e),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(jt(this.dot(r),-1,1)))}rotateTowards(r,t){let e=this.angleTo(r);if(e===0)return this;let s=Math.min(1,t/e);return this.slerp(r,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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x*=r,this._y*=r,this._z*=r,this._w*=r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,t){let e=r._x,s=r._y,i=r._z,n=r._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=e*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-e*l,this._z=i*h+n*l+e*o-s*a,this._w=n*h-e*a-s*o-i*l,this._onChangeCallback(),this}slerp(r,t){if(t===0)return this;if(t===1)return this.copy(r);let e=this._x,s=this._y,i=this._z,n=this._w,a=n*r._w+e*r._x+s*r._y+i*r._z;if(a<0?(this._w=-r._w,this._x=-r._x,this._y=-r._y,this._z=-r._z,a=-a):this.copy(r),a>=1)return this._w=n,this._x=e,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-t;return this._w=d*n+t*this._w,this._x=d*e+t*this._x,this._y=d*s+t*this._y,this._z=d*i+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(r,t,e){return this.copy(r).slerp(t,e)}random(){let r=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(r),s*Math.cos(r),i*Math.sin(t),i*Math.cos(t))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,t=0){return this._x=r[t],this._y=r[t+1],this._z=r[t+2],this._w=r[t+3],this._onChangeCallback(),this}toArray(r=[],t=0){return r[t]=this._x,r[t+1]=this._y,r[t+2]=this._z,r[t+3]=this._w,r}fromBufferAttribute(r,t){return this._x=r.getX(t),this._y=r.getY(t),this._z=r.getZ(t),this._w=r.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ei=class PA{constructor(t=0,e=0,s=0){PA.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(cw.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(cw.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+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(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Qf.copy(this).projectOnVector(t),this.sub(Qf)}reflect(t){return this.sub(Qf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(jt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Qf=new ei,cw=new cet;var FA=class Qg{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Qg.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,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]=x,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 Qg().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/Go.setFromMatrixColumn(t,0).length(),n=1/Go.setFromMatrixColumn(t,1).length(),a=1/Go.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.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(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(det,t,pet)}lookAt(t,e,s){let i=this.elements;return Xr.subVectors(t,e),Xr.lengthSq()===0&&(Xr.z=1),Xr.normalize(),Vn.crossVectors(s,Xr),Vn.lengthSq()===0&&(Math.abs(s.z)===1?Xr.x+=1e-4:Xr.z+=1e-4,Xr.normalize(),Vn.crossVectors(s,Xr)),Vn.normalize(),xd.crossVectors(Xr,Vn),i[0]=Vn.x,i[4]=xd.x,i[8]=Xr.x,i[1]=Vn.y,i[5]=xd.y,i[9]=Xr.y,i[2]=Vn.z,i[6]=xd.z,i[10]=Xr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.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],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],E=s[15],z=i[0],A=i[4],L=i[8],tt=i[12],nt=i[1],it=i[5],wt=i[9],ht=i[13],yt=i[2],St=i[6],Tt=i[10],Ut=i[14],Lt=i[3],ft=i[7],gt=i[11],zt=i[15];return n[0]=a*z+o*nt+l*yt+h*Lt,n[4]=a*A+o*it+l*St+h*ft,n[8]=a*L+o*wt+l*Tt+h*gt,n[12]=a*tt+o*ht+l*Ut+h*zt,n[1]=u*z+c*nt+d*yt+p*Lt,n[5]=u*A+c*it+d*St+p*ft,n[9]=u*L+c*wt+d*Tt+p*gt,n[13]=u*tt+c*ht+d*Ut+p*zt,n[2]=m*z+f*nt+x*yt+b*Lt,n[6]=m*A+f*it+x*St+b*ft,n[10]=m*L+f*wt+x*Tt+b*gt,n[14]=m*tt+f*ht+x*Ut+b*zt,n[3]=w*z+S*nt+_*yt+E*Lt,n[7]=w*A+S*it+_*St+E*ft,n[11]=w*L+S*wt+_*Tt+E*gt,n[15]=w*tt+S*ht+_*Ut+E*zt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,E=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*E;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=E*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.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(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,E=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*E,i[1]=(p+_)*E,i[2]=(m-S)*E,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=Go.set(i[0],i[1],i[2]).length(),a=Go.set(i[4],i[5],i[6]).length(),o=Go.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Fs.copy(this);let h=1/n,u=1/a,c=1/o;return Fs.elements[0]*=h,Fs.elements[1]*=h,Fs.elements[2]*=h,Fs.elements[4]*=u,Fs.elements[5]*=u,Fs.elements[6]*=u,Fs.elements[8]*=c,Fs.elements[9]*=c,Fs.elements[10]*=c,e.setFromRotationMatrix(Fs),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Ra){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===Ra)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Jg)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(t,e,s,i,n,a,o=Ra){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===Ra)m=(a+n)*c,f=-2*c;else if(o===Jg)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(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const Go=new ei,Fs=new FA,det=new ei(0,0,0),pet=new ei(1,1,1),Vn=new ei,xd=new ei,Xr=new ei;var OA=class kA{constructor(t=0,e=0){kA.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(jt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},met=class BA{constructor(t=0,e=0,s=0,i=1){BA.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}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===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,E=(b+1)/2,z=(u+d)/4,A=(c+f)/4,L=(m+x)/4;return S>_&&S>E?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>E?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=L/i):E<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(E),s=A/n,i=L/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this.w=jt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this.w=jt(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(jt(s,t,e))}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(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)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}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}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}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 Kg(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const DA=(...r)=>Kg(r);function fet(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of ty(r))e.push(Kg(s.slice(0,-4)),i.getCacheKey(t));return Kg(e)}function*ty(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function ey(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function UA(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new vx(...t):e==="vec2"?new OA(...t):e==="vec3"?new ei(...t):e==="vec4"?new met(...t):e==="mat2"?new het(...t):e==="mat3"?new Jh(...t):e==="mat4"?new FA(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?yet(t[0]):null}function get(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function yet(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}var xet=class{addEventListener(r,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[r]===void 0&&(e[r]=[]),e[r].indexOf(t)===-1&&e[r].push(t)}hasEventListener(r,t){let e=this._listeners;return e===void 0?!1:e[r]!==void 0&&e[r].indexOf(t)!==-1}removeEventListener(r,t){let e=this._listeners;if(e===void 0)return;let s=e[r];if(s!==void 0){let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(r){let t=this._listeners;if(t===void 0)return;let e=t[r.type];if(e!==void 0){r.target=this;let s=e.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,r);r.target=null}}};const bet={analyze:"setup",generate:"analyze"};let vet=0;var wet=class extends xet{static get type(){return"Node"}constructor(r=null){super(),this.nodeType=r,this.updateType=Ln.NONE,this.updateBeforeType=Ln.NONE,this.updateAfterType=Ln.NONE,this.uuid=aet.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:vet++})}set needsUpdate(r){r===!0&&this.version++}get type(){return this.constructor.type}onUpdate(r,t){return this.updateType=t,this.update=r.bind(this.getSelf()),this}onFrameUpdate(r){return this.onUpdate(r,Ln.FRAME)}onRenderUpdate(r){return this.onUpdate(r,Ln.RENDER)}onObjectUpdate(r){return this.onUpdate(r,Ln.OBJECT)}onReference(r){return this.updateReference=r.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:r}of ty(this))yield r}dispose(){this.dispatchEvent({type:"dispose"})}traverse(r){r(this);for(let t of this.getChildren())t.traverse(r)}getCacheKey(r=!1){return r||(r=this.version!==this._cacheKeyVersion),(r===!0||this._cacheKey===null)&&(this._cacheKey=DA(fet(this,r),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(r){let t=this.getNodeType(r);return r.getElementType(t)}getMemberType(){return"void"}getNodeType(r){let t=r.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(r):this.nodeType}getShared(r){let t=this.getHash(r);return r.getNodeFromHash(t)||this}setup(r){let t=r.getNodeProperties(this),e=0;for(let s of this.getChildren())t["node"+e++]=s;return t.outputNode||null}analyze(r,t=null){let e=r.increaseUsage(this);if(this.parents===!0){let s=r.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[r.shaderStage]=s.stages[r.shaderStage]||[],s.stages[r.shaderStage].push(t)}if(e===1){let s=r.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(r,this)}}generate(r,t){let{outputNode:e}=r.getNodeProperties(this);if(e&&e.isNode===!0)return e.build(r,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(r,t=null){let e=this.getShared(r);if(this!==e)return e.build(r,t);let s=r.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[r.buildStage]=!0;let i=bet[r.buildStage];if(i&&s.buildStages[i]!==!0){let o=r.getBuildStage();r.setBuildStage(i),this.build(r),r.setBuildStage(o)}r.addNode(this),r.addChain(this);let n=null,a=r.getBuildStage();if(a==="setup"){this.updateReference(r);let o=r.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(r)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=r.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(r)}}n=o.outputNode}else if(a==="analyze")this.analyze(r,t);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(r),h=r.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(r)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&r.context.nodeBlock!==void 0&&r.addFlowCodeHierarchy(this,r.context.nodeBlock),n=r.format(n,l,t)}else n=this.generate(r,t)||"";return r.removeChain(this),r.addSequentialNode(this),n}getSerializeChildren(){return ty(this)}serialize(r){let t=this.getSerializeChildren(),e={};for(let{property:s,index:i,childNode:n}of t)i===void 0?e[s]=n.toJSON(r.meta).uuid:(e[s]===void 0&&(e[s]=Number.isInteger(i)?[]:{}),e[s][i]=n.toJSON(r.meta).uuid);Object.keys(e).length>0&&(r.inputNodes=e)}deserialize(r){if(r.inputNodes!==void 0){let t=r.meta.nodes;for(let e in r.inputNodes)if(Array.isArray(r.inputNodes[e])){let s=[];for(let i of r.inputNodes[e])s.push(t[i]);this[e]=s}else if(typeof r.inputNodes[e]=="object"){let s={};for(let i in r.inputNodes[e]){let n=r.inputNodes[e][i];s[i]=t[n]}this[e]=s}else{let s=r.inputNodes[e];this[e]=t[s]}}}toJSON(r){let{uuid:t,type:e}=this,s=r===void 0||typeof r=="string";s&&(r={textures:{},images:{},nodes:{}});let i=r.nodes[t];i===void 0&&(i={uuid:t,type:e,meta:r,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(r.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(r.textures),o=n(r.images),l=n(r.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},je=wet,Met=class extends je{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},as=Met,Tet=class extends je{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},wx=Tet,Net=class extends je{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},$A=Net,_et=class extends as{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}},Aet=_et;const zet=Zh.join("");var Cet=class extends je{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max(Zh.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===zet.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},dw=Cet,Eet=class extends as{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=Zh[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},Vet=Eet,Ret=class extends as{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=Zh[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},Iet=Ret,Let=class extends je{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?ey(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=ey(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=get(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?UA(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}},Mx=Let;const pw=/float|u?int/;var Pet=class extends Mx{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return pw.test(e)&&pw.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},gn=Pet,Fet=class extends je{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}},Oet=Fet;let ket=null;const nl=new Map;function j(r,t){if(nl.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);nl.set(r,t)}const jA=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),mw=r=>jA(r).split("").sort().join(""),WA={setup(r,t){let e=t.shift();return r(om(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(ket.assign(e,...s),e);if(nl.has(t)){let s=nl.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&nl.has(t.slice(0,t.length-6))){let s=nl.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=jA(t),ct(new dw(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=mw(t.slice(3).toLowerCase()),s=>ct(new Vet(r,t,ct(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=mw(t.slice(4).toLowerCase()),()=>ct(new Iet(ct(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),ct(new dw(r,t));if(/^\d+$/.test(t)===!0)return ct(new wx(e,new gn(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>ct(new Oet(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},Kf=new WeakMap,fw=new WeakMap,Bet=function(r,t=null){let e=ey(r);if(e==="node"){let s=Kf.get(r);return s===void 0&&(s=new Proxy(r,WA),Kf.set(r,s),Kf.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return ct(ry(r,t));if(e==="shader")return Cs(r)}return r},Det=function(r,t=null){for(let e in r)r[e]=ct(r[e],t);return r},Uet=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=ct(r[s],t);return r},$et=function(r,t=null,e=null,s=null){let i=u=>ct(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.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 t===null?n=(...u)=>i(new r(...Pd(h(u)))):e===null?n=(...u)=>i(new r(t,...Pd(h(u)))):(e=ct(e),n=(...u)=>i(new r(t,...Pd(h(u)),e))),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 jet=class extends je{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=fw.get(r.constructor);a===void 0&&(a=new WeakMap,fw.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=ct(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=ct(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=ct(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},Wet=class extends je{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return om(r),ct(new jet(this,r))}setup(){return this.call()}};const qet=[!1,!0],Het=[0,1,2,3],Get=[-1,-2],qA=[.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],Tx=new Map;for(let r of qet)Tx.set(r,new gn(r));const Nx=new Map;for(let r of Het)Nx.set(r,new gn(r,"uint"));const Sx=new Map([...Nx].map(r=>new gn(r.value,"int")));for(let r of Get)Sx.set(r,new gn(r,"int"));const nm=new Map([...Sx].map(r=>new gn(r.value)));for(let r of qA)nm.set(r,new gn(r));for(let r of qA)nm.set(-r,new gn(-r));const am={bool:Tx,uint:Nx,ints:Sx,float:nm},gw=new Map([...Tx,...nm]),ry=(r,t)=>gw.has(r)?gw.get(r):r.isNode===!0?r:new gn(r,t),Xet=r=>{try{return r.getNodeType()}catch{return}},We=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[UA(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return ct(t.get(e[0]));if(e.length===1){let i=ry(e[0],r);return Xet(i)===r?ct(i):ct(new $A(i,r))}let s=e.map(i=>ry(i));return ct(new Aet(s,r))}},Yet=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Zet(r,t){return new Proxy(new Wet(r,t),WA)}const ct=(r,t=null)=>Bet(r,t),om=(r,t=null)=>new Det(r,t),Pd=(r,t=null)=>new Uet(r,t),et=(...r)=>new $et(...r);let Jet=0;const Cs=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Zet(r,e),i=(...n)=>{let a;om(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="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),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+Jet++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i};function Qet(r){return r}j("toStack",Qet);const Ket=new We("color"),Ti=new We("float",am.float),ch=new We("int",am.ints),trt=new We("uint",am.uint),ert=new We("bool",am.bool),HA=new We("vec2"),rrt=new We("ivec2"),srt=new We("uvec2"),irt=new We("bvec2"),Wl=new We("vec3"),nrt=new We("ivec3"),art=new We("uvec3"),ort=new We("bvec3"),$a=new We("vec4"),lrt=new We("ivec4"),urt=new We("uvec4"),hrt=new We("bvec4"),crt=new We("mat2"),GA=new We("mat3"),drt=new We("mat4");j("toColor",Ket),j("toFloat",Ti),j("toInt",ch),j("toUint",trt),j("toBool",ert),j("toVec2",HA),j("toIVec2",rrt),j("toUVec2",srt),j("toBVec2",irt),j("toVec3",Wl),j("toIVec3",nrt),j("toUVec3",art),j("toBVec3",ort),j("toVec4",$a),j("toIVec4",lrt),j("toUVec4",urt),j("toBVec4",hrt),j("toMat2",crt),j("toMat3",GA),j("toMat4",drt);const prt=et(wx).setParameterLength(2),mrt=(r,t)=>ct(new $A(ct(r),t));j("element",prt),j("convert",mrt),j("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),r));const frt={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Le=class sy extends as{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new sy(t,e,s);for(let a=0;a<i.length-1;a++)n=new sy(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(frt[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===Ra;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const XA=et(Le,"+").setParameterLength(2,1/0).setName("add"),iy=et(Le,"-").setParameterLength(2,1/0).setName("sub"),_x=et(Le,"*").setParameterLength(2,1/0).setName("mul"),YA=et(Le,"/").setParameterLength(2,1/0).setName("div"),lm=et(Le,"%").setParameterLength(2).setName("mod"),ZA=et(Le,"==").setParameterLength(2).setName("equal"),grt=et(Le,"!=").setParameterLength(2).setName("notEqual"),yrt=et(Le,"<").setParameterLength(2).setName("lessThan"),xrt=et(Le,">").setParameterLength(2).setName("greaterThan"),brt=et(Le,"<=").setParameterLength(2).setName("lessThanEqual"),vrt=et(Le,">=").setParameterLength(2).setName("greaterThanEqual"),wrt=et(Le,"&&").setParameterLength(2,1/0).setName("and"),Mrt=et(Le,"||").setParameterLength(2,1/0).setName("or"),Trt=et(Le,"!").setParameterLength(1).setName("not"),Nrt=et(Le,"^^").setParameterLength(2).setName("xor"),Srt=et(Le,"&").setParameterLength(2).setName("bitAnd"),_rt=et(Le,"~").setParameterLength(2).setName("bitNot"),Art=et(Le,"|").setParameterLength(2).setName("bitOr"),zrt=et(Le,"^").setParameterLength(2).setName("bitXor"),Crt=et(Le,"<<").setParameterLength(2).setName("shiftLeft"),Ert=et(Le,">>").setParameterLength(2).setName("shiftRight"),Vrt=Cs(([r])=>(r.addAssign(1),r)),Rrt=Cs(([r])=>(r.subAssign(1),r)),Irt=Cs(([r])=>{let t=ch(r).toConst();return r.addAssign(1),t}),Lrt=Cs(([r])=>{let t=ch(r).toConst();return r.subAssign(1),t});j("add",XA),j("sub",iy),j("mul",_x),j("div",YA),j("mod",lm),j("equal",ZA),j("notEqual",grt),j("lessThan",yrt),j("greaterThan",xrt),j("lessThanEqual",brt),j("greaterThanEqual",vrt),j("and",wrt),j("or",Mrt),j("not",Trt),j("xor",Nrt),j("bitAnd",Srt),j("bitNot",_rt),j("bitOr",Art),j("bitXor",zrt),j("shiftLeft",Crt),j("shiftRight",Ert),j("incrementBefore",Vrt),j("decrementBefore",Rrt),j("increment",Irt),j("decrement",Lrt);const Prt=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),lm(r,t)),Frt=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),lm(ch(r),ch(t)));j("remainder",Prt),j("modInt",Frt);var O=class ie extends as{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===ie.MAX||t===ie.MIN)&&arguments.length>3){let n=new ie(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new ie(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===ie.LENGTH||e===ie.DISTANCE||e===ie.DOT?"float":e===ie.CROSS?"vec3":e===ie.ALL||e===ie.ANY?"bool":e===ie.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===ie.ONE_MINUS)n=iy(1,e);else if(i===ie.RECIPROCAL)n=YA(1,e);else if(i===ie.DIFFERENCE)n=Ax(iy(e,s));else if(i===ie.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=$a(Wl(o),0):a=$a(Wl(a),0);let l=_x(a,o).xyz;n=JA(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===ie.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===ie.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Ra&&i===ie.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Ra&&(i===ie.MIN||i===ie.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===ie.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===ie.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===Jg&&i===ie.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ie.DFDX||i===ie.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};O.ALL="all",O.ANY="any",O.RADIANS="radians",O.DEGREES="degrees",O.EXP="exp",O.EXP2="exp2",O.LOG="log",O.LOG2="log2",O.SQRT="sqrt",O.INVERSE_SQRT="inversesqrt",O.FLOOR="floor",O.CEIL="ceil",O.NORMALIZE="normalize",O.FRACT="fract",O.SIN="sin",O.COS="cos",O.TAN="tan",O.ASIN="asin",O.ACOS="acos",O.ATAN="atan",O.ABS="abs",O.SIGN="sign",O.LENGTH="length",O.NEGATE="negate",O.ONE_MINUS="oneMinus",O.DFDX="dFdx",O.DFDY="dFdy",O.ROUND="round",O.RECIPROCAL="reciprocal",O.TRUNC="trunc",O.FWIDTH="fwidth",O.TRANSPOSE="transpose",O.BITCAST="bitcast",O.EQUALS="equals",O.MIN="min",O.MAX="max",O.STEP="step",O.REFLECT="reflect",O.DISTANCE="distance",O.DIFFERENCE="difference",O.DOT="dot",O.CROSS="cross",O.POW="pow",O.TRANSFORM_DIRECTION="transformDirection",O.MIX="mix",O.CLAMP="clamp",O.REFRACT="refract",O.SMOOTHSTEP="smoothstep",O.FACEFORWARD="faceforward";const Ort=Ti(Math.PI);Ti(Math.PI*2);const krt=et(O,O.ALL).setParameterLength(1),Brt=et(O,O.ANY).setParameterLength(1),Drt=et(O,O.RADIANS).setParameterLength(1),Urt=et(O,O.DEGREES).setParameterLength(1),$rt=et(O,O.EXP).setParameterLength(1),jrt=et(O,O.EXP2).setParameterLength(1),Wrt=et(O,O.LOG).setParameterLength(1),qrt=et(O,O.LOG2).setParameterLength(1),Hrt=et(O,O.SQRT).setParameterLength(1),Grt=et(O,O.INVERSE_SQRT).setParameterLength(1),Xrt=et(O,O.FLOOR).setParameterLength(1),Yrt=et(O,O.CEIL).setParameterLength(1),JA=et(O,O.NORMALIZE).setParameterLength(1),QA=et(O,O.FRACT).setParameterLength(1),KA=et(O,O.SIN).setParameterLength(1),Zrt=et(O,O.COS).setParameterLength(1),Jrt=et(O,O.TAN).setParameterLength(1),Qrt=et(O,O.ASIN).setParameterLength(1),Krt=et(O,O.ACOS).setParameterLength(1),tz=et(O,O.ATAN).setParameterLength(1,2),Ax=et(O,O.ABS).setParameterLength(1),ez=et(O,O.SIGN).setParameterLength(1),tst=et(O,O.LENGTH).setParameterLength(1),est=et(O,O.NEGATE).setParameterLength(1),rst=et(O,O.ONE_MINUS).setParameterLength(1),sst=et(O,O.DFDX).setParameterLength(1),ist=et(O,O.DFDY).setParameterLength(1),nst=et(O,O.ROUND).setParameterLength(1),ast=et(O,O.RECIPROCAL).setParameterLength(1),ost=et(O,O.TRUNC).setParameterLength(1),lst=et(O,O.FWIDTH).setParameterLength(1),ust=et(O,O.TRANSPOSE).setParameterLength(1),hst=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ZA(r,t)),cst=et(O,O.MIN).setParameterLength(2,1/0),dst=et(O,O.MAX).setParameterLength(2,1/0),pst=et(O,O.STEP).setParameterLength(2),mst=et(O,O.REFLECT).setParameterLength(2),fst=et(O,O.DISTANCE).setParameterLength(2),gst=et(O,O.DIFFERENCE).setParameterLength(2),Qh=et(O,O.DOT).setParameterLength(2),yst=et(O,O.CROSS).setParameterLength(2),rz=et(O,O.POW).setParameterLength(2),xst=et(O,O.POW,2).setParameterLength(1),bst=et(O,O.POW,3).setParameterLength(1),vst=et(O,O.POW,4).setParameterLength(1),wst=et(O,O.TRANSFORM_DIRECTION).setParameterLength(2),Mst=r=>_x(ez(r),rz(Ax(r),1/3)),Tst=r=>Qh(r,r),um=et(O,O.MIX).setParameterLength(3),sz=(r,t=0,e=1)=>ct(new O(O.CLAMP,ct(r),ct(t),ct(e))),Nst=r=>sz(r),Sst=et(O,O.REFRACT).setParameterLength(3),_st=et(O,O.SMOOTHSTEP).setParameterLength(3),Ast=et(O,O.FACEFORWARD).setParameterLength(3),zst=Cs(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=Qh(r.xy,HA(t,e)),n=lm(i,Ort);return QA(KA(n).mul(s))}),Cst=(r,t,e)=>um(t,e,r),Est=(r,t,e)=>_st(t,e,r),Vst=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),tz(r,t));j("all",krt),j("any",Brt),j("equals",hst),j("radians",Drt),j("degrees",Urt),j("exp",$rt),j("exp2",jrt),j("log",Wrt),j("log2",qrt),j("sqrt",Hrt),j("inverseSqrt",Grt),j("floor",Xrt),j("ceil",Yrt),j("normalize",JA),j("fract",QA),j("sin",KA),j("cos",Zrt),j("tan",Jrt),j("asin",Qrt),j("acos",Krt),j("atan",tz),j("abs",Ax),j("sign",ez),j("length",tst),j("lengthSq",Tst),j("negate",est),j("oneMinus",rst),j("dFdx",sst),j("dFdy",ist),j("round",nst),j("reciprocal",ast),j("trunc",ost),j("fwidth",lst),j("atan2",Vst),j("min",cst),j("max",dst),j("step",pst),j("reflect",mst),j("distance",fst),j("dot",Qh),j("cross",yst),j("pow",rz),j("pow2",xst),j("pow3",bst),j("pow4",vst),j("transformDirection",wst),j("mix",Cst),j("clamp",sz),j("refract",Sst),j("smoothstep",Est),j("faceForward",Ast),j("difference",gst),j("saturate",Nst),j("cbrt",Mst),j("transpose",ust),j("rand",zst);var yw=class extends as{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const Rst=(...r)=>{let t;if(r.length===1){let e=r[0];t=new yw(null,e.length,e)}else{let e=r[0],s=r[1];t=new yw(e,s)}return ct(t)};j("toArray",(r,t)=>Rst(Array(t).fill(r)));var iz=class extends je{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const Ist=r=>new iz(r),Lst=(r,t=0)=>new iz(r,!0,t),Pst=Lst("render"),Fst=Ist("object");var Ost=class extends Mx{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=Fst}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const kst=(r,t)=>{let e=Yet(t||r),s=r;return ct(new Ost(s,e))};var Bst=class extends je{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const Dst=(r,t)=>ct(new Bst(r,t));var Ust=class extends as{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return Zh.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const $st=et(Ust).setParameterLength(2);j("assign",$st);var jst=class extends as{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,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(Ti(0));for(let o=0;o<i.length;o++)t.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()'.`),t.push(n(Ti(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const Wst=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Pd(t):om(t[0]),ct(new jst(ct(r),t)));j("call",Wst);var qst=class extends je{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?Dst(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
151
151
|
${r.tab}if ( ${u} ) {
|
|
152
152
|
|
|
153
153
|
`).addFlowTab();let c=n.build(r,e);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))),r.removeFlowTab().addFlowCode(r.tab+" "+c+`
|
|
@@ -164,5 +164,5 @@ ${r.tab}if ( ${u} ) {
|
|
|
164
164
|
`,n+=r.flow.code.replace(/^\t/gm,"")+`
|
|
165
165
|
`,n+="/* ... */ "+e+` /* ... */
|
|
166
166
|
`,n+="// #"+i+`#
|
|
167
|
-
`,t===null?console.log(n):t(r,n),e}};const Iit=(r,t=null)=>ct(new Rit(ct(r),t));j("debug",Iit);const Lit=Cs(([r])=>uz(r.rgb)),Pit=Cs(([r,t=Ti(1)])=>t.mix(uz(r.rgb),r.rgb)),Fit=Cs(([r,t=Ti(1)])=>{let e=XA(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),i=s.sub(e).mul(t).mul(-3);return um(r.rgb,s,i)}),Oit=Cs(([r,t=Ti(1)])=>{let e=Wl(.57735,.57735,.57735),s=t.cos();return Wl(r.rgb.mul(s).add(e.cross(r.rgb).mul(t.sin()).add(e.mul(Qh(e,r.rgb).mul(s.oneMinus())))))}),uz=(r,t=Wl(ke.getLuminanceCoefficients(new ei)))=>Qh(r,t),Sl={name:"Grayscale",props:{},fragmentNode:({childNode:r})=>{let{vec4:t}=Rr;if(!r)return console.error("You must pass a child component into the Grayscale shader."),t(0);let e=r||t(0,0,0,0);return t(Lit(e.rgb).rgb,e.a)}};function kit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const hz={blendMode:"normal",opacity:1};try{Sl&&Sl.props&&Object.entries(Sl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(hz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Bit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Sl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>kit(r,hz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Sl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Sl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},_l={name:"HueShift",props:{shift:{type:Number,default:0,description:"The amount to shift the hue by"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Hue Shift shader."),e(0);let s=t||e(0,0,0,0);return e(Oit(s.rgb,r.shift.uniform).rgb,s.a)}};function Dit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const cz={blendMode:"normal",opacity:1};try{_l&&_l.props&&Object.entries(_l.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(cz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Uit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${_l.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Dit(r,cz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(_l,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,_l.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Al={name:"Invert",props:{},fragmentNode:({childNode:r})=>{let{vec4:t,vec3:e}=Rr;if(!r)return console.error("You must pass a child component into the Invert shader."),t(0);let s=r||t(0,0,0,0);return t(e(1,1,1).sub(s.rgb),s.a)}};function $it(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const dz={blendMode:"normal",opacity:1};try{Al&&Al.props&&Object.entries(Al.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(dz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const jit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Al.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>$it(r,dz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Al,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Al.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},zl={name:"LinearGradient",props:{startColor:{type:String,default:"#1aff00",transform:Qi,description:"The starting color of the gradient"},endColor:{type:String,default:"#0000ff",transform:Qi,description:"The ending color of the gradient"},angle:{type:Number,default:0,description:"rotation angle in degrees (0-360, where 0 = left-to-right)"},center:{type:Object,default:{x:.5,y:.5},transform:v0},autoRotate:{type:Boolean,default:!1,description:"Enable automatic rotation of the gradient"},autoRotateSpeed:{type:Number,default:1,description:"Speed of the automatic rotation in degrees per second"}},fragmentNode:({uniforms:r,onBeforeRender:t})=>{let{vec2:e,mix:s,float:i,cos:n,sin:a,dot:o,radians:l,viewportUV:h,abs:u,div:c,uniform:d}=Rr,p=d(0);t(({deltaTime:tt})=>{if(r.autoRotate.uniform.value){let nt=r.autoRotateSpeed.uniform.value*tt*100;p.value=(p.value+nt)%360}});let m=r.angle.uniform.add(p),f=l(m),x=n(f),b=a(f),w=e(x,b),S=e(r.center.uniform[0],r.center.uniform[1]),_=h.sub(S),E=o(_,w),z=i(.5).mul(u(x).add(u(b))),A=c(E,z.max(1e-6)),L=A.mul(.5).add(.5).clamp(i(0),i(1));return s(r.startColor.uniform,r.endColor.uniform,L)}};function Wit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const pz={blendMode:"normal",opacity:1};try{zl&&zl.props&&Object.entries(zl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(pz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const qit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Wit(r,pz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(zl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,zl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},vd=new WeakMap,Cl={name:"MouseDistortion",props:{viscosity:{type:Number,default:0,description:"Fluid resistance (0-1, higher = more viscous)"},velocityScale:{type:Number,default:2,description:"Speed multiplier for fluid motion"},vorticity:{type:Number,default:.1,description:"Swirl strength (0-1)"},dissipation:{type:Number,default:3,description:"How quickly the effect fades (0-1)"},splatRadius:{type:Number,default:.1,description:"Radius of fluid splat effect (0-1)"}},fragmentNode:({uniforms:r,onBeforeRender:t,childNode:e,onCleanup:s,canvas:i})=>{let{vec2:n,vec4:a,float:o,uniform:l,viewportUV:h,convertToTexture:u,texture:c}=Rr;if(!e)return a(h.x,h.y,0,1);let d=u(e),p=32,m=new Float32Array(p*p*2),f=new eu.DataTexture(m,p,p,eu.RGFormat,eu.FloatType);f.magFilter=eu.LinearFilter,f.minFilter=eu.LinearFilter,f.needsUpdate=!0;let x=c(f),b=l(.5),w=l(.5),S=l(0),_=l(0),E=.5,z=.5,A=Date.now();t(({pointer:yt})=>{let St=Date.now(),Tt=Math.min((St-A)/1e3,.016);A=St;let Ut=Tt>0?(yt.x-E)/Tt:0,Lt=Tt>0?(yt.y-z)/Tt:0;S.value=S.value*.85+Ut*.15,_.value=_.value*.85+Lt*.15,b.value=yt.x,w.value=yt.y;let ft=r.dissipation.uniform.value,gt=r.velocityScale.uniform.value,zt=r.splatRadius.uniform.value,qe=r.vorticity.uniform.value;for(let fr=0;fr<p;fr++)for(let ri=0;ri<p;ri++){let Me=(fr*p+ri)*2;m[Me]*=1-ft*Tt,m[Me+1]*=1-ft*Tt;let wz=(ri+.5)/p,Mz=(fr+.5)/p,hm=wz-yt.x,cm=Mz-yt.y,dm=Math.sqrt(hm*hm+cm*cm);if(dm<zt*2&&Math.abs(Ut)+Math.abs(Lt)>.01){let Kh=Math.exp(-dm*dm/(zt*zt));if(m[Me]+=S.value*Kh*gt*Tt*.5,m[Me+1]+=_.value*Kh*gt*Tt*.5,qe>0){let Vx=Math.atan2(cm,hm)+Math.PI*.5;m[Me]+=Math.cos(Vx)*qe*Kh*Tt*2,m[Me+1]+=Math.sin(Vx)*qe*Kh*Tt*2}}m[Me]=Math.max(-1,Math.min(1,m[Me])),m[Me+1]=Math.max(-1,Math.min(1,m[Me+1]))}f.needsUpdate=!0,E=yt.x,z=yt.y});let L=vd.get(i);L||(L=new ResizeObserver(yt=>{let St=yt[0];if(!St)return;let{width:Tt,height:Ut}=St.contentRect,Lt=window.devicePixelRatio||1;d.setSize(Math.round(Tt*Lt),Math.round(Ut*Lt))}),L.observe(i),vd.set(i,L)),s(()=>{f.dispose();let yt=vd.get(i);yt&&(yt.disconnect(),vd.delete(i))});let tt=x.sample(h).xy,nt=o(.1),it=o(-.1),wt=tt.clamp(n(it,it),n(nt,nt)),ht=h.sub(wt);return d.sample(ht)}};function Hit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const mz={blendMode:"normal",opacity:1};try{Cl&&Cl.props&&Object.entries(Cl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(mz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Git=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Cl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Hit(r,mz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Cl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Cl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})};var Xit=class extends as{static get type(){return"PosterizeNode"}constructor(r,t){super(),this.sourceNode=r,this.stepsNode=t}setup(){let{sourceNode:r,stepsNode:t}=this;return r.mul(t).floor().div(t)}};const Yit=et(Xit).setParameterLength(2),El={name:"Posterize",props:{intensity:{type:Number,default:5,description:"The intensity of the posterization effect (lower is more posterized)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e,int:s}=Rr;if(!t)return console.error("You must pass a child component into the Posterize shader."),e(0);let i=t||e(0,0,0,0);return Yit(i,s(r.intensity.uniform))}};function Zit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const fz={blendMode:"normal",opacity:1};try{El&&El.props&&Object.entries(El.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(fz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Jit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${El.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Zit(r,fz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(El,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,El.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Vl={name:"Saturation",props:{intensity:{type:Number,default:1,description:"The intensity of the saturation effect (1 being no change)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Saturation shader."),e(0);let s=t||e(0,0,0,0);return e(Pit(s.rgb,r.intensity.uniform).rgb,s.a)}};function Qit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const gz={blendMode:"normal",opacity:1};try{Vl&&Vl.props&&Object.entries(Vl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(gz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Kit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Qit(r,gz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Vl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Vl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Rl={name:"SolidColor",props:{color:{type:String,default:"#5b18ca",transform:Qi,description:"The solid color to display"}},fragmentNode:({uniforms:r})=>r.color.uniform};function tnt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const yz={blendMode:"normal",opacity:1};try{Rl&&Rl.props&&Object.entries(Rl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(yz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const ent=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Rl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>tnt(r,yz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Rl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Rl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Il={name:"Swirl",props:{colorA:{type:String,default:"#1275d8",description:"Primary gradient color",transform:Qi},colorB:{type:String,default:"#e19136",description:"Secondary gradient color",transform:Qi},colorC:{type:String,default:"#320485",description:"Accent gradient color",transform:Qi},speed:{type:Number,default:1,description:"Flow animation speed"},scale:{type:Number,default:5,description:"Gradient scale"},complexity:{type:Number,default:5,description:"Flow complexity"}},fragmentNode:({uniforms:r})=>{let t=h0(),e=u0.mul(r.speed.uniform),s=r.scale.uniform,i=r.complexity.uniform,n=kn(t.x.mul(s.mul(1.2)).add(e.mul(.8))).mul(.3),a=zd(t.y.mul(s.mul(.9)).sub(e.mul(.6))).mul(.3),o=c0(t.x.add(kn(t.y.mul(i.mul(2)).add(e)).mul(.08)),t.y.add(zd(t.x.mul(i.mul(1.5)).sub(e.mul(.7))).mul(.08))),l=kn(o.x.mul(s.mul(3)).add(o.y.mul(s.mul(2))).add(e.mul(.5))),h=zd(o.x.sub(o.y).mul(s.mul(2.5)).add(e.mul(.3))),u=kn(o.x.mul(i).add(n).add(o.y.mul(i.mul(.8)).add(a)).add(e.mul(.4))),c=dl(l,h,u.mul(.5).add(.5)),d=o.x.mul(.7).add(o.y.mul(.3)).add(c.mul(.2)),p=dl(r.colorA.uniform,r.colorB.uniform,Mg(.1,.6,d)),m=dl(p,r.colorC.uniform,Mg(.4,.9,d.add(u.mul(.3)))),f=kn(e.mul(3).add(d.mul(10))).mul(.02).add(1),x=m.mul(f);return Uu(x,1)}};function rnt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const xz={blendMode:"normal",opacity:1};try{Il&&Il.props&&Object.entries(Il.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(xz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const snt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Il.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>rnt(r,xz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Il,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Il.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Ll={name:"Twirl",props:{center:{type:Object,default:{x:.5,y:.5},transform:v0,description:"The center point of the twirl effect"},intensity:{type:Number,default:1,description:"The strength of the twirl effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec2:e,vec4:s,cos:i,sin:n,length:a,uv:o,convertToTexture:l}=Rr;if(!t)return console.error("You must pass a child component into the Twirl shader."),s(0);let h=l(t),u=o(),c=e(r.center.uniform.x,r.center.uniform.y),d=u.sub(c),p=r.intensity.uniform.mul(a(d)),m=i(p),f=n(p),x=m.mul(d.x).sub(f.mul(d.y)),b=f.mul(d.x).add(m.mul(d.y)),w=e(x.add(c.x),b.add(c.y));return s(h.sample(w))}};function int(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const bz={blendMode:"normal",opacity:1};try{Ll&&Ll.props&&Object.entries(Ll.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(bz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const nnt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Ll.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>int(r,bz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Ll,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Ll.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Pl={name:"Vibrance",props:{intensity:{type:Number,default:0,description:"The intensity of the vibrance effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Vibrance shader."),e(0);let s=t||e(0,0,0,0);return e(Fit(s.rgb,r.intensity.uniform).rgb,s.a)}};function ant(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const vz={blendMode:"normal",opacity:1};try{Pl&&Pl.props&&Object.entries(Pl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(vz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const ont=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>ant(r,vz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Pl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Pl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})};exports.Circle=Ott;exports.DotGrid=Btt;exports.FilmGrain=Utt;exports.GlassTiles=jtt;exports.Grayscale=Bit;exports.HueShift=Uit;exports.Invert=jit;exports.LinearGradient=qit;exports.MouseDistortion=Git;exports.Posterize=Jit;exports.Saturation=Kit;exports.Shader=Ptt;exports.SolidColor=ent;exports.Swirl=snt;exports.Twirl=nnt;exports.Vibrance=ont;
|
|
167
|
+
`,t===null?console.log(n):t(r,n),e}};const Iit=(r,t=null)=>ct(new Rit(ct(r),t));j("debug",Iit);const Lit=Cs(([r])=>uz(r.rgb)),Pit=Cs(([r,t=Ti(1)])=>t.mix(uz(r.rgb),r.rgb)),Fit=Cs(([r,t=Ti(1)])=>{let e=XA(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),i=s.sub(e).mul(t).mul(-3);return um(r.rgb,s,i)}),Oit=Cs(([r,t=Ti(1)])=>{let e=Wl(.57735,.57735,.57735),s=t.cos();return Wl(r.rgb.mul(s).add(e.cross(r.rgb).mul(t.sin()).add(e.mul(Qh(e,r.rgb).mul(s.oneMinus())))))}),uz=(r,t=Wl(ke.getLuminanceCoefficients(new ei)))=>Qh(r,t),Sl={name:"Grayscale",props:{},fragmentNode:({childNode:r})=>{let{vec4:t}=Rr;if(!r)return console.error("You must pass a child component into the Grayscale shader."),t(0);let e=r||t(0,0,0,0);return t(Lit(e.rgb).rgb,e.a)}};function kit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const hz={blendMode:"normal"};try{Sl&&Sl.props&&Object.entries(Sl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(hz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Bit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Sl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>kit(r,hz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Sl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Sl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},_l={name:"HueShift",props:{shift:{type:Number,default:0,description:"The amount to shift the hue by"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Hue Shift shader."),e(0);let s=t||e(0,0,0,0);return e(Oit(s.rgb,r.shift.uniform).rgb,s.a)}};function Dit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const cz={blendMode:"normal"};try{_l&&_l.props&&Object.entries(_l.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(cz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Uit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${_l.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Dit(r,cz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(_l,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,_l.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Al={name:"Invert",props:{},fragmentNode:({childNode:r})=>{let{vec4:t,vec3:e}=Rr;if(!r)return console.error("You must pass a child component into the Invert shader."),t(0);let s=r||t(0,0,0,0);return t(e(1,1,1).sub(s.rgb),s.a)}};function $it(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const dz={blendMode:"normal"};try{Al&&Al.props&&Object.entries(Al.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(dz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const jit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Al.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>$it(r,dz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Al,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Al.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},zl={name:"LinearGradient",props:{startColor:{type:String,default:"#1aff00",transform:Qi,description:"The starting color of the gradient"},endColor:{type:String,default:"#0000ff",transform:Qi,description:"The ending color of the gradient"},angle:{type:Number,default:0,description:"rotation angle in degrees (0-360, where 0 = left-to-right)"},center:{type:Object,default:{x:.5,y:.5},transform:v0},autoRotate:{type:Boolean,default:!1,description:"Enable automatic rotation of the gradient"},autoRotateSpeed:{type:Number,default:1,description:"Speed of the automatic rotation in degrees per second"}},fragmentNode:({uniforms:r,onBeforeRender:t})=>{let{vec2:e,mix:s,float:i,cos:n,sin:a,dot:o,radians:l,viewportUV:h,abs:u,div:c,uniform:d}=Rr,p=d(0);t(({deltaTime:tt})=>{if(r.autoRotate.uniform.value){let nt=r.autoRotateSpeed.uniform.value*tt*100;p.value=(p.value+nt)%360}});let m=r.angle.uniform.add(p),f=l(m),x=n(f),b=a(f),w=e(x,b),S=e(r.center.uniform[0],r.center.uniform[1]),_=h.sub(S),E=o(_,w),z=i(.5).mul(u(x).add(u(b))),A=c(E,z.max(1e-6)),L=A.mul(.5).add(.5).clamp(i(0),i(1));return s(r.startColor.uniform,r.endColor.uniform,L)}};function Wit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const pz={blendMode:"normal"};try{zl&&zl.props&&Object.entries(zl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(pz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const qit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Wit(r,pz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(zl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,zl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},vd=new WeakMap,Cl={name:"MouseDistortion",props:{viscosity:{type:Number,default:0,description:"Fluid resistance (0-1, higher = more viscous)"},velocityScale:{type:Number,default:2,description:"Speed multiplier for fluid motion"},vorticity:{type:Number,default:.1,description:"Swirl strength (0-1)"},dissipation:{type:Number,default:3,description:"How quickly the effect fades (0-1)"},splatRadius:{type:Number,default:.1,description:"Radius of fluid splat effect (0-1)"}},fragmentNode:({uniforms:r,onBeforeRender:t,childNode:e,onCleanup:s,canvas:i})=>{let{vec2:n,vec4:a,float:o,uniform:l,viewportUV:h,convertToTexture:u,texture:c}=Rr;if(!e)return a(h.x,h.y,0,1);let d=u(e),p=32,m=new Float32Array(p*p*2),f=new eu.DataTexture(m,p,p,eu.RGFormat,eu.FloatType);f.magFilter=eu.LinearFilter,f.minFilter=eu.LinearFilter,f.needsUpdate=!0;let x=c(f),b=l(.5),w=l(.5),S=l(0),_=l(0),E=.5,z=.5,A=Date.now();t(({pointer:yt})=>{let St=Date.now(),Tt=Math.min((St-A)/1e3,.016);A=St;let Ut=Tt>0?(yt.x-E)/Tt:0,Lt=Tt>0?(yt.y-z)/Tt:0;S.value=S.value*.85+Ut*.15,_.value=_.value*.85+Lt*.15,b.value=yt.x,w.value=yt.y;let ft=r.dissipation.uniform.value,gt=r.velocityScale.uniform.value,zt=r.splatRadius.uniform.value,qe=r.vorticity.uniform.value;for(let fr=0;fr<p;fr++)for(let ri=0;ri<p;ri++){let Me=(fr*p+ri)*2;m[Me]*=1-ft*Tt,m[Me+1]*=1-ft*Tt;let wz=(ri+.5)/p,Mz=(fr+.5)/p,hm=wz-yt.x,cm=Mz-yt.y,dm=Math.sqrt(hm*hm+cm*cm);if(dm<zt*2&&Math.abs(Ut)+Math.abs(Lt)>.01){let Kh=Math.exp(-dm*dm/(zt*zt));if(m[Me]+=S.value*Kh*gt*Tt*.5,m[Me+1]+=_.value*Kh*gt*Tt*.5,qe>0){let Vx=Math.atan2(cm,hm)+Math.PI*.5;m[Me]+=Math.cos(Vx)*qe*Kh*Tt*2,m[Me+1]+=Math.sin(Vx)*qe*Kh*Tt*2}}m[Me]=Math.max(-1,Math.min(1,m[Me])),m[Me+1]=Math.max(-1,Math.min(1,m[Me+1]))}f.needsUpdate=!0,E=yt.x,z=yt.y});let L=vd.get(i);L||(L=new ResizeObserver(yt=>{let St=yt[0];if(!St)return;let{width:Tt,height:Ut}=St.contentRect,Lt=window.devicePixelRatio||1;d.setSize(Math.round(Tt*Lt),Math.round(Ut*Lt))}),L.observe(i),vd.set(i,L)),s(()=>{f.dispose();let yt=vd.get(i);yt&&(yt.disconnect(),vd.delete(i))});let tt=x.sample(h).xy,nt=o(.1),it=o(-.1),wt=tt.clamp(n(it,it),n(nt,nt)),ht=h.sub(wt);return d.sample(ht)}};function Hit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const mz={blendMode:"normal"};try{Cl&&Cl.props&&Object.entries(Cl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(mz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Git=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Cl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Hit(r,mz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Cl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Cl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})};var Xit=class extends as{static get type(){return"PosterizeNode"}constructor(r,t){super(),this.sourceNode=r,this.stepsNode=t}setup(){let{sourceNode:r,stepsNode:t}=this;return r.mul(t).floor().div(t)}};const Yit=et(Xit).setParameterLength(2),El={name:"Posterize",props:{intensity:{type:Number,default:5,description:"The intensity of the posterization effect (lower is more posterized)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e,int:s}=Rr;if(!t)return console.error("You must pass a child component into the Posterize shader."),e(0);let i=t||e(0,0,0,0);return Yit(i,s(r.intensity.uniform))}};function Zit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const fz={blendMode:"normal"};try{El&&El.props&&Object.entries(El.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(fz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Jit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${El.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Zit(r,fz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(El,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,El.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Vl={name:"Saturation",props:{intensity:{type:Number,default:1,description:"The intensity of the saturation effect (1 being no change)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Saturation shader."),e(0);let s=t||e(0,0,0,0);return e(Pit(s.rgb,r.intensity.uniform).rgb,s.a)}};function Qit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const gz={blendMode:"normal"};try{Vl&&Vl.props&&Object.entries(Vl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(gz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Kit=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>Qit(r,gz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Vl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Vl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Rl={name:"SolidColor",props:{color:{type:String,default:"#5b18ca",transform:Qi,description:"The solid color to display"}},fragmentNode:({uniforms:r})=>r.color.uniform};function tnt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const yz={blendMode:"normal"};try{Rl&&Rl.props&&Object.entries(Rl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(yz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const ent=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Rl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>tnt(r,yz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Rl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Rl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Il={name:"Swirl",props:{colorA:{type:String,default:"#1275d8",description:"Primary gradient color",transform:Qi},colorB:{type:String,default:"#e19136",description:"Secondary gradient color",transform:Qi},colorC:{type:String,default:"#320485",description:"Accent gradient color",transform:Qi},speed:{type:Number,default:1,description:"Flow animation speed"},scale:{type:Number,default:5,description:"Gradient scale"},complexity:{type:Number,default:5,description:"Flow complexity"}},fragmentNode:({uniforms:r})=>{let t=h0(),e=u0.mul(r.speed.uniform),s=r.scale.uniform,i=r.complexity.uniform,n=kn(t.x.mul(s.mul(1.2)).add(e.mul(.8))).mul(.3),a=zd(t.y.mul(s.mul(.9)).sub(e.mul(.6))).mul(.3),o=c0(t.x.add(kn(t.y.mul(i.mul(2)).add(e)).mul(.08)),t.y.add(zd(t.x.mul(i.mul(1.5)).sub(e.mul(.7))).mul(.08))),l=kn(o.x.mul(s.mul(3)).add(o.y.mul(s.mul(2))).add(e.mul(.5))),h=zd(o.x.sub(o.y).mul(s.mul(2.5)).add(e.mul(.3))),u=kn(o.x.mul(i).add(n).add(o.y.mul(i.mul(.8)).add(a)).add(e.mul(.4))),c=dl(l,h,u.mul(.5).add(.5)),d=o.x.mul(.7).add(o.y.mul(.3)).add(c.mul(.2)),p=dl(r.colorA.uniform,r.colorB.uniform,Mg(.1,.6,d)),m=dl(p,r.colorC.uniform,Mg(.4,.9,d.add(u.mul(.3)))),f=kn(e.mul(3).add(d.mul(10))).mul(.02).add(1),x=m.mul(f);return Uu(x,1)}};function rnt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const xz={blendMode:"normal"};try{Il&&Il.props&&Object.entries(Il.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(xz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const snt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Il.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>rnt(r,xz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Il,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Il.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Ll={name:"Twirl",props:{center:{type:Object,default:{x:.5,y:.5},transform:v0,description:"The center point of the twirl effect"},intensity:{type:Number,default:1,description:"The strength of the twirl effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec2:e,vec4:s,cos:i,sin:n,length:a,uv:o,convertToTexture:l}=Rr;if(!t)return console.error("You must pass a child component into the Twirl shader."),s(0);let h=l(t),u=o(),c=e(r.center.uniform.x,r.center.uniform.y),d=u.sub(c),p=r.intensity.uniform.mul(a(d)),m=i(p),f=n(p),x=m.mul(d.x).sub(f.mul(d.y)),b=f.mul(d.x).add(m.mul(d.y)),w=e(x.add(c.x),b.add(c.y));return s(h.sample(w))}};function int(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const bz={blendMode:"normal"};try{Ll&&Ll.props&&Object.entries(Ll.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(bz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const nnt=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Ll.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>int(r,bz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Ll,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Ll.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})},Pl={name:"Vibrance",props:{intensity:{type:Number,default:0,description:"The intensity of the vibrance effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=Rr;if(!t)return console.error("You must pass a child component into the Vibrance shader."),e(0);let s=t||e(0,0,0,0);return e(Fit(s.rgb,r.intensity.uniform).rgb,s.a)}};function ant(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const vz={blendMode:"normal"};try{Pl&&Pl.props&&Object.entries(Pl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(vz[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const ont=r=>{const t=H.useContext(kt);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=H.useMemo(()=>r.id||`${Pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=H.useMemo(()=>ant(r,vz),[r]),l=H.useRef(null);l.current===null&&(l.current=Ar.createUniformsMap(Pl,o,a));const h=H.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(H.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Pl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),H.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]),H.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return hr.jsx(kt.Provider,{value:h,children:r.children})};exports.Circle=Ott;exports.DotGrid=Btt;exports.FilmGrain=Utt;exports.GlassTiles=jtt;exports.Grayscale=Bit;exports.HueShift=Uit;exports.Invert=jit;exports.LinearGradient=qit;exports.MouseDistortion=Git;exports.Posterize=Jit;exports.Saturation=Kit;exports.Shader=Ptt;exports.SolidColor=ent;exports.Swirl=snt;exports.Twirl=nnt;exports.Vibrance=ont;
|
|
168
168
|
//# sourceMappingURL=index.cjs.map
|