;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="9f26f092-6d63-21e1-5196-8026f6b400fa")}catch(e){}}(); (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,552122,314382,e=>{"use strict";var t=e.i(840387),i=e.i(373680),a=e.i(504778),r=e.i(908464),n=e.i(472361);let s=new Map,o=new Set;function l(){o.forEach(e=>e())}function u(e){return e.includes("/api/attachment-image/")}function c(e){let t=s.get(e);void 0!==t&&clearTimeout(t);let i=setTimeout(()=>{s.delete(e),l()},6e4);s.set(e,i),void 0===t&&l()}function d(e){return s.has(e)}function h(e){return o.add(e),()=>{o.delete(e)}}function m(){return!1}e.s(["isAttachmentImageFailed",0,d,"isAttachmentImageProxyUrl",0,u,"markAttachmentImageFailed",0,c,"useIsAttachmentImageFailed",0,function(e){let t,i=(0,r.c)(2);i[0]!==e?(t=()=>null!=e&&d(e),i[0]=e,i[1]=t):t=i[1];let a=t;return(0,n.useSyncExternalStore)(h,a,m)}],314382);let f=async e=>{let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t},g=async e=>{if(u(e)&&d(e))throw Error("attachment image handle is within its failure cooldown");try{return await f(e)}catch(t){throw u(e)&&c(e),t}};class p{load;decoded;failed;constructor(e=g){this.load=e,this.decoded=new Map,this.failed=new Set}async get(e){let t=this.decoded.get(e);if(null!=t)return t;if(this.failed.has(e))throw Error("Frame previously failed to decode");try{let t=await this.load(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:")?e:`data:image/jpeg;base64,${e}`);return this.decoded.set(e,t),t}catch(t){throw this.failed.add(e),t}}clear(){this.decoded.clear(),this.failed.clear()}}let S=(0,t.createClientLogger)("PartialResultsSandLoader"),v=`#version 300 es precision highp float; layout(location=0) in vec2 a_basePosition; layout(location=1) in float a_random; out vec2 v_uv01Center; out float v_amplitude; out float v_random; out float v_transitionDelay; uniform float u_time; uniform vec2 u_resolution; uniform float u_aspectRatio; uniform float u_particleSize; uniform float u_isGridView; uniform float u_isTransitioning; uniform float u_settleProgress; uniform float u_settleSizeProgress; uniform float u_generationProgress; const float NOISE_OFFSET_1 = 100.0; const float NOISE_OFFSET_2 = 50.0; const float NOISE_OFFSET_4 = 25.0; const float TRANSITION_NOISE_SCALE = 0.433; const float TRANSITION_NOISE_OFFSET = 100.0; const float WAVE_AMPLITUDE = 0.8; const float NOISE_SCALE = 0.6; const float LARGE_FLOW_WEIGHT = 0.77; const float MEDIUM_FLOW_WEIGHT = 0.06; const float SMALL_FLOW_WEIGHT = 0.71; const float LARGE_FLOW_SCALE = 1.54; const float MEDIUM_FLOW_SCALE = 0.20; const float SMALL_FLOW_SCALE = 1.5; const float EDGE_TAPER_START = 0.97; const float TAPER_END_OFFSET = 1.03; const float TAPER_RANDOM_VARIATION = 0.1; const float RANDOM_MOTION_AMPLITUDE = 0.086; const float RANDOM_SEED_1 = 123.456; const float RANDOM_SEED_2 = 789.012; const float FBM_SCALE_DEFAULT = 1.2; const float TRANSITION_STAGGER_RANGE = 0.2; const float TRANSITION_INDIVIDUAL_DURATION = 0.5; float randomParticle(vec2 st) { return fract(sin(dot(st, vec2(12.9898, 78.233))) * 43758.5453123); } float noiseParticle(vec2 st) { vec2 i = floor(st); vec2 f = fract(st); float a = randomParticle(i); float b = randomParticle(i + vec2(1.0, 0.0)); float c = randomParticle(i + vec2(0.0, 1.0)); float d = randomParticle(i + vec2(1.0, 1.0)); vec2 u = f * f * (3.0 - 2.0 * f); return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; } float fbmParticle(vec2 st, float scale) { vec2 pos = st * scale; float value = 0.0; float amplitude = 0.5; float frequency = 1.0; value += amplitude * noiseParticle(pos * frequency); frequency *= 2.0; amplitude *= 0.5; value += amplitude * noiseParticle(pos * frequency); frequency *= 2.0; amplitude *= 0.5; value += amplitude * noiseParticle(pos * frequency); return value * 1.12; } float fbmGrid(vec2 st, float scale) { vec2 pos = st * scale; float value = 0.0; float amplitude = 0.5; value += amplitude * noiseParticle(pos); amplitude *= 0.5; value += amplitude * noiseParticle(pos * 2.0); return value * 1.3; } vec2 calculateFlowScale(vec2 pos, float time, float scale, float timeSpeed, float offsetX, float offsetY, float fbmScale, float aspectRatio, bool useGrid) { float ar = aspectRatio; vec2 aspectScale = vec2(max(ar, 1.0), max(1.0/ar, 1.0)); vec2 aspectPos = pos * aspectScale; float s1 = sin(time * timeSpeed); float c2 = cos(time * timeSpeed * 0.7); vec2 timeOffset = vec2(s1, c2) * 10.0; vec2 scaledPos = aspectPos * NOISE_SCALE * scale + timeOffset; float angle = time * 0.1; float sr = sin(angle); float cr = cos(angle); mat2 rot = mat2(cr, -sr, sr, cr); scaledPos = rot * scaledPos; if (useGrid) { vec2 noise1 = vec2(fbmGrid(scaledPos + vec2(offsetX, offsetY), fbmScale), fbmGrid(scaledPos + vec2(offsetX + NOISE_OFFSET_1, offsetY), fbmScale)); return (noise1 - 0.375) * 1.33; } else { return vec2(fbmParticle(scaledPos + vec2(offsetX, offsetY), fbmScale) - 0.5, fbmParticle(scaledPos + vec2(offsetX + NOISE_OFFSET_1, offsetY), fbmScale) - 0.5); } } vec2 getFlowFieldParticle(vec2 pos, float time, float aspectRatio, bool useGrid) { vec2 flow = vec2(0.0); if (useGrid) { flow += calculateFlowScale(pos, time, 1.54, 0.5, 0.0, 0.0, 1.2, aspectRatio, true) * 0.77; flow += calculateFlowScale(pos, time, 1.5, 1.2, 25.0, 0.0, 1.2, aspectRatio, true) * 0.71; } else { flow += calculateFlowScale(pos, time, 1.54, 0.5, 0.0, 0.0, 1.2, aspectRatio, false) * 0.77; flow += calculateFlowScale(pos, time, 0.20, 0.8, 50.0, 0.0, 1.2, aspectRatio, false) * 0.06; flow += calculateFlowScale(pos, time, 1.5, 1.2, 25.0, 0.0, 1.2, aspectRatio, false) * 0.71; } return flow; } float calculateTransitionNoise(vec2 position, float aspectRatio, bool useGrid) { float ar = aspectRatio; vec2 aspectScale = vec2(max(ar, 1.0), max(1.0/ar, 1.0)); vec2 aspectPos = position * aspectScale; vec2 noisePos = aspectPos * TRANSITION_NOISE_SCALE + vec2(TRANSITION_NOISE_OFFSET); return useGrid ? fbmGrid(noisePos, 1.0) : fbmParticle(noisePos, 1.0); } void main() { bool grid = (u_isGridView > 0.5); float time = u_time * 0.25; if (u_isTransitioning > 0.5) { float ar = u_aspectRatio; vec2 aspectScale = vec2(max(ar, 1.0), max(1.0/ar, 1.0)); vec2 aspectPos = a_basePosition * aspectScale; vec2 noisePos = aspectPos * TRANSITION_NOISE_SCALE + vec2(TRANSITION_NOISE_OFFSET); float transitionNoise = fbmParticle(noisePos, 1.0); transitionNoise = smoothstep(0.2, 0.8, transitionNoise); v_transitionDelay = transitionNoise * TRANSITION_STAGGER_RANGE + 0.001; } else { v_transitionDelay = 0.0; } vec2 flowField = getFlowFieldParticle(a_basePosition, time, u_aspectRatio, grid); float edgeDistance = max(abs(a_basePosition.x), abs(a_basePosition.y)); float randomOffset = (a_random - 0.5) * 0.05; float displacementAttenuation = 1.0 - smoothstep(0.9 + randomOffset, 1.0 + randomOffset, edgeDistance); float generationProgress = clamp(u_generationProgress, 0.0, 1.0); float settleProgress = clamp(u_settleProgress, 0.0, 1.0); float settleSizeProgress = clamp(u_settleSizeProgress, 0.0, 1.0); const float MIN_DISPLACEMENT_AT_FULL_PROGRESS = 0.3; float progressDamping = mix(1.0, MIN_DISPLACEMENT_AT_FULL_PROGRESS, generationProgress); float settleMultiplier = 1.0 - settleProgress; float displacementScale = max(0.0, min(progressDamping, settleMultiplier)); vec2 displacement = flowField * WAVE_AMPLITUDE * displacementAttenuation * displacementScale; if (RANDOM_MOTION_AMPLITUDE > 0.01) { float seed1 = a_random * RANDOM_SEED_1; float seed2 = a_random * RANDOM_SEED_2; float s1 = sin(seed1 + time * 2.9); float c1 = cos(seed1 + time * 2.9); float s2 = sin(seed2 + time * 3.3); float c2 = cos(seed2 + time * 3.3); displacement += vec2(0.7 * s1 + 0.3 * c1, 0.7 * s2 + 0.3 * c2) * RANDOM_MOTION_AMPLITUDE * WAVE_AMPLITUDE * displacementAttenuation * displacementScale; } vec2 position = a_basePosition + displacement; float edgeFactor = 1.0; if (!grid) { float rv = (a_random - 0.5) * TAPER_RANDOM_VARIATION; edgeFactor = 1.0 - smoothstep(EDGE_TAPER_START + rv, TAPER_END_OFFSET + rv, max(abs(position.x), abs(position.y))); } v_amplitude = edgeFactor; v_random = a_random; v_uv01Center = a_basePosition * 0.5 + 0.5; gl_Position = vec4(position, 0.0, 1.0); gl_PointSize = max(0.5, mix(u_particleSize, 1.0, settleSizeProgress)); } `,T=`#version 300 es precision highp float; out vec4 outColor; in vec2 v_uv01Center; in float v_amplitude; in float v_random; in float v_transitionDelay; uniform sampler2D u_texA; uniform sampler2D u_texB; uniform mat3 u_uvA; uniform mat3 u_uvB; uniform float u_blendFactor; uniform float u_particleOpacity; uniform float u_useGradient; uniform float u_fadeProgress; uniform float u_fadeDirection; uniform float u_transitionProgress; uniform float u_isTransitioning; uniform float u_aspectRatio; uniform float u_isGridView; uniform float u_gradientSeed; uniform float u_oldGradientSeed; uniform float u_transitioningToGradient; uniform float u_transitioningGradients; uniform float u_currentlyOnGradient; uniform float u_densityKeepRatio; uniform float u_densityFadeBand; uniform float u_useStaggeredTransition; uniform vec4 u_gradientColorLow; uniform vec4 u_gradientColorHigh; const float PARTICLE_EDGE_FADE = 0.2; const float TRANSITION_INDIVIDUAL_DURATION = 0.5; const float TRANSITION_STAGGER_RANGE = 0.2; const float GRADIENT_ZOOM = 0.35; const float GRADIENT_NOISE_SCALE = 2.0; const float PARTICLE_RANDOM_BRIGHTNESS = 0.09; float randomParticle(vec2 st) { return fract(sin(dot(st, vec2(12.9898, 78.233))) * 43758.5453123); } float noiseParticle(vec2 st) { vec2 i = floor(st); vec2 f = fract(st); float a = randomParticle(i); float b = randomParticle(i + vec2(1.0, 0.0)); float c = randomParticle(i + vec2(0.0, 1.0)); float d = randomParticle(i + vec2(1.0, 1.0)); vec2 u = f * f * (3.0 - 2.0 * f); return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; } vec4 generateBlobbyGradient(vec2 uv01, float seed) { vec2 zoomedUV = uv01 * GRADIENT_ZOOM; vec2 offset = vec2(sin(seed * 0.5), cos(seed * 0.7)) * 0.1; zoomedUV += offset; float n = noiseParticle(zoomedUV * GRADIENT_NOISE_SCALE * 3.0 + vec2(seed * 10.0)); n += noiseParticle(zoomedUV * GRADIENT_NOISE_SCALE * 7.0 + vec2(seed * 20.0 + 100.0)) * 0.4; n *= 0.71; float finalNoise = smoothstep(0.1, 0.9, n); return mix(u_gradientColorLow, u_gradientColorHigh, finalNoise); } void main() { vec2 pc = gl_PointCoord * 2.0 - 1.0; if (dot(pc, pc) > 1.0) discard; if (u_isGridView > 0.5 && v_amplitude < 0.01) discard; float keepFactor = 1.0; if (u_densityKeepRatio < 0.999) { float keepStart = max(0.0, u_densityKeepRatio - u_densityFadeBand); float keepEnd = min(1.0, u_densityKeepRatio + u_densityFadeBand); keepFactor = 1.0 - smoothstep(keepStart, keepEnd, v_random); if (keepFactor <= 0.001) discard; } vec2 uv01 = vec2(v_uv01Center.x, 1.0 - v_uv01Center.y); vec2 uvA = (u_uvA * vec3(uv01, 1.0)).xy; vec4 sourceColor; if (u_oldGradientSeed > 0.0) { sourceColor = generateBlobbyGradient(uv01, u_oldGradientSeed); } else if (u_useGradient > 0.5) { sourceColor = generateBlobbyGradient(uv01, u_gradientSeed); } else { sourceColor = texture(u_texA, uvA); } vec4 particleColor = sourceColor; if (u_isTransitioning > 0.5) { float particleBlend = u_blendFactor; if (u_useStaggeredTransition > 0.5) { float startTime = v_transitionDelay; float endTime = min(startTime + TRANSITION_INDIVIDUAL_DURATION, 1.0); float t = clamp((u_transitionProgress - startTime) / (endTime - startTime), 0.0, 1.0); particleBlend = smoothstep(0.0, 1.0, t); } bool targetIsGradient = (u_oldGradientSeed > 0.0) || (u_transitioningToGradient > 0.5); vec2 uvB = (u_uvB * vec3(uv01, 1.0)).xy; vec4 targetColor = targetIsGradient ? generateBlobbyGradient(uv01, u_gradientSeed) : texture(u_texB, uvB); particleColor = mix(sourceColor, targetColor, particleBlend); } if (PARTICLE_RANDOM_BRIGHTNESS > 0.0) { float brightnessAmount = (v_random - 0.5) * 2.0 * PARTICLE_RANDOM_BRIGHTNESS; vec3 mixTo = (brightnessAmount > 0.0) ? vec3(1.0) : vec3(0.0); particleColor.rgb = mix(particleColor.rgb, mixTo, abs(brightnessAmount)); } float dist = length(pc); float radialAlpha = smoothstep(1.0, 0.0, dist); float opacityFactor = smoothstep(0.0, PARTICLE_EDGE_FADE, v_amplitude); float finalAlpha = radialAlpha * opacityFactor * u_particleOpacity * keepFactor; outColor = vec4(particleColor.rgb * finalAlpha, finalAlpha); } `,P=`#version 300 es precision highp float; layout(location=0) in vec2 a_pos; out vec2 v_uv01; void main() { v_uv01 = (a_pos * 0.5 + 0.5) * vec2(1.0, -1.0) + vec2(0.0, 1.0); gl_Position = vec4(a_pos, 0.0, 1.0); } `,_=`#version 300 es precision highp float; out vec4 outColor; in vec2 v_uv01; uniform sampler2D u_texA; uniform sampler2D u_texB; uniform mat3 u_uvA; uniform mat3 u_uvB; uniform float u_isTransitioning; uniform float u_backgroundTransitionProgress; uniform float u_aspectRatio; uniform float u_isGridView; uniform float u_gradientSeed; uniform float u_oldGradientSeed; uniform float u_transitioningToGradient; uniform float u_currentlyOnGradient; uniform float u_bgBlurLod; uniform vec2 u_resolution; uniform float u_useStaggeredTransition; uniform vec4 u_gradientColorLow; uniform vec4 u_gradientColorHigh; const float TRANSITION_INDIVIDUAL_DURATION = 0.5; const float TRANSITION_STAGGER_RANGE = 0.2; const float BACKGROUND_DARKNESS_DEFAULT = 0.12; const float TRANSITION_NOISE_SCALE = 0.433; const float TRANSITION_NOISE_OFFSET = 100.0; float randomParticle(vec2 st) { return fract(sin(dot(st, vec2(12.9898, 78.233))) * 43758.5453123); } float noiseParticle(vec2 st) { vec2 i=floor(st), f=fract(st); float a=randomParticle(i), b=randomParticle(i+vec2(1,0)), c=randomParticle(i+vec2(0,1)), d=randomParticle(i+vec2(1,1)); vec2 u=f*f*(3.0-2.0*f); return mix(a,b,u.x)+(c-a)*u.y*(1.0-u.x)+(d-b)*u.x*u.y; } float fbmGrid(vec2 st, float scale){ vec2 pos=st*scale; float value=0.0, amplitude=0.5; value+=amplitude*noiseParticle(pos); amplitude*=0.5; value+=amplitude*noiseParticle(pos*2.0); return value*1.3; } float fbmParticle(vec2 st, float scale){ vec2 pos=st*scale; float value=0.0, amplitude=0.5, frequency=1.0; value+=amplitude*noiseParticle(pos*frequency); frequency*=2.0; amplitude*=0.5; value+=amplitude*noiseParticle(pos*frequency); frequency*=2.0; amplitude*=0.5; value+=amplitude*noiseParticle(pos*frequency); return value*1.12; } float calculateTransitionNoise(vec2 position, float aspectRatio, bool useGrid){ float ar=aspectRatio; vec2 aspectScale=vec2(max(ar,1.0),max(1.0/ar,1.0)); vec2 aspectPos=position*aspectScale; vec2 noisePos=aspectPos*TRANSITION_NOISE_SCALE+vec2(TRANSITION_NOISE_OFFSET); return useGrid?fbmGrid(noisePos,1.0):fbmParticle(noisePos,1.0);} vec4 generateBlobbyGradient(vec2 uv01,float seed,vec4 lowC,vec4 highC){ vec2 zoomedUV=uv01*0.35; vec2 offset=vec2(sin(seed*0.5),cos(seed*0.7))*0.1; zoomedUV+=offset; float n=noiseParticle(zoomedUV*2.0*3.0+vec2(seed*10.0)); n+=noiseParticle(zoomedUV*2.0*7.0+vec2(seed*20.0+100.0))*0.4; n*=0.71; float finalNoise=smoothstep(0.1,0.9,n); return mix(lowC,highC,finalNoise);} vec4 sampleBackgroundTexture(sampler2D tex, vec2 uv, vec2 uvMin, vec2 uvMax){ vec2 texSize = vec2(textureSize(tex, 0)); vec2 uvRange = uvMax - uvMin; float texelsInView = max(uvRange.x * texSize.x, uvRange.y * texSize.y); float canvasMax = max(u_resolution.x, u_resolution.y); float lodAdjust = log2(max(texelsInView / canvasMax, 0.125)); float lod = max(u_bgBlurLod + lodAdjust, 0.0); vec2 centerUv = clamp(uv, uvMin, uvMax); vec4 center = textureLod(tex, centerUv, lod); if (lod < 0.75) { return center; } vec2 texel = 1.0 / texSize; float blurRadius = max(1.0, exp2(lod - 2.0)); vec2 offset = texel * blurRadius; vec4 axis = textureLod(tex, clamp(uv + vec2(offset.x, 0.0), uvMin, uvMax), lod) + textureLod(tex, clamp(uv - vec2(offset.x, 0.0), uvMin, uvMax), lod) + textureLod(tex, clamp(uv + vec2(0.0, offset.y), uvMin, uvMax), lod) + textureLod(tex, clamp(uv - vec2(0.0, offset.y), uvMin, uvMax), lod); vec4 diagonal = textureLod(tex, clamp(uv + offset, uvMin, uvMax), lod) + textureLod(tex, clamp(uv + vec2(-offset.x, offset.y), uvMin, uvMax), lod) + textureLod(tex, clamp(uv + vec2(offset.x, -offset.y), uvMin, uvMax), lod) + textureLod(tex, clamp(uv - offset, uvMin, uvMax), lod); return center * 0.36 + axis * 0.12 + diagonal * 0.04; } void main(){ vec2 ndcPos=v_uv01*2.0-1.0; float blendFactor = 0.0; if (u_isTransitioning > 0.5) { if (u_useStaggeredTransition > 0.5) { float transitionNoise=calculateTransitionNoise(ndcPos,u_aspectRatio,(u_isGridView>0.5)); float adjustedNoise=smoothstep(0.2,0.8,transitionNoise); float startTime=adjustedNoise*TRANSITION_STAGGER_RANGE+0.001; float endTime=min(startTime+TRANSITION_INDIVIDUAL_DURATION,1.0); blendFactor=clamp((u_backgroundTransitionProgress-startTime)/(endTime-startTime),0.0,1.0); blendFactor=smoothstep(0.0,1.0,blendFactor); } else { blendFactor = clamp(u_backgroundTransitionProgress, 0.0, 1.0); } } vec2 uvA=(u_uvA*vec3(v_uv01,1.0)).xy; vec2 uvB=(u_uvB*vec3(v_uv01,1.0)).xy; vec2 uvMinA = vec2(u_uvA[2][0], u_uvA[2][1]); vec2 uvMaxA = uvMinA + vec2(abs(u_uvA[0][0]), abs(u_uvA[1][1])); vec2 uvMinB = vec2(u_uvB[2][0], u_uvB[2][1]); vec2 uvMaxB = uvMinB + vec2(abs(u_uvB[0][0]), abs(u_uvB[1][1])); vec4 sourceColor; vec4 targetColor; if(u_oldGradientSeed>0.0){ sourceColor=generateBlobbyGradient(v_uv01,u_oldGradientSeed,u_gradientColorLow,u_gradientColorHigh); targetColor=generateBlobbyGradient(v_uv01,u_gradientSeed,u_gradientColorLow,u_gradientColorHigh); } else if(u_transitioningToGradient>0.5){ sourceColor=sampleBackgroundTexture(u_texA,uvA,uvMinA,uvMaxA); targetColor=generateBlobbyGradient(v_uv01,u_gradientSeed,u_gradientColorLow,u_gradientColorHigh); } else if(u_currentlyOnGradient>0.5){ sourceColor=generateBlobbyGradient(v_uv01,u_gradientSeed,u_gradientColorLow,u_gradientColorHigh); targetColor=sampleBackgroundTexture(u_texB,uvB,uvMinB,uvMaxB); } else { sourceColor=sampleBackgroundTexture(u_texA,uvA,uvMinA,uvMaxA); targetColor=sampleBackgroundTexture(u_texB,uvB,uvMinB,uvMaxB); } vec4 finalColor=(u_isTransitioning>0.5) ? mix(sourceColor,targetColor,blendFactor) : sourceColor; finalColor.rgb=mix(finalColor.rgb,vec3(0.0),0.12); outColor=finalColor; } `,b=new Float32Array([1,0,0,0,1,0,0,0,1]),x=1/120,y=[{setting:"high",blurOffset:0,scaleMultiplier:1,frameSkip:1},{setting:"mediumThread",blurOffset:0,scaleMultiplier:1,frameSkip:1},{setting:"medium",blurOffset:1,scaleMultiplier:1,frameSkip:1},{setting:"low",blurOffset:2,scaleMultiplier:1,frameSkip:2}];function F(e,t,i){let a=null,r=null,n=null;try{if(a=e.createShader(e.VERTEX_SHADER),null==a)throw Error("Error initializing vertex shader");if(e.shaderSource(a,t),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(a)||"VS compile error");if(r=e.createShader(e.FRAGMENT_SHADER),null==r)throw Error("Error initializing fragment shader");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(r)||"FS compile error");if(n=e.createProgram(),null==n)throw Error("Error creating program");if(e.attachShader(n,a),e.attachShader(n,r),e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS))throw Error(e.getProgramInfoLog(n)||"Link error");return e.deleteShader(a),e.deleteShader(r),n}catch(t){throw null!=a&&e.deleteShader(a),null!=r&&e.deleteShader(r),null!=n&&e.deleteProgram(n),t}}function A(e,t,i,a,r=!1){let n=e/t,s=i/a,o=1,l=1,u=0,c=0;return s>n?u=(1-(o=n/s))*.5:c=(1-(l=s/n))*.5,new Float32Array([o,0,0,0,r?-l:l,0,u,r?l+c:c,1])}function M(e=1){return Math.random()*e}function E(e){return e<=0?750:Math.min(6e4,Math.max(1,1e3/e))}function D(e){let t=F(e,P,_),i=F(e,v,T),a=e.createVertexArray(),r=e.createBuffer();if(null==a||null==r)throw Error("Failed to create bg VAO/VBO");e.bindVertexArray(a),e.bindBuffer(e.ARRAY_BUFFER,r);let n=new Float32Array([-1,-1,1,-1,-1,1,1,1]);return e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),{bgProgram:t,particleProgram:i,bgVao:a,bgVbo:r}}class R{canvas;bitmapCtx;gl;particleVao=null;particleBuffer=null;uniformLocationsCached=!1;bgUniformLocations={texA:null,texB:null,uvA:null,uvB:null,isTransitioning:null,backgroundTransitionProgress:null,aspectRatio:null,isGridView:null,gradientSeed:null,oldGradientSeed:null,transitioningToGradient:null,currentlyOnGradient:null,bgBlurLod:null,resolution:null,useStaggeredTransition:null,gradientColorLow:null,gradientColorHigh:null};particleUniformLocations={texA:null,texB:null,time:null,resolution:null,aspectRatio:null,particleSize:null,isGridView:null,isTransitioning:null,uvA:null,uvB:null,blendFactor:null,particleOpacity:null,useGradient:null,fadeProgress:null,fadeDirection:null,transitionProgress:null,gradientSeed:null,oldGradientSeed:null,transitioningToGradient:null,transitioningGradients:null,currentlyOnGradient:null,densityKeepRatio:null,densityFadeBand:null,useStaggeredTransition:null,gradientColorLow:null,gradientColorHigh:null,settleProgress:null,settleSizeProgress:null,generationProgress:null};textures=[null,null];textureData=[{width:null,height:null,uv:b},{width:null,height:null,uv:b}];displayTexIndex=0;uploadTexIndex=1;pendingUploadTexIndex=1;particleColorTexture=null;particleColorUV=b;particleColorWidth=null;particleColorHeight=null;currentParticleFrameData=null;framePlayback;innerState;decodedFrameBuffer=new Map;frameImageCache=new p;pendingFrameSet=null;pendingParticleFrameData=null;loadRequestId=0;isBuffering=!1;hasDisplayedContent=!1;isVideoMode=!1;particleColorUpdateDebounced;particleFadeOutCallback;hasEmittedParticleFadeOut=!1;bufferSize;crossFadeDuration;particleColorDebounceMs;videoFrameThreshold;scaleFactor;maxGrid=500;particleCountSetting="medium";baseParticlesPerPoint=.8;baseParticleSize=2.05;particlesPerPoint=.8;particleSize=2.05;generationProgressForDensity=0;generationProgressForDisplacement=0;generationProgressTarget=0;generationProgressSmoothedTarget=0;completionProgressFrozen=!1;completionFrozenProgressForDensity=0;completionFrozenProgressForDisplacement=0;completionFrozenDisplacementScale=1;particleDensityKeepRatio=1;particleDensityFadeBand=.06;particleCount=0;gridW=null;gridH=null;isGridView=!1;darkMode=!1;gradientLow=[];gradientHigh=[];backgroundBlurRadiusPx=0;backgroundBlurTargetPx=0;backgroundBlurAnimationStartPx=0;backgroundBlurAnimationStartTs=0;backgroundBlurAnimationDurationMs=900;useStaggeredTransition=!1;speedMultiplier=.065;speedBurst={accumulatedTime:0,durationMs:1160,isActive:!1,peakMultiplier:3.2,startTs:0};generationProgressSpring={position:0,velocity:0,target:0};generationProgressSpringStiffness=52;generationProgressSpringDamping=12;settleAnimating=!1;settleStartTs=0;settleSizeDelayMs=190;settleFadeDelayMs=500;settleFadeStartProgress=.69;settleMovementInitialVelocityMultiplier=.25;settleMovementInitialVelocityMax=.5;settleProgress=0;settleSpring={position:0,velocity:0,target:0};settleMovementStiffness=5;settleMovementDamping=4;settleSizeProgress=0;settleSizeStarted=!1;settleSizeSpring={position:0,velocity:0,target:0};settleSizeStiffness=36;settleSizeDamping=11.5;settleFadeDurationSec=1.25;settleFadeStarted=!1;adaptiveQualityEnabled=!0;adaptiveOriginalSetting="medium";adaptiveStartIndex=0;adaptiveStepsDown=0;adaptiveFrameTimeSamples=new Float64Array(20);adaptiveFrameTimeSampleIndex=0;adaptiveFrameTimeSampleCount=0;adaptiveFrameTimeRunningSum=0;adaptiveWarmupFramesRemaining=30;adaptiveLastTierChangeTs=0;adaptiveBlurOffset=0;adaptiveBaseScaleFactor=1;adaptiveFrameSkip=1;adaptiveFrameCounter=0;adaptiveLastRenderTs=0;renderWidth=2;renderHeight=2;constructor(e,t,a,r={}){if(this.canvas=e,this.bitmapCtx=t,this.gl=a,this.bufferSize=r.bufferSize??3,this.crossFadeDuration=r.crossFadeDuration??300,this.particleColorDebounceMs=r.particleColorDebounceMs??200,this.videoFrameThreshold=r.videoFrameThreshold??1,this.scaleFactor=r.scaleFactor??1,this.adaptiveBaseScaleFactor=this.scaleFactor,this.particleFadeOutCallback=r.onParticlesFadedOut,this.darkMode=r.darkMode??!1,this.particleCountSetting=r.particleCountSetting??"medium",this.adaptiveQualityEnabled=r.adaptiveQuality??!0,this.adaptiveOriginalSetting=this.particleCountSetting,this.adaptiveStartIndex=function(e){let t=y.findIndex(t=>t.setting===e);return t>=0?t:0}(this.particleCountSetting),this.adaptiveStepsDown=0,this.adaptiveQualityEnabled&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){const e=Math.min(this.adaptiveStartIndex+1,y.length-1);if(e>this.adaptiveStartIndex){this.adaptiveStepsDown=1;const t=y[e];null!=t&&(this.particleCountSetting=t.setting,this.adaptiveBlurOffset=t.blurOffset,this.adaptiveFrameSkip=t.frameSkip,this.scaleFactor=this.adaptiveBaseScaleFactor*t.scaleMultiplier)}}this.framePlayback={frames:[],fps:r.fps??12,currentFrameIndex:0,isPlaying:!1,lastFrameChangeTs:0};const n=performance.now();this.innerState={backgroundBlendFactor:0,backgroundTransitionProgress:0,blendFactor:0,currentlyOnGradient:1,fadeAnimating:!1,fadeDirection:1,fadeDurationMs:0,fadeFrom:1,fadeStart:0,fadeTo:1,gradientSeed:M(1e3),isTransitioning:!1,lastUpdateTs:n,oldGradientSeed:0,particleOpacity:1,randomTimeOffset:M(100),startTs:n,time:0,transitionDuration:null,transitioningGradients:0,transitioningToGradient:0,transitionProgress:0,transitionStart:0,useGradient:1},this.particleColorUpdateDebounced=(0,i.default)(()=>{this.applyPendingParticleColorUpdate()},{wait:this.particleColorDebounceMs}),this.initInstanceGL(),this.setDarkMode(this.darkMode),this.computeRenderSize(),this.setParticleCountSetting(this.particleCountSetting)}setOnParticlesFadedOut(e){this.particleFadeOutCallback=e}setDarkMode(e){this.darkMode=e,this.gradientLow=e?[.004,.047,.071,1]:[.361,.38,.4,1],this.gradientHigh=[.929,.965,1,1]}setBackgroundBlurRadius(e){let t=Math.max(0,e);if(.001>Math.abs(t-this.backgroundBlurTargetPx))return;this.backgroundBlurTargetPx=t,this.backgroundBlurAnimationStartPx=this.backgroundBlurRadiusPx,this.backgroundBlurAnimationStartTs=performance.now();let i=900+180*Math.min(1,Math.abs(this.backgroundBlurTargetPx-this.backgroundBlurAnimationStartPx)/15);this.backgroundBlurAnimationDurationMs=this.backgroundBlurTargetPx<=.001?Math.max(i,1250):i}setGenerationProgress(e){let t=Math.max(0,Math.min(1,e));1e-4>Math.abs(t-this.generationProgressTarget)||(this.generationProgressTarget=t)}setParticleCountSetting(e){this.setParticleCountSettingValues(e),this.applyParticlePreset()}setParticleCountSettingValues(e){let t=this.renderWidth||2,i=this.renderHeight||2,a=(Math.max(Math.floor(Math.min(t,i)/500),1)-1)*.2+1.35,r=1.35*Math.max(1,Math.sqrt(t*i/25e4));switch(this.particleCountSetting=e,e){case"low":this.baseParticlesPerPoint=.3*a,this.baseParticleSize=3.75*r;break;case"high":this.baseParticlesPerPoint=1.62*a,this.baseParticleSize=1.6*r;break;case"mediumThread":this.baseParticlesPerPoint=2.6*a,this.baseParticleSize=1.95*r;break;default:this.baseParticlesPerPoint=.8*a,this.baseParticleSize=2.05*r}this.particlesPerPoint=this.baseParticlesPerPoint,this.particleSize=this.baseParticleSize}applyParticlePreset(){let e=this.baseParticlesPerPoint,t=this.baseParticleSize,i=Math.abs(e-this.particlesPerPoint)>.001,a=Math.abs(t-this.particleSize)>.001;(i||a)&&(this.particlesPerPoint=e,this.particleSize=t,this.rebuildParticles())}setParticleOpacity(e,t=!1,i=0){let a=Math.max(0,Math.min(1,e)),r=1e-4>Math.abs(a-this.innerState.particleOpacity);if(!(!t||i<=0)||!r||this.settleAnimating||this.innerState.fadeAnimating){if(a>0&&(this.hasEmittedParticleFadeOut=!1,this.settleAnimating=!1,this.settleProgress=0,this.settleSpring={position:0,velocity:0,target:0},this.settleSizeProgress=0,this.settleSizeStarted=!1,this.settleSizeSpring={position:0,velocity:0,target:0},this.settleFadeStarted=!1,this.completionProgressFrozen=!1,this.completionFrozenDisplacementScale=1),t&&i>0){this.innerState.fadeAnimating=!0,this.innerState.fadeStart=performance.now(),this.innerState.fadeDurationMs=Math.max(1,1e3*i),this.innerState.fadeFrom=this.innerState.particleOpacity,this.innerState.fadeTo=a,this.innerState.fadeDirection=a>this.innerState.fadeFrom?1:-1;return}this.innerState.particleOpacity=a,this.innerState.fadeAnimating=!1,this.innerState.fadeDirection=a>.5?1:-1,a<=0&&!this.hasEmittedParticleFadeOut&&(this.hasEmittedParticleFadeOut=!0,this.particleFadeOutCallback?.())}}startCompletionReveal(e=.68,t=.333){let i=Math.max(0,1e3*t);this.completionProgressFrozen=!0,this.completionFrozenProgressForDensity=Math.max(0,Math.min(1,this.generationProgressForDensity)),this.completionFrozenProgressForDisplacement=Math.max(0,Math.min(1,this.generationProgressForDisplacement)),this.completionFrozenDisplacementScale=this.getProgressDampingForGenerationProgress(this.completionFrozenProgressForDisplacement),this.settleAnimating=!0,this.settleStartTs=performance.now(),this.settleProgress=0,this.settleSpring={position:0,velocity:this.getSettleInitialVelocity(),target:1},this.settleSizeProgress=0,this.settleSizeStarted=!1,this.settleSizeSpring={position:0,velocity:0,target:1},this.settleFadeDurationSec=e,this.settleSizeDelayMs=Math.max(170,.65*i),this.settleFadeDelayMs=Math.max(this.settleSizeDelayMs+170,1.45*i),this.settleFadeStarted=!1}stepSpring(e,t,i,a){let r=Math.max(0,Math.min(.05,a));if(r<=0)return;let n=Math.min(8,Math.max(1,Math.ceil(r/x))),s=r/n;for(let a=0;aMath.abs(e.position-e.target)&&.0015>Math.abs(e.velocity)}setFrames(e,t){let i=this.framePlayback.frames.length>0,a=e.length>0,r=this.framePlayback.frames.length,n=t??this.framePlayback.fps,s=e.length>this.videoFrameThreshold;if(function(e,t){if(e.length!==t.length)return!1;for(let i=0;i.5){this.decodedFrameBuffer.clear(),this.framePlayback.currentFrameIndex=0,this.framePlayback.isPlaying=!1,this.framePlayback.lastFrameChangeTs=0,this.particleColorUpdateDebounced.reset(),this.bufferFrames(0).then(async()=>{await this.primeParticleColorFromFrameSet(e,this.isVideoMode),await this.loadAndDisplayFrame(0),this.hasDisplayedContent=!0,this.framePlayback.isPlaying=e.length>this.videoFrameThreshold});return}this.scheduleParticleColorUpdate(e,this.isVideoMode,o&&!this.isVideoMode||1===e.length);let l=0;r>0&&e.length>0&&(l=Math.min(Math.ceil(this.framePlayback.currentFrameIndex/r*e.length),e.length-1)),this.decodedFrameBuffer.clear(),this.framePlayback.currentFrameIndex=l,this.bufferFrames(l).then(()=>{let t=1===e.length?E(n):this.crossFadeDuration;this.loadAndDisplayFrameWithTransition(l,t)})}computeRenderSize(){let e=(window.devicePixelRatio||1)*this.scaleFactor,t=this.canvas.getBoundingClientRect(),i=Math.max(2,Math.floor(t.width*e)),a=Math.max(2,Math.floor(t.height*e));(this.renderWidth!==i||this.renderHeight!==a)&&(this.renderWidth=i,this.renderHeight=a,this.rebuildParticles(),this.recomputeTextureUVs(i,a))}getDesiredSize(){return{width:this.renderWidth,height:this.renderHeight}}resize(){this.computeRenderSize()}cleanup(e){this.pendingFrameSet=null,this.decodedFrameBuffer.clear(),this.frameImageCache.clear(),this.pendingParticleFrameData=null,this.particleColorUpdateDebounced.reset(),this.textures.forEach(t=>e.deleteTexture(t)),e.deleteTexture(this.particleColorTexture),e.deleteBuffer(this.particleBuffer),e.deleteVertexArray(this.particleVao),this.textures=[null,null],this.particleColorTexture=null,this.particleBuffer=null,this.particleVao=null}initInstanceGL(){let e=this.gl;this.particleVao=e.createVertexArray(),this.particleBuffer=e.createBuffer(),this.textures[0]=this.createEmptyTexture(!0),this.textures[1]=this.createEmptyTexture(!0),this.particleColorTexture=this.createEmptyTexture(!1),this.particleColorUV=b,this.displayTexIndex=0,this.uploadTexIndex=1,this.pendingUploadTexIndex=1}cacheUniformLocations(e){let t=this.gl;this.bgUniformLocations={texA:t.getUniformLocation(e.bgProgram,"u_texA"),texB:t.getUniformLocation(e.bgProgram,"u_texB"),uvA:t.getUniformLocation(e.bgProgram,"u_uvA"),uvB:t.getUniformLocation(e.bgProgram,"u_uvB"),isTransitioning:t.getUniformLocation(e.bgProgram,"u_isTransitioning"),backgroundTransitionProgress:t.getUniformLocation(e.bgProgram,"u_backgroundTransitionProgress"),aspectRatio:t.getUniformLocation(e.bgProgram,"u_aspectRatio"),isGridView:t.getUniformLocation(e.bgProgram,"u_isGridView"),gradientSeed:t.getUniformLocation(e.bgProgram,"u_gradientSeed"),oldGradientSeed:t.getUniformLocation(e.bgProgram,"u_oldGradientSeed"),transitioningToGradient:t.getUniformLocation(e.bgProgram,"u_transitioningToGradient"),currentlyOnGradient:t.getUniformLocation(e.bgProgram,"u_currentlyOnGradient"),bgBlurLod:t.getUniformLocation(e.bgProgram,"u_bgBlurLod"),resolution:t.getUniformLocation(e.bgProgram,"u_resolution"),useStaggeredTransition:t.getUniformLocation(e.bgProgram,"u_useStaggeredTransition"),gradientColorLow:t.getUniformLocation(e.bgProgram,"u_gradientColorLow"),gradientColorHigh:t.getUniformLocation(e.bgProgram,"u_gradientColorHigh")},this.particleUniformLocations={texA:t.getUniformLocation(e.particleProgram,"u_texA"),texB:t.getUniformLocation(e.particleProgram,"u_texB"),time:t.getUniformLocation(e.particleProgram,"u_time"),resolution:t.getUniformLocation(e.particleProgram,"u_resolution"),aspectRatio:t.getUniformLocation(e.particleProgram,"u_aspectRatio"),particleSize:t.getUniformLocation(e.particleProgram,"u_particleSize"),isGridView:t.getUniformLocation(e.particleProgram,"u_isGridView"),isTransitioning:t.getUniformLocation(e.particleProgram,"u_isTransitioning"),uvA:t.getUniformLocation(e.particleProgram,"u_uvA"),uvB:t.getUniformLocation(e.particleProgram,"u_uvB"),blendFactor:t.getUniformLocation(e.particleProgram,"u_blendFactor"),particleOpacity:t.getUniformLocation(e.particleProgram,"u_particleOpacity"),useGradient:t.getUniformLocation(e.particleProgram,"u_useGradient"),fadeProgress:t.getUniformLocation(e.particleProgram,"u_fadeProgress"),fadeDirection:t.getUniformLocation(e.particleProgram,"u_fadeDirection"),transitionProgress:t.getUniformLocation(e.particleProgram,"u_transitionProgress"),gradientSeed:t.getUniformLocation(e.particleProgram,"u_gradientSeed"),oldGradientSeed:t.getUniformLocation(e.particleProgram,"u_oldGradientSeed"),transitioningToGradient:t.getUniformLocation(e.particleProgram,"u_transitioningToGradient"),transitioningGradients:t.getUniformLocation(e.particleProgram,"u_transitioningGradients"),currentlyOnGradient:t.getUniformLocation(e.particleProgram,"u_currentlyOnGradient"),densityKeepRatio:t.getUniformLocation(e.particleProgram,"u_densityKeepRatio"),densityFadeBand:t.getUniformLocation(e.particleProgram,"u_densityFadeBand"),useStaggeredTransition:t.getUniformLocation(e.particleProgram,"u_useStaggeredTransition"),gradientColorLow:t.getUniformLocation(e.particleProgram,"u_gradientColorLow"),gradientColorHigh:t.getUniformLocation(e.particleProgram,"u_gradientColorHigh"),settleProgress:t.getUniformLocation(e.particleProgram,"u_settleProgress"),settleSizeProgress:t.getUniformLocation(e.particleProgram,"u_settleSizeProgress"),generationProgress:t.getUniformLocation(e.particleProgram,"u_generationProgress")},this.uniformLocationsCached=!0}createEmptyTexture(e){let t=this.gl,i=t.createTexture();return t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),e&&t.generateMipmap(t.TEXTURE_2D),i}rebuildParticles(){let e=this.gl,t=Math.max(2,Math.min(this.renderWidth,this.maxGrid)),i=Math.max(2,Math.min(this.renderHeight,this.maxGrid)),a=Math.max(2,Math.min(Math.floor(t*this.particlesPerPoint),this.maxGrid)),r=Math.max(2,Math.min(Math.floor(i*this.particlesPerPoint),this.maxGrid));this.gridW=a,this.gridH=r,this.particleCount=a*r;let n=new Float32Array(3*this.particleCount),s=0,o=0xffffffff*Math.random()>>>0||1;for(let e=0;e1?(t/(a-1)-.5)*2:0,l=r>1?(e/(r-1)-.5)*2:0;n[s++]=i,n[s++]=l,o^=o<<13,o^=o>>17,o^=o<<5,n[s++]=(o>>>0)/0xffffffff}e.bindVertexArray(this.particleVao),e.bindBuffer(e.ARRAY_BUFFER,this.particleBuffer),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,12,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,1,e.FLOAT,!1,12,8),e.bindVertexArray(null)}recomputeTextureUVs(e,t){for(let i of this.textureData)null!=i.width&&null!=i.height&&(i.uv=A(e,t,i.width,i.height,!1));null!=this.particleColorWidth&&null!=this.particleColorHeight&&(this.particleColorUV=A(e,t,this.particleColorWidth,this.particleColorHeight,!1))}decodeFrameData(e){return this.frameImageCache.get(e)}async bufferFrames(e){if(this.isBuffering||0===this.framePlayback.frames.length)return;this.isBuffering=!0;let t=[];for(let i=0;i{try{let t=this.framePlayback.frames[e];if(null==t)return;let i=await this.decodeFrameData(t);this.decodedFrameBuffer.set(e,i)}catch{}})),this.isBuffering=!1}async uploadFrameToBackgroundTexture(e,t){let i=this.decodedFrameBuffer.get(e);if(null==i){let t=this.framePlayback.frames[e];if(null==t)throw Error("Missing frame data for background upload");i=await this.decodeFrameData(t),this.decodedFrameBuffer.set(e,i)}let a=this.gl;a.bindTexture(a.TEXTURE_2D,this.textures[t]),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i),a.generateMipmap(a.TEXTURE_2D),this.textureData[t].width=i.width,this.textureData[t].height=i.height,this.textureData[t].uv=A(this.renderWidth,this.renderHeight,i.width,i.height,!1)}async uploadParticleColorFrame(e){if(this.currentParticleFrameData!==e)try{let t=await this.decodeFrameData(e),i=this.gl;i.bindTexture(i.TEXTURE_2D,this.particleColorTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.particleColorWidth=t.width,this.particleColorHeight=t.height,this.particleColorUV=A(this.renderWidth,this.renderHeight,t.width,t.height,!1),this.currentParticleFrameData=e}catch{}}async applyPendingParticleColorUpdate(){let e=this.pendingParticleFrameData;null!=e&&(await this.uploadParticleColorFrame(e),this.pendingParticleFrameData=null)}scheduleParticleColorUpdate(e,t,i=!1){if(0===e.length){this.pendingParticleFrameData=null,this.particleColorUpdateDebounced.reset();return}if(t){this.pendingParticleFrameData=null,this.currentParticleFrameData=null,this.particleColorUpdateDebounced.reset();return}let a=e[e.length-1]??e[0];if(null!=a){if(i){if(this.pendingParticleFrameData=null,this.particleColorUpdateDebounced.reset(),a===this.currentParticleFrameData)return;this.uploadParticleColorFrame(a);return}this.pendingParticleFrameData=a,this.particleColorUpdateDebounced()}}async primeParticleColorFromFrameSet(e,t){if(0===e.length)return;if(t){this.pendingParticleFrameData=null,this.currentParticleFrameData=null;return}let i=e[e.length-1]??e[0];null!=i&&(this.pendingParticleFrameData=null,await this.uploadParticleColorFrame(i))}async loadAndDisplayFrameWithTransition(e,t){if(e>=this.framePlayback.frames.length)return;let i=++this.loadRequestId,a=+(0===this.displayTexIndex);try{if(await this.uploadFrameToBackgroundTexture(e,a),i!==this.loadRequestId)return;this.uploadTexIndex=a,this.pendingUploadTexIndex=this.displayTexIndex,this.beginTimedTransition(t,!1),this.framePlayback.isPlaying=this.framePlayback.frames.length>this.videoFrameThreshold;let r=(e+1)%this.framePlayback.frames.length;this.bufferFrames(r)}catch{S.error({frameIndex:e},"Failed to load frame with transition")}}async loadAndDisplayFrame(e){if(e>=this.framePlayback.frames.length)return;let t=++this.loadRequestId,i=this.pendingUploadTexIndex;this.pendingUploadTexIndex=+(0===i);try{if(await this.uploadFrameToBackgroundTexture(e,i),t!==this.loadRequestId)return;this.uploadTexIndex=i,this.hasDisplayedContent=!0;let a=1===this.framePlayback.frames.length;if(this.innerState.currentlyOnGradient>.5||this.innerState.useGradient>.5){let e=a?E(this.framePlayback.fps):this.crossFadeDuration;this.beginTimedTransition(e,!0)}else a?this.beginTimedTransition(E(this.framePlayback.fps),!1):this.beginTransition();let r=(e+1)%this.framePlayback.frames.length;this.bufferFrames(r)}catch{S.error({frameIndex:e},"Failed to load frame"),this.pendingUploadTexIndex=i}}beginTransition(){this.innerState.isTransitioning=!0,this.useStaggeredTransition=!1,this.innerState.transitionStart=0,this.innerState.transitionDuration=null,this.innerState.transitionProgress=0,this.innerState.backgroundTransitionProgress=0,this.innerState.blendFactor=0,this.innerState.backgroundBlendFactor=0,this.triggerSpeedBurst()}beginTimedTransition(e,t){this.innerState.isTransitioning=!0,this.useStaggeredTransition=t,this.innerState.transitionStart=performance.now(),this.innerState.transitionDuration=Math.max(1,e),this.innerState.transitionProgress=0,this.innerState.backgroundTransitionProgress=0,this.innerState.blendFactor=0,this.innerState.backgroundBlendFactor=0,this.triggerSpeedBurst()}completeTransition(){this.innerState.isTransitioning&&(this.innerState.isTransitioning=!1,this.innerState.transitioningToGradient>.5||this.innerState.transitioningGradients>.5?(this.innerState.useGradient=1,this.innerState.currentlyOnGradient=1):(this.displayTexIndex=this.uploadTexIndex,this.innerState.useGradient=0,this.innerState.currentlyOnGradient=0),this.innerState.transitionProgress=0,this.innerState.backgroundTransitionProgress=0,this.innerState.blendFactor=0,this.innerState.backgroundBlendFactor=0,this.innerState.transitionDuration=null,this.innerState.transitionStart=0,this.useStaggeredTransition=!1,this.innerState.transitioningToGradient=0,this.innerState.transitioningGradients=0,this.innerState.oldGradientSeed=0)}transitionToGradient(){if(this.innerState.currentlyOnGradient>.5&&!this.innerState.isTransitioning){this.innerState.useGradient=1,this.innerState.currentlyOnGradient=1;return}this.innerState.oldGradientSeed=0,this.innerState.transitioningGradients=0,this.innerState.transitioningToGradient=1,this.innerState.gradientSeed=M(1e3),this.beginTimedTransition(this.crossFadeDuration,!0)}triggerSpeedBurst(){this.speedBurst.isActive=!0,this.speedBurst.startTs=performance.now()}updateTimeAndFade(e){let t=(e-this.innerState.lastUpdateTs)/1e3;if(this.innerState.lastUpdateTs=e,this.updateBackgroundBlurSmoothing(e),this.updateGenerationProgressMotion(t),this.speedBurst.isActive){let i=Math.min(1,(e-this.speedBurst.startTs)/this.speedBurst.durationMs),a=Math.sin((3*(1-i)*i*i+i*i*i)*Math.PI)*(this.speedBurst.peakMultiplier-1);this.speedBurst.accumulatedTime+=a*this.speedMultiplier*t,i>=1&&(this.speedBurst.isActive=!1)}if(this.settleAnimating){let i=e-this.settleStartTs;this.stepSpring(this.settleSpring,this.settleMovementStiffness,this.settleMovementDamping,t),this.settleProgress=Math.max(0,Math.min(1,this.settleSpring.position)),i>=this.settleSizeDelayMs&&(this.settleSizeStarted||(this.settleSizeStarted=!0),this.stepSpring(this.settleSizeSpring,this.settleSizeStiffness,this.settleSizeDamping,t),this.settleSizeProgress=Math.max(0,Math.min(1,this.settleSizeSpring.position)));let a=i>=this.settleFadeDelayMs,r=this.settleProgress>=this.settleFadeStartProgress;a&&r&&!this.settleFadeStarted&&(this.settleFadeStarted=!0,this.setParticleOpacity(0,!0,this.settleFadeDurationSec));let n=this.isSpringSettled(this.settleSpring),s=!this.settleSizeStarted||this.isSpringSettled(this.settleSizeSpring),o=this.settleFadeStarted&&!this.innerState.fadeAnimating&&this.innerState.particleOpacity<=.001;n&&s&&o&&(this.settleAnimating=!1,this.settleProgress=1,this.settleSizeProgress=1)}if(this.innerState.fadeAnimating){let t=Math.min(1,(e-this.innerState.fadeStart)/this.innerState.fadeDurationMs),i=t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;this.innerState.particleOpacity=this.innerState.fadeFrom+(this.innerState.fadeTo-this.innerState.fadeFrom)*i,t>=1&&(this.innerState.fadeAnimating=!1,this.innerState.particleOpacity=this.innerState.fadeTo)}this.innerState.particleOpacity<=0&&!this.hasEmittedParticleFadeOut&&(this.hasEmittedParticleFadeOut=!0,this.particleFadeOutCallback?.());let i=((e-this.innerState.startTs)/1e3*this.speedMultiplier%100+this.speedBurst.accumulatedTime%100+this.innerState.randomTimeOffset)%100;this.innerState.time=i}updateBackgroundBlurSmoothing(e){if(.001>Math.abs(this.backgroundBlurRadiusPx-this.backgroundBlurTargetPx)){this.backgroundBlurRadiusPx=this.backgroundBlurTargetPx;return}this.backgroundBlurAnimationStartTs<=0&&(this.backgroundBlurAnimationStartTs=e,this.backgroundBlurAnimationStartPx=this.backgroundBlurRadiusPx);let t=Math.min(1,(e-this.backgroundBlurAnimationStartTs)/Math.max(1,this.backgroundBlurAnimationDurationMs));this.backgroundBlurRadiusPx=this.backgroundBlurAnimationStartPx+(this.backgroundBlurTargetPx-this.backgroundBlurAnimationStartPx)*(t*t*(3-2*t)),t>=1&&(this.backgroundBlurRadiusPx=this.backgroundBlurTargetPx,this.backgroundBlurAnimationStartTs=0)}smoothstep01(e){let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)}easeInOutCubic01(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}getSettleInitialVelocity(){let e=this.getProgressDampingForGenerationProgress(this.generationProgressForDisplacement),t=Math.max(0,Math.min(1,this.generationProgressSpring.velocity*this.settleMovementInitialVelocityMultiplier))*(1-e)+this.settleSpring.velocity;return Math.max(-this.settleMovementInitialVelocityMax,Math.min(this.settleMovementInitialVelocityMax,t))}getProgressDampingForGenerationProgress(e){return 1-.7*Math.max(0,Math.min(1,e))}updateGenerationProgressMotion(e){let t=Math.max(0,Math.min(.05,e)),i=this.generationProgressTarget-this.generationProgressSmoothedTarget,a=t<=0?0:1-Math.exp(-Math.LN2*t/(i>=0?.24:.08));this.generationProgressSmoothedTarget+=i*a,this.generationProgressSpring.target=this.generationProgressSmoothedTarget,this.stepSpring(this.generationProgressSpring,this.generationProgressSpringStiffness,this.generationProgressSpringDamping,e);let r=Math.max(0,Math.min(1,this.generationProgressSpring.position)),n=this.smoothstep01(r),s=Math.min(1,Math.pow(n,.92));this.generationProgressForDensity=this.completionProgressFrozen?this.completionFrozenProgressForDensity:n,this.generationProgressForDisplacement=this.completionProgressFrozen?this.completionFrozenProgressForDisplacement:s;let o=1-this.generationProgressForDensity;this.particleDensityKeepRatio=.5+.5*o,this.particleDensityFadeBand=.06*(1+.25*this.generationProgressForDensity)}updateTransitionState(e){if(!this.innerState.isTransitioning)return;if(null!=this.innerState.transitionDuration){let t=Math.min(1,(e-this.innerState.transitionStart)/this.innerState.transitionDuration);this.innerState.transitionProgress=t,this.innerState.backgroundTransitionProgress=t,this.innerState.blendFactor=t,this.innerState.backgroundBlendFactor=t,t>=1&&(this.completeTransition(),this.framePlayback.lastFrameChangeTs=e);return}if(this.framePlayback.fps<=0)return;if(0===this.framePlayback.lastFrameChangeTs){this.framePlayback.lastFrameChangeTs=e;return}let t=1e3/this.framePlayback.fps,i=Math.min(1,(e-this.framePlayback.lastFrameChangeTs)/t);this.innerState.transitionProgress=i,this.innerState.backgroundTransitionProgress=i,this.innerState.blendFactor=i,this.innerState.backgroundBlendFactor=i,i>=1&&this.completeTransition()}flushPendingFrameSetAfterTransition(){if(this.innerState.isTransitioning||null==this.pendingFrameSet)return;let e=this.pendingFrameSet;this.pendingFrameSet=null,this.setFrames(e.frames,e.fps)}updateFramePlayback(e){if(!this.framePlayback.isPlaying||0===this.framePlayback.frames.length||this.framePlayback.frames.length<=this.videoFrameThreshold||this.innerState.isTransitioning&&null!=this.innerState.transitionDuration||this.framePlayback.fps<=0)return;if(0===this.framePlayback.lastFrameChangeTs){this.framePlayback.lastFrameChangeTs=e;return}let t=1e3/this.framePlayback.fps;if(e-this.framePlayback.lastFrameChangeTs=20&&(this.adaptiveFrameTimeRunningSum-=this.adaptiveFrameTimeSamples[this.adaptiveFrameTimeSampleIndex]??0),this.adaptiveFrameTimeSamples[this.adaptiveFrameTimeSampleIndex]=e,this.adaptiveFrameTimeRunningSum+=e,this.adaptiveFrameTimeSampleIndex=(this.adaptiveFrameTimeSampleIndex+1)%20,this.adaptiveFrameTimeSampleCount<20&&this.adaptiveFrameTimeSampleCount++}getAverageFrameTime(){return 0===this.adaptiveFrameTimeSampleCount?0:this.adaptiveFrameTimeRunningSum/this.adaptiveFrameTimeSampleCount}updateAdaptiveQuality(e){if(!this.adaptiveQualityEnabled)return;if(this.adaptiveWarmupFramesRemaining>0)return void this.adaptiveWarmupFramesRemaining--;if(this.adaptiveFrameTimeSampleCount<20||this.adaptiveStartIndex+this.adaptiveStepsDown>=y.length-1||this.adaptiveLastTierChangeTs>0&&e-this.adaptiveLastTierChangeTs<1500)return;let t=25*this.adaptiveFrameSkip,i=this.getAverageFrameTime();i>t&&this.applyAdaptiveStepDown(e,i)}applyAdaptiveStepDown(e,t){let i=this.adaptiveStepsDown+1,a=this.adaptiveStartIndex+i;if(a>=y.length)return;let r=y[a];if(null==r)return;this.adaptiveStepsDown=i,this.adaptiveLastTierChangeTs=e,this.adaptiveBlurOffset=r.blurOffset,this.adaptiveFrameSkip=r.frameSkip,this.setParticleCountSettingValues(r.setting);let n=this.adaptiveBaseScaleFactor*r.scaleMultiplier;Math.abs(n-this.scaleFactor)>.001?(this.scaleFactor=n,this.resize()):this.rebuildParticles(),this.adaptiveFrameTimeSampleCount=0,this.adaptiveFrameTimeSampleIndex=0,this.adaptiveFrameTimeRunningSum=0,this.adaptiveLastRenderTs=0,this.adaptiveWarmupFramesRemaining=30}lastTickTimestamp=0;tick(e){this.lastTickTimestamp=e,this.computeRenderSize(),this.updateTimeAndFade(e),this.updateTransitionState(e),this.flushPendingFrameSetAfterTransition(),this.updateFramePlayback(e)}render(e,t){if(this.uniformLocationsCached||this.cacheUniformLocations(t),this.adaptiveFrameCounter++,!(this.adaptiveFrameSkip<=1||this.adaptiveFrameCounter%this.adaptiveFrameSkip==0))return!1;if(e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this.drawBackground(e,t),this.drawParticles(e,t),this.adaptiveQualityEnabled){let e=this.lastTickTimestamp;if(this.adaptiveLastRenderTs>0){let t=e-this.adaptiveLastRenderTs;this.recordFrameTime(t)}this.adaptiveLastRenderTs=e,this.updateAdaptiveQuality(e)}return!0}contextRestored(e){this.gl=e,this.uniformLocationsCached=!1,this.initInstanceGL(),this.setParticleCountSetting(this.particleCountSetting)}}e.s(["default",()=>R,"getPartialResultsSandLoaderRenderer",0,function(){return(0,a.getOrCreateRenderer)("partialResultsSand",D)}],552122)},803534,508324,e=>{"use strict";var t=e.i(964355),i=e.i(472361),a=e.i(451347),r=e.i(900893);function n(e){let n=(0,r.useConstant)(()=>(0,t.motionValue)(e)),{isStatic:s}=(0,i.useContext)(a.MotionConfigContext);if(s){let[,t]=(0,i.useState)(e);(0,i.useEffect)(()=>n.on("change",t),[])}return n}e.s(["useMotionValue",0,n],803534);var s=e.i(562667),o=e.i(907953),l=e.i(478146);function u(e,t){let i=n(t()),a=()=>i.set(t());return a(),(0,l.useIsomorphicLayoutEffect)(()=>{let t=()=>o.frame.preRender(a,!1,!0),i=e.map(e=>e.on("change",t));return()=>{i.forEach(e=>e()),(0,o.cancelFrame)(a)}}),i}function c(e,t){let i=(0,r.useConstant)(()=>[]);return u(e,()=>{i.length=0;let a=e.length;for(let t=0;tObject.keys(h)),s=(0,r.useConstant)(()=>({}));for(let i of t)s[i]=e(l,d,h[i],m);return s}let f="function"==typeof a?a:function(...e){let t=!Array.isArray(e[0]),i=t?0:-1,a=e[0+i],r=e[1+i],n=e[2+i],o=e[3+i],l=(0,s.interpolate)(r,n,o);return t?l(a):l}(a,n,o),g=Array.isArray(i)?c(i,f):c([i],([e])=>f(e)),p=Array.isArray(i)?void 0:i.accelerate;return p&&!p.isTransformed&&"function"!=typeof a&&Array.isArray(n)&&o?.clamp!==!1&&(g.accelerate={...p,times:a,keyframes:n,isTransformed:!0,...o?.ease?{ease:o.ease}:{}}),g}],508324)},139335,510729,e=>{"use strict";var t=e.i(733783),i=e.i(267989),a=e.i(908464),r=e.i(472361),n=e.i(899272),s=e.i(840387),o=e.i(314516),l=e.i(40339),u=e.i(378810),c=e.i(689469),d=e.i(996208),h=e.i(552122),m=e.i(707524),f=e.i(803534),g=e.i(508324);class p{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let i=0;it.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return S(this.animations,"duration")}get iterationDuration(){return S(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function S(e,t){let i=0;for(let a=0;ai&&(i=r)}return i}class v extends p{then(e,t){return this.finished.finally(e).then(()=>{})}}var T=e.i(926935),P=e.i(964355),_=e.i(753584),b=e.i(350764),x=e.i(931224),y=e.i(430142),F=e.i(219084),A=e.i(998809),M=e.i(470934),E=e.i(633836),D=e.i(725542),R=e.i(991388),C=e.i(577182);function L(e,t){var i;let a;return(0,C.isEasingArray)(e)?e[i=e.length,((t-0)%(a=i-0)+a)%a+0]:e}var I=e.i(488133);function U(e){return"object"==typeof e&&!Array.isArray(e)}function G(e,t,i,a){return null==e?[]:"string"==typeof e&&U(t)?(0,I.resolveElements)(e,i,a):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>null!=e):[e]}function B(e,t,i,a){return"number"==typeof t?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):"<"===t?i:t.startsWith("<")?Math.max(0,i+parseFloat(t.slice(1))):a.get(t)??e}var O=e.i(341330);function k(e,t){return e.at!==t.at?e.at-t.at:null===e.value?1:null===t.value?-1:0}function w(e,t){return t.has(e)||t.set(e,{}),t.get(e)}function N(e,t){return t[e]||(t[e]=[]),t[e]}let V=e=>"number"==typeof e,z=e=>e.every(V);var H=e.i(659367),W=e.i(323482),X=e.i(900332),j=e.i(170899),q=e.i(359569),K=e.i(488257),Q=e.i(882979),Y=e.i(686968),$=e.i(481103);class Z extends $.VisualElement{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,t){if(t in e){let i=e[t];if("string"==typeof i||"number"==typeof i)return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return(0,Y.createBox)()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}}function J(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},i=(0,j.isSVGElement)(e)&&!(0,q.isSVGSVGElement)(e)?new K.SVGVisualElement(t):new Q.HTMLVisualElement(t);i.mount(e),W.visualElementStore.set(e,i)}function ee(e){let t=new Z({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),W.visualElementStore.set(e,t)}function et(e,t,i,a){let r=[];if((0,b.isMotionValue)(e)||"number"==typeof e||"string"==typeof e&&!U(t))r.push((0,H.animateSingleValue)(e,U(t)&&t.default||t,i&&i.default||i));else{if(null==e)return r;let n=G(e,t,a),s=n.length;(0,D.invariant)(!!s,"No valid elements provided.","no-valid-elements");for(let e=0;e{var l;let u=Array.isArray(l=e)?l:[l],{delay:c=0,times:m=(0,x.defaultOffset)(u),type:f=t.type||"keyframes",repeat:g,repeatType:p,repeatDelay:S=0,...P}=i,{ease:_=t.ease||"easeOut",duration:b}=i,M="function"==typeof c?c(s,o):c,C=u.length,I=(0,y.isGenerator)(f)?f:r?.[f||"keyframes"];if(C<=2&&I){let e=100;2===C&&z(u)&&(e=Math.abs(u[1]-u[0]));let i={...t,...P};void 0!==b&&(i.duration=(0,E.secondsToMilliseconds)(b));let a=(0,F.createGeneratorEasing)(i,e,I);_=a.ease,b=a.duration}b??(b=n);let U=d+M;1===m.length&&0===m[0]&&(m[1]=1);let G=m.length-u.length;if(G>0&&(0,A.fillOffset)(m,G),1===u.length&&u.unshift(null),g&&(0,D.warning)(g<20,`Sequence segments can't repeat ${g} times — ignoring repeat option. Use a value below 20 or apply repeat at the sequence level instead.`),g&&g<20){let e=b>0?S/b:0;b=b*(g+1)+S*g;let t=[...u],i=[...m],a=[..._=Array.isArray(_)?[..._]:[_]],r="reverse"===p||"mirror"===p,n=t,s=a;r&&(n=[...t].reverse(),"reverse"===p&&(s=[...a].reverse().map(e=>"function"==typeof e?(0,R.reverseEasing)(e):e)));for(let o=0;o0&&(u.push(u[u.length-1]),m.push(h),_.push("linear")),u.push(...c);for(let e=0;er&&i.at{for(let r in e){let n=e[r];n.sort(k);let o=[],l=[],u=[];for(let e=0;e{if(Array.isArray(e)&&"function"==typeof e[0]){let t=e[0],i=(0,P.motionValue)(0);return(i.on("change",t),1===e.length)?[i,[0,1]]:2===e.length?[i,[0,1],e[1]]:[i,e[1],e[2]]}return e}),s,t,{spring:_.spring}).forEach(({keyframes:e,transition:t},a)=>{i.push(...et(a,e,t))}),l=i}else{let{onComplete:i,...a}=n||{};"function"==typeof i&&(o=i),l=et(e,r,{...u,...a},t)}let c=new v(l);return o&&c.finished.then(o),t&&(t.animations.push(c),c.finished.then(()=>{(0,T.removeItem)(t.animations,c)})),c}}(),ea=(0,r.createContext)({averageProgress:0,setProgress:()=>{}});function er(e,t){return e+t}function en(){return(0,r.useContext)(ea)}function es(e){return Math.max(0,Math.min(1,e))}function eo(e){return`${Math.min(Math.round(e),100).toLocaleString()}%`}e.s(["MediaGenerationProgressProvider",0,function(e){let i,n,s,o,l,u,c,d,h=(0,a.c)(11),{children:m}=e;h[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,h[0]=i):i=h[0];let f=(0,r.useRef)(i),[g,p]=(0,r.useState)(0),S=(0,r.useRef)(null);h[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{let e=Array.from(f.current.values());0===e.length?p(0):p(e.reduce(er,0)/e.length)},h[1]=n):n=h[1];let v=n;h[2]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{null==S.current&&(S.current=window.setTimeout(()=>{S.current=null,v()},100))},h[2]=s):s=h[2];let T=s;h[3]===Symbol.for("react.memo_cache_sentinel")?(o=(e,t)=>{f.current.get(e)!==t&&(f.current.set(e,t),T())},h[3]=o):o=h[3];let P=o;h[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>()=>{null!=S.current&&(window.clearTimeout(S.current),S.current=null)},u=[],h[4]=l,h[5]=u):(l=h[4],u=h[5]),(0,r.useEffect)(l,u),h[6]!==g?(c={averageProgress:g,setProgress:P},h[6]=g,h[7]=c):c=h[7];let _=c;return h[8]!==m||h[9]!==_?(d=(0,t.jsx)(ea.Provider,{value:_,children:m}),h[8]=m,h[9]=_,h[10]=d):d=h[10],d},"useMediaGenerationProgress",0,en],510729),(0,s.createClientLogger)("EctoPartialResultsSandLoader"),e.s(["EctoPartialResultsSandLoader",0,function(e){var s;let p,S,v,T,P,_,b,x,y,F,A,M,E,D,R,C,L,I,U,G,B,O,k,w,N,V,z,H,W,X,j,q=(0,a.c)(84),{index:K,partialResult:Q,blurMultiplier:Y,darkMode:$,particleCount:Z,className:J,onParticlesFadedOut:ee,showProgressPercentage:et,adaptiveQuality:ea}=e,er=void 0!==$&&$,el=void 0===Z?"medium":Z,eu=void 0===ea||ea,ec=(0,r.useRef)(null),[ed,eh]=(0,r.useState)(null),em=(0,r.useRef)(!1),ef=(0,r.useRef)(null),eg=(0,r.useRef)(null),ep=(0,d.useBitmapRendererSupport)(),[eS,ev]=(0,r.useState)(!1),eT=ep&&!eS,{averageProgress:eP,setProgress:e_}=en();Q?.frames;let eb=(Q?.frames?.length??0)>0,ex=(0,f.useMotionValue)(0),ey=(0,g.useTransform)(ex,eo),eF=0===eP,eA=Q?.status==="SUCCESS",eM=eA?1:Q?.progress??0;q[0]!==K||q[1]!==eM||q[2]!==e_?(p=()=>{e_(K,eM)},S=[K,eM,e_],q[0]=K,q[1]=eM,q[2]=e_,q[3]=p,q[4]=S):(p=q[3],S=q[4]),(0,r.useEffect)(p,S),q[5]!==eP||q[6]!==eA||q[7]!==eb||q[8]!==ex||q[9]!==et?(v=()=>{if(!et)return;let e=eb?2:1;ei(ex,100*eP,{duration:eA?.75:3.5*e,ease:[.16,.04,.3,1]})},T=[eP,ex,eA,eb,et],q[5]=eP,q[6]=eA,q[7]=eb,q[8]=ex,q[9]=et,q[10]=v,q[11]=T):(v=q[10],T=q[11]),(0,r.useEffect)(v,T),(0,c.useRendererVisibility)(ec,ed,h.getPartialResultsSandLoaderRenderer),q[12]!==eu||q[13]!==er||q[14]!==eT||q[15]!==ed||q[16]!==ee||q[17]!==el?(_=()=>{let e=ec.current;if(null!=e&&eT&&null==ed)try{let t=(0,h.getPartialResultsSandLoaderRenderer)(),i=e.getContext("bitmaprenderer");if(null==i)return;let a=t.getGL(),r=new h.default(e,i,a,{darkMode:er,particleCountSetting:el,onParticlesFadedOut:ee,adaptiveQuality:eu});em.current=!1,eh(r)}catch(e){ev(!0)}},P=[eT,er,el,ee,eu,ed],q[12]=eu,q[13]=er,q[14]=eT,q[15]=ed,q[16]=ee,q[17]=el,q[18]=P,q[19]=_):(P=q[18],_=q[19]),(0,r.useLayoutEffect)(_,P),q[20]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{null!=eg.current&&(window.cancelAnimationFrame(eg.current),eg.current=null),ef.current=null,eh(null)},x=[],q[20]=b,q[21]=x):(b=q[20],x=q[21]),(0,r.useEffect)(b,x),q[22]!==ed?(y=()=>{ed?.resize()},q[22]=ed,q[23]=y):y=q[23];let eE=y,eD=(0,u.useResizeObserver)(eE);q[24]!==eD?(F=e=>{ec.current=e,null!=e&&eD(e)},q[24]=eD,q[25]=F):F=q[25];let eR=F,eC=(s=Q?.progress,(eA?0:1.2+13.8*(1-es(s??0)))*(void 0===Y?1:Y));if(q[26]!==Q){let e,t;e=Q?.frames.length??0,t=Q?.fps??3,A=e>12?t:e>1?3:.5,q[26]=Q,q[27]=A}else A=q[27];let eL=A;Q?.frames,q[28]!==Q?.frames?(M=Array.from(Q?.frames??[]),q[28]=Q?.frames,q[29]=M):M=q[29];let eI=M;if(q[30]!==eC||q[31]!==ed?(E=()=>{ed?.setBackgroundBlurRadius(eC)},D=[ed,eC],q[30]=eC,q[31]=ed,q[32]=E,q[33]=D):(E=q[32],D=q[33]),(0,r.useEffect)(E,D),q[34]!==er||q[35]!==ed?(R=()=>{ed?.setDarkMode(er)},C=[ed,er],q[34]=er,q[35]=ed,q[36]=R,q[37]=C):(R=q[36],C=q[37]),(0,r.useEffect)(R,C),q[38]!==ed||q[39]!==el?(L=()=>{ed?.setParticleCountSetting(el)},I=[ed,el],q[38]=ed,q[39]=el,q[40]=L,q[41]=I):(L=q[40],I=q[41]),(0,r.useEffect)(L,I),q[42]!==ed||q[43]!==ee?(U=()=>{ed?.setOnParticlesFadedOut(ee)},G=[ed,ee],q[42]=ed,q[43]=ee,q[44]=U,q[45]=G):(U=q[44],G=q[45]),(0,r.useEffect)(U,G),q[46]!==eu||q[47]!==ed?(B=()=>{ed?.setAdaptiveQuality(eu)},O=[ed,eu],q[46]=eu,q[47]=ed,q[48]=B,q[49]=O):(B=q[48],O=q[49]),(0,r.useEffect)(B,O),q[50]!==eI||q[51]!==eL||q[52]!==ed?(k=()=>{null==ed||(ef.current={frames:eI,fps:eL},null==eg.current&&(eg.current=window.requestAnimationFrame(()=>{eg.current=null;let e=ef.current;ef.current=null,null!=e&&ed.setFrames(e.frames,e.fps)})))},w=[ed,eI,eL],q[50]=eI,q[51]=eL,q[52]=ed,q[53]=k,q[54]=w):(k=q[53],w=q[54]),(0,r.useEffect)(k,w),q[55]!==ed||q[56]!==Q?(N=()=>{if(null==ed)return;if(null==Q){em.current=!1,ed.setGenerationProgress(0),ed.setParticleOpacity(1);return}let e=Q.status;if("SUCCESS"===e){ed.setGenerationProgress(1),em.current||(em.current=!0,ed.startCompletionReveal());return}if(em.current=!1,"IN_PROGRESS"===e){let e=es(Q.progress??0);ed.setGenerationProgress(e),ed.setParticleOpacity(1)}else ed.setGenerationProgress(0),ed.setParticleOpacity(1)},V=[ed,Q],q[55]=ed,q[56]=Q,q[57]=N,q[58]=V):(N=q[57],V=q[58]),(0,r.useEffect)(N,V),eT){let e,a,r,s;return q[59]!==J?(e=(0,n.cn)("relative h-full w-full overflow-hidden",J),q[59]=J,q[60]=e):e=q[60],q[61]!==eR?(a=(0,t.jsx)("canvas",{ref:eR,className:"h-full w-full"}),q[61]=eR,q[62]=a):a=q[62],q[63]!==ey||q[64]!==eF||q[65]!==et?(r=et&&(0,t.jsx)("div",{className:"pointer-events-none absolute start-3 top-3 z-0",children:(0,t.jsx)("div",{className:"bg-fill-secondary-elevated/90 shadow-blur-elevation-01 rounded-full px-3 py-1.5 backdrop-blur-md transition-all duration-[400ms] ease-out starting:scale-[0.8] starting:opacity-0",children:(0,t.jsx)("span",{className:"text-body-medium text-white tabular-nums",children:eF?i.fbt._("Imagining",null,{hk:"3Vcei4"}):(0,t.jsx)(m.motion.span,{children:ey})})})}),q[63]=ey,q[64]=eF,q[65]=et,q[66]=r):r=q[66],q[67]!==e||q[68]!==a||q[69]!==r?(s=(0,t.jsxs)(o.Flexbox,{testid:"ecto-partial-results-sand-loader",className:e,children:[a,r]}),q[67]=e,q[68]=a,q[69]=r,q[70]=s):s=q[70],s}q[71]!==Q?(z=null==Q||0===Q.frames.length?null:Q.frames[Q.frames.length-1]??Q.frames[0]??null,q[71]=Q,q[72]=z):z=q[72];let eU=z,eG=null!=eU?`data:image/jpeg;base64,${eU}`:void 0,eB=Q?.status??"IN_PROGRESS";return q[73]!==J?(H=(0,n.cn)("relative h-full w-full overflow-hidden",J),q[73]=J,q[74]=H):H=q[74],q[75]!==eC||q[76]!==eG?(W=null!=eG&&(0,t.jsx)("img",{src:eG,alt:"",className:"h-full w-full object-cover object-center transition-[filter] duration-[1.16s] ease-in-out",style:{filter:`blur(${eC}px)`}}),q[75]=eC,q[76]=eG,q[77]=W):W=q[77],q[78]!==eB?(X="SUCCESS"!==eB&&(0,t.jsx)(l.Skeleton,{className:"h-full w-full"}),q[78]=eB,q[79]=X):X=q[79],q[80]!==H||q[81]!==W||q[82]!==X?(j=(0,t.jsxs)(o.Flexbox,{testid:"ecto-partial-results-sand-loader",className:H,children:[W,X]}),q[80]=H,q[81]=W,q[82]=X,q[83]=j):j=q[83],j}],139335)}]); //# debugId=9f26f092-6d63-21e1-5196-8026f6b400fa