ai-wrapped 1.9.0 → 1.11.0
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/README.md +44 -5
- package/bin/cli.ts +143 -15
- package/dist/assets/BotAvatar-B1afqxjz.js +1 -0
- package/dist/assets/CrystalizedBall-fdPnFP5O.js +440 -0
- package/dist/assets/EchoText-CySFjm8w.js +1 -0
- package/dist/assets/GlowCursor-C0jBh3OU.js +221 -0
- package/dist/assets/Heatwave-CjFyQGbM.js +146 -0
- package/dist/assets/LightTunnel-DWAZftvN.js +152 -0
- package/dist/assets/LineSpiral-CnfM5ley.js +221 -0
- package/dist/assets/SideRays-BFkjst89.js +114 -0
- package/dist/assets/SlicedWaves-Dpkt-Vaj.js +118 -0
- package/dist/assets/SplitFlapText-Cpb9Vcdu.js +36 -0
- package/dist/assets/Strands-C-50OkYn.js +269 -0
- package/dist/assets/TechText-C7Id1PJM.js +1 -0
- package/dist/assets/archivo-wdth-DY7AcnAa.woff2 +0 -0
- package/dist/assets/index-BiLDfPwS.js +161 -0
- package/dist/assets/index-CyB7FOHv.css +1 -0
- package/dist/index.html +4 -2
- package/electrobun.config.ts +1 -0
- package/package.json +14 -10
- package/skills/ai-wrapped/SKILL.md +111 -0
- package/src/bun/headless.ts +169 -0
- package/src/bun/index.ts +17 -257
- package/src/bun/queries.ts +228 -0
- package/src/bun/share.ts +71 -0
- package/src/shared/buildPayload.test.ts +138 -0
- package/src/shared/buildPayload.ts +224 -0
- package/src/shared/shareData.ts +121 -1
- package/src/shared/types.ts +13 -0
- package/tsconfig.json +1 -1
- package/dist/assets/index-BcAc5_4D.js +0 -45
- package/dist/assets/index-BrZtDnpT.css +0 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import{r as C,j as Be}from"./index-BiLDfPwS.js";const ge=8,ae=3,Ge=4,We=2400,gt=4,V=2.4,ze=2.2,Xe=["#f2f5ff","#7fb2ff","#2f6bff"],xt=`#version 300 es
|
|
2
|
+
void main() {
|
|
3
|
+
vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
|
|
4
|
+
gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
|
|
5
|
+
}`,vt=`#version 300 es
|
|
6
|
+
precision highp float;
|
|
7
|
+
uniform vec2 uRes;
|
|
8
|
+
uniform vec2 uLook;
|
|
9
|
+
uniform float uFocal;
|
|
10
|
+
uniform float uTravel;
|
|
11
|
+
uniform float uSpin;
|
|
12
|
+
uniform float uTwist;
|
|
13
|
+
uniform float uLines;
|
|
14
|
+
uniform float uLayers;
|
|
15
|
+
uniform float uWidth;
|
|
16
|
+
uniform float uWarp;
|
|
17
|
+
uniform float uWave;
|
|
18
|
+
uniform float uReach;
|
|
19
|
+
uniform float uBlur;
|
|
20
|
+
uniform float uSpread;
|
|
21
|
+
uniform float uHue;
|
|
22
|
+
uniform float uStreaks;
|
|
23
|
+
uniform float uStreakPhase;
|
|
24
|
+
uniform float uSeed;
|
|
25
|
+
uniform vec3 uColors[${ge}];
|
|
26
|
+
uniform float uColorCount;
|
|
27
|
+
uniform vec4 uPulses[${ae}];
|
|
28
|
+
uniform vec4 uCursor;
|
|
29
|
+
uniform vec2 uDrag;
|
|
30
|
+
uniform float uIntro;
|
|
31
|
+
uniform float uIntroHead;
|
|
32
|
+
out vec4 outColor;
|
|
33
|
+
|
|
34
|
+
const float TAU = 6.28318530718;
|
|
35
|
+
|
|
36
|
+
vec3 tint(float t) {
|
|
37
|
+
float x = fract(t) * uColorCount;
|
|
38
|
+
float i = floor(x);
|
|
39
|
+
float f = x - i;
|
|
40
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
41
|
+
int a = int(i);
|
|
42
|
+
int b = int(mod(i + 1.0, uColorCount));
|
|
43
|
+
return mix(uColors[a], uColors[b], f);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
float hash(float n) {
|
|
47
|
+
return fract(sin(n * 12.9898 + uSeed * 78.233) * 43758.5453);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vec3 strand(float k, float d, float layer, float depth, float halfWidth, float edge, float lz) {
|
|
51
|
+
float id = mod(k, uLines) + layer * 13.0;
|
|
52
|
+
float h1 = hash(id);
|
|
53
|
+
float h2 = hash(id + 41.0);
|
|
54
|
+
halfWidth *= 0.7 + 0.6 * hash(id + 7.0);
|
|
55
|
+
float w = max(halfWidth, edge * 0.5);
|
|
56
|
+
float t = clamp((w + edge - d) / (2.0 * edge), 0.0, 1.0);
|
|
57
|
+
float body = t * t * (3.0 - 2.0 * t) * min(1.0, halfWidth / w);
|
|
58
|
+
if (body <= 0.0) return vec3(0.0);
|
|
59
|
+
body *= 1.0 - 0.35 * smoothstep(0.0, w + edge, d);
|
|
60
|
+
float world = depth + uTravel;
|
|
61
|
+
float band = pow(0.5 + 0.5 * sin(world * 1.1 + h1 * TAU + uStreakPhase), 6.0);
|
|
62
|
+
float streak = mix(1.0, 0.3 + 2.6 * band, uStreaks);
|
|
63
|
+
float strength = 0.35 + 0.65 * h2;
|
|
64
|
+
float front = uIntro - h1 * 0.4;
|
|
65
|
+
float reveal = smoothstep(front - 0.3, front, lz);
|
|
66
|
+
float head = exp(-pow((lz - front) / 0.12, 2.0)) * uIntroHead;
|
|
67
|
+
vec3 tone = tint(world * 0.06 * uSpread + uHue + h1 * 0.12);
|
|
68
|
+
return tone * body * (strength * streak * reveal + head * 2.5);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
float pulses(float lz) {
|
|
72
|
+
float lift = 0.0;
|
|
73
|
+
for (int k = 0; k < ${ae}; k++) {
|
|
74
|
+
vec4 pulse = uPulses[k];
|
|
75
|
+
if (pulse.w <= 0.0) continue;
|
|
76
|
+
float band = lz - pulse.x;
|
|
77
|
+
lift += pulse.y * exp(-band * band / 0.05);
|
|
78
|
+
}
|
|
79
|
+
return lift;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void main() {
|
|
83
|
+
float px = 1.0 / uRes.y;
|
|
84
|
+
vec2 screen = (gl_FragCoord.xy - 0.5 * uRes) * px;
|
|
85
|
+
vec2 toCursor = screen - uCursor.xy;
|
|
86
|
+
float spot = dot(toCursor, toCursor);
|
|
87
|
+
float near = exp(-spot / 0.04);
|
|
88
|
+
vec2 uv = screen - toCursor * uCursor.w * near - uDrag * exp(-spot / 0.08) - uLook;
|
|
89
|
+
float r = max(length(uv), 1e-3);
|
|
90
|
+
float angle = atan(uv.y, uv.x);
|
|
91
|
+
float lr = log(r);
|
|
92
|
+
float wave = uWarp * (0.55 * sin(lr * 1.9 + uWave) + 0.3 * sin(lr * 3.7 - uWave * 1.37 + 2.1));
|
|
93
|
+
float slope = uWarp * (1.045 * cos(lr * 1.9 + uWave) + 1.11 * cos(lr * 3.7 - uWave * 1.37 + 2.1));
|
|
94
|
+
float cursor = 1.0 + uCursor.z * near;
|
|
95
|
+
vec3 light = vec3(0.0);
|
|
96
|
+
for (int i = 0; i < ${Ge}; i++) {
|
|
97
|
+
float layer = float(i);
|
|
98
|
+
if (layer >= uLayers) break;
|
|
99
|
+
float share = layer / max(uLayers - 1.0, 1.0);
|
|
100
|
+
float radius = pow(1.8, layer);
|
|
101
|
+
float depth = radius * uFocal / r;
|
|
102
|
+
float far = 1.0 - smoothstep(uReach * 0.12, uReach, depth);
|
|
103
|
+
if (far <= 0.0) continue;
|
|
104
|
+
float lz = log(depth);
|
|
105
|
+
float twist = uTwist * mix(1.0, 1.3, share);
|
|
106
|
+
float bend = slope - twist;
|
|
107
|
+
float gap = r * TAU / (uLines * sqrt(1.0 + bend * bend)) / px;
|
|
108
|
+
float dense = smoothstep(2.5, 7.0, gap);
|
|
109
|
+
float spin = uSpin * mix(1.0, 0.5, share) + hash(layer + 91.0) * TAU;
|
|
110
|
+
float phase = (angle - twist * lz - spin - wave) * uLines / TAU;
|
|
111
|
+
float nearest = floor(phase + 0.5);
|
|
112
|
+
float offset = phase - nearest;
|
|
113
|
+
float halfWidth = uWidth * r / radius / px;
|
|
114
|
+
float soft = uBlur * 0.016 * max(log(1.6 / depth), 0.0) / px;
|
|
115
|
+
float edge = sqrt(soft * soft + 0.36);
|
|
116
|
+
float lift = pulses(lz);
|
|
117
|
+
float weight = far * dense * mix(1.0, 0.55, share) * cursor;
|
|
118
|
+
vec3 lit = strand(nearest, abs(offset) * gap, layer, depth, halfWidth, edge, lz);
|
|
119
|
+
lit += strand(nearest + sign(offset), (1.0 - abs(offset)) * gap, layer, depth, halfWidth, edge, lz);
|
|
120
|
+
light += (lit * (1.0 + lift) + vec3(dot(lit, vec3(0.3333))) * lift * 0.8) * weight;
|
|
121
|
+
}
|
|
122
|
+
outColor = vec4(light, 1.0);
|
|
123
|
+
}`,St=`#version 300 es
|
|
124
|
+
precision highp float;
|
|
125
|
+
uniform sampler2D uSource;
|
|
126
|
+
uniform vec2 uTexel;
|
|
127
|
+
uniform float uExposure;
|
|
128
|
+
out vec4 outColor;
|
|
129
|
+
vec3 pick(vec2 at) {
|
|
130
|
+
vec3 c = texture(uSource, at).rgb * uExposure;
|
|
131
|
+
float peak = max(max(c.r, c.g), c.b);
|
|
132
|
+
return c * smoothstep(0.3, 1.4, peak);
|
|
133
|
+
}
|
|
134
|
+
void main() {
|
|
135
|
+
vec2 uv = gl_FragCoord.xy * 2.0 * uTexel;
|
|
136
|
+
vec3 c = pick(uv + vec2(-0.5, -0.5) * uTexel);
|
|
137
|
+
c += pick(uv + vec2(0.5, -0.5) * uTexel);
|
|
138
|
+
c += pick(uv + vec2(-0.5, 0.5) * uTexel);
|
|
139
|
+
c += pick(uv + vec2(0.5, 0.5) * uTexel);
|
|
140
|
+
outColor = vec4(c * 0.25, 1.0);
|
|
141
|
+
}`,wt=`#version 300 es
|
|
142
|
+
precision highp float;
|
|
143
|
+
uniform sampler2D uSource;
|
|
144
|
+
uniform vec2 uTexel;
|
|
145
|
+
out vec4 outColor;
|
|
146
|
+
void main() {
|
|
147
|
+
vec2 uv = gl_FragCoord.xy * 2.0 * uTexel;
|
|
148
|
+
vec3 c = texture(uSource, uv + vec2(-0.5, -0.5) * uTexel).rgb;
|
|
149
|
+
c += texture(uSource, uv + vec2(0.5, -0.5) * uTexel).rgb;
|
|
150
|
+
c += texture(uSource, uv + vec2(-0.5, 0.5) * uTexel).rgb;
|
|
151
|
+
c += texture(uSource, uv + vec2(0.5, 0.5) * uTexel).rgb;
|
|
152
|
+
outColor = vec4(c * 0.25, 1.0);
|
|
153
|
+
}`,bt=`#version 300 es
|
|
154
|
+
precision highp float;
|
|
155
|
+
uniform sampler2D uSource;
|
|
156
|
+
uniform vec2 uStep;
|
|
157
|
+
uniform vec2 uSize;
|
|
158
|
+
out vec4 outColor;
|
|
159
|
+
void main() {
|
|
160
|
+
vec2 uv = gl_FragCoord.xy / uSize;
|
|
161
|
+
vec3 c = texture(uSource, uv).rgb * 0.2270270;
|
|
162
|
+
c += texture(uSource, uv + uStep * 1.3846154).rgb * 0.3162162;
|
|
163
|
+
c += texture(uSource, uv - uStep * 1.3846154).rgb * 0.3162162;
|
|
164
|
+
c += texture(uSource, uv + uStep * 3.2307692).rgb * 0.0702703;
|
|
165
|
+
c += texture(uSource, uv - uStep * 3.2307692).rgb * 0.0702703;
|
|
166
|
+
outColor = vec4(c, 1.0);
|
|
167
|
+
}`,yt=`#version 300 es
|
|
168
|
+
precision highp float;
|
|
169
|
+
uniform sampler2D uSource;
|
|
170
|
+
uniform sampler2D uBase;
|
|
171
|
+
uniform vec2 uSize;
|
|
172
|
+
out vec4 outColor;
|
|
173
|
+
void main() {
|
|
174
|
+
vec2 uv = gl_FragCoord.xy / uSize;
|
|
175
|
+
outColor = vec4(texture(uBase, uv).rgb + texture(uSource, uv).rgb, 1.0);
|
|
176
|
+
}`,Et=`#version 300 es
|
|
177
|
+
precision highp float;
|
|
178
|
+
uniform sampler2D uScene;
|
|
179
|
+
uniform sampler2D uBloom;
|
|
180
|
+
uniform vec2 uRes;
|
|
181
|
+
uniform float uExposure;
|
|
182
|
+
uniform float uGlow;
|
|
183
|
+
uniform float uGrain;
|
|
184
|
+
uniform float uFade;
|
|
185
|
+
uniform float uFrame;
|
|
186
|
+
uniform float uLightMode;
|
|
187
|
+
uniform float uOpacity;
|
|
188
|
+
out vec4 outColor;
|
|
189
|
+
|
|
190
|
+
float h31(vec3 p) {
|
|
191
|
+
p = fract(p * vec3(0.1031, 0.1030, 0.0973));
|
|
192
|
+
p += dot(p, p.yxz + 33.33);
|
|
193
|
+
return fract((p.x + p.y) * p.z);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
float feather(float x, float w) {
|
|
197
|
+
if (w <= 0.0) return 1.0;
|
|
198
|
+
float t = clamp(min(x, 1.0 - x) / w, 0.0, 1.0);
|
|
199
|
+
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
void main() {
|
|
203
|
+
vec2 uv = gl_FragCoord.xy / uRes;
|
|
204
|
+
vec3 c = texture(uScene, uv).rgb * uExposure + texture(uBloom, uv).rgb * uGlow;
|
|
205
|
+
vec3 col = 1.0 - exp(-c);
|
|
206
|
+
col *= feather(uv.x, uFade * 0.34) * feather(uv.y, uFade * 0.44);
|
|
207
|
+
float top = max(max(col.r, col.g), col.b);
|
|
208
|
+
float noise = h31(vec3(floor(gl_FragCoord.xy), uFrame)) - 0.5;
|
|
209
|
+
if (uLightMode > 0.5) {
|
|
210
|
+
vec3 hue = col / max(top, 1e-3);
|
|
211
|
+
float lum = dot(hue, vec3(0.2126, 0.7152, 0.0722));
|
|
212
|
+
vec3 ink = clamp(hue * (0.42 / max(lum, 0.22)), 0.0, 1.0);
|
|
213
|
+
ink = mix(ink, vec3(0.11, 0.12, 0.16), clamp(1.0 - (top - min(min(col.r, col.g), col.b)) * 3.0, 0.0, 1.0) * 0.85);
|
|
214
|
+
float alpha = clamp(top * 1.4 - 0.05, 0.0, 1.0) * 0.95;
|
|
215
|
+
alpha = clamp(alpha + noise * uGrain * alpha, 0.0, 1.0);
|
|
216
|
+
outColor = vec4(ink * alpha, alpha) * uOpacity;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
col = clamp(col + noise * uGrain * (0.25 + col), 0.0, 1.0);
|
|
220
|
+
outColor = vec4(col, max(max(col.r, col.g), col.b)) * uOpacity;
|
|
221
|
+
}`,xe={scene:{source:vt,uniforms:["uRes","uLook","uFocal","uTravel","uSpin","uTwist","uLines","uLayers","uWidth","uWarp","uWave","uReach","uBlur","uSpread","uHue","uStreaks","uStreakPhase","uSeed","uColors","uColorCount","uPulses","uCursor","uDrag","uIntro","uIntroHead"]},down:{source:St,uniforms:["uSource","uTexel","uExposure"]},shrink:{source:wt,uniforms:["uSource","uTexel"]},blur:{source:bt,uniforms:["uSource","uStep","uSize"]},up:{source:yt,uniforms:["uSource","uBase","uSize"]},composite:{source:Et,uniforms:["uScene","uBloom","uRes","uExposure","uGlow","uGrain","uFade","uFrame","uLightMode","uOpacity"]}},q=Object.keys(xe),v=(s,b,g)=>Math.min(g,Math.max(b,s)),p=(s,b)=>{const g=Number(s);return Number.isFinite(g)?g:b},Ne=(s,b,g)=>{const d=s.createShader(b);return d?(s.shaderSource(d,g),s.compileShader(d),d):null},Tt=(s,b)=>{const g=Ne(s,s.VERTEX_SHADER,xt),d=Ne(s,s.FRAGMENT_SHADER,b),y=g&&d?s.createProgram():null;return!g||!d||!y?(g&&s.deleteShader(g),d&&s.deleteShader(d),null):(s.attachShader(y,g),s.attachShader(y,d),s.linkProgram(y),{program:y,vertex:g,fragment:d})},Rt=(s,b,g)=>{const{program:d,vertex:y,fragment:$}=b,K=s.getProgramParameter(d,s.LINK_STATUS);if(!K&&!s.isContextLost()){const k=[y,$].filter(X=>!s.getShaderParameter(X,s.COMPILE_STATUS));k.length?k.forEach(X=>console.error(s.getShaderInfoLog(X))):console.error(s.getProgramInfoLog(d))}if(s.deleteShader(y),s.deleteShader($),!K)return s.deleteProgram(d),null;const Y={};for(const k of g)Y[k]=s.getUniformLocation(d,k);return{program:d,uniforms:Y}},kt=({colors:s=Xe,colorSpread:b=1,colorSpeed:g=.15,lines:d=5,layers:y=3,twist:$=1,direction:K="clockwise",speed:Y=1,spin:k=.2,thickness:X=1,warp:He=.5,streaks:je=.6,depth:Ve=1,blur:qe=.35,glow:$e=.6,brightness:Ke=1,grain:Ye=0,fade:Je=0,variation:Qe=0,opacity:Ze=1,intro:et=!0,mouseInteraction:tt=!0,mouseStrength:ot=1,clickBurst:rt=!0,lightMode:nt=!1,paused:at=!1,dpr:ut,className:st="",...it})=>{const ve=C.useRef(null),Se=C.useRef(null),ue=C.useRef(null),J=C.useRef(0),[lt,ct]=C.useState(0),we={colors:(Array.isArray(s)&&s.length?s:Xe).slice(0,ge).map(String),colorSpread:v(p(b,1),0,6),colorSpeed:p(g,.15),lines:Math.round(v(p(d,5),1,24)),layers:Math.round(v(p(y,3),1,Ge)),twist:v(p($,1),-3,3),turn:K==="counterclockwise"?1:-1,speed:p(Y,1),spin:p(k,.2),thickness:v(p(X,1),.1,6),warp:v(p(He,.5),0,2),streaks:v(p(je,.6),0,1),depth:v(p(Ve,1),.2,3),blur:v(p(qe,.35),0,2),glow:v(p($e,.6),0,3),brightness:Math.max(0,p(Ke,1)),grain:v(p(Ye,0),0,1),fade:v(p(Je,0),0,1),variation:p(Qe,0),opacity:v(p(Ze,1),0,1),intro:et,mouseInteraction:tt,mouseStrength:v(p(ot,1),0,3),clickBurst:rt,lightMode:nt,paused:at,dpr:ut},L=C.useRef(we);return L.current=we,C.useEffect(()=>{ue.current?.()}),C.useEffect(()=>{const U=ve.current,x=Se.current;if(!U||!x)return;cancelAnimationFrame(J.current),J.current=0;const e=x.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"default"});if(!e)return;const Q=e.getExtension("KHR_parallel_shader_compile"),be=!!e.getExtension("EXT_color_buffer_float"),F={},se={};let O=!1;for(const o of q){const r=Tt(e,xe[o].source);r?F[o]=r:O=!0}const ye=()=>{for(const o of q){const r=F[o];if(!r)continue;delete F[o];const n=Rt(e,r,xe[o].uniforms);n?se[o]=n:O=!0}return!O};Q||ye();const Ee=e.createVertexArray(),ie=document.createElement("canvas");ie.width=1,ie.height=1;const B=ie.getContext("2d",{willReadFrequently:!0}),Z=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,le=new Float32Array(ge*3),N=new Float32Array(ae*4),t={travel:2,spin:0,hue:0,wave:0,streak:0,clock:0,frame:0,intro:L.current.intro&&!Z&&!L.current.paused?0:V+2,width:1,height:1,paletteKey:"",colorCount:1,targets:null,pointer:{x:0,y:0,inside:!1,placed:!1},look:{x:0,y:0,vx:0,vy:0},cursor:{x:0,y:0,glow:0,energy:0},trail:{x:0,y:0},drag:{x:0,y:0},surge:0,pulses:[]};let E=0,W=0,ee=!0,ce=!0,te=!1;const ft=o=>{if(!B||!o)return[1,1,1];const r=/^[0-9a-f]{3,8}$/i.test(o)?`#${o}`:o;B.clearRect(0,0,1,1),B.fillStyle="#000000",B.fillStyle=r,B.fillRect(0,0,1,1);const[n,u,f]=B.getImageData(0,0,1,1).data;return[n/255,u/255,f/255]},mt=o=>{const r=o.colors.join("|");r!==t.paletteKey&&(t.paletteKey=r,le.fill(0),o.colors.forEach((n,u)=>le.set(ft(n),u*3)),t.colorCount=o.colors.length)},fe=(o,r)=>{const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,be?e.RGBA16F:e.RGBA8,o,r,0,e.RGBA,be?e.HALF_FLOAT:e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const u=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,u),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),e.bindFramebuffer(e.FRAMEBUFFER,null),{texture:n,framebuffer:u,width:o,height:r}},me=o=>{e.deleteTexture(o.texture),e.deleteFramebuffer(o.framebuffer)},Te=()=>{t.targets&&(me(t.targets.scene),t.targets.levels.forEach(o=>{me(o.a),me(o.b)}),t.targets=null)},ht=()=>{const o=x.width,r=x.height,n=`${o}x${r}`;if(t.targets&&t.targets.key===n)return;Te();const u=[];let f=o,i=r;for(let a=0;a<gt;a++)f=Math.max(1,Math.round(f/2)),i=Math.max(1,Math.round(i/2)),u.push({a:fe(f,i),b:fe(f,i)});t.targets={key:n,scene:fe(o,r),levels:u}},z=(o,r,n,u)=>{e.bindFramebuffer(e.FRAMEBUFFER,r?r.framebuffer:null),e.viewport(0,0,n,u),e.useProgram(o.program),e.drawArrays(e.TRIANGLES,0,3)},_=(o,r)=>{e.activeTexture(e.TEXTURE0+o),e.bindTexture(e.TEXTURE_2D,r)},he=()=>{const{scene:o,down:r,shrink:n,blur:u,up:f,composite:i}=se;if(!o||!r||!n||!u||!f||!i||O||te)return;const a=L.current;if(mt(a),ht(),!t.targets)return;const m=t.targets,P=x.width,D=x.height;e.disable(e.BLEND),e.bindVertexArray(Ee);const I=12*a.depth,R=Math.abs(Math.round(a.variation)),l=o.uniforms;e.useProgram(o.program),e.uniform2f(l.uRes,P,D),e.uniform2f(l.uLook,t.look.x,t.look.y),e.uniform1f(l.uFocal,.9),e.uniform1f(l.uTravel,t.travel+R%37*1.7),e.uniform1f(l.uSpin,(t.spin+R%17*.37)*a.turn),e.uniform1f(l.uTwist,a.twist*2.6*a.turn),e.uniform1f(l.uLines,a.lines),e.uniform1f(l.uLayers,a.layers),e.uniform1f(l.uWidth,.0075*a.thickness),e.uniform1f(l.uWarp,a.warp*.4),e.uniform1f(l.uWave,t.wave+R%23*.61),e.uniform1f(l.uReach,I),e.uniform1f(l.uBlur,a.blur*(a.lightMode?.3:1)),e.uniform1f(l.uSpread,a.colorSpread),e.uniform1f(l.uHue,t.hue+R%11*.09),e.uniform1f(l.uStreaks,a.streaks),e.uniform1f(l.uStreakPhase,t.streak+R%13*.83),e.uniform1f(l.uSeed,R%29*.173),e.uniform3fv(l.uColors,le),e.uniform1f(l.uColorCount,t.colorCount),N.fill(0),t.pulses.forEach((c,h)=>{const w=t.clock-c.start,j=1-w/ze;N[h*4]=Math.log(I)-w*1.9,N[h*4+1]=6*j*j,N[h*4+3]=1}),e.uniform4fv(l.uPulses,N);const oe=t.cursor.glow*Math.min(.3,.12*a.mouseStrength),re=t.cursor.glow*a.mouseStrength*(.25+.45*t.cursor.energy);e.uniform4f(l.uCursor,t.cursor.x,t.cursor.y,re,oe),e.uniform2f(l.uDrag,t.drag.x,t.drag.y);const G=v(t.intro/V,0,1),H=1-Math.pow(1-G,3),ne=G>=1;e.uniform1f(l.uIntro,ne?-20:Math.log(I)+.4-H*(Math.log(I)+1.6)),e.uniform1f(l.uIntroHead,ne?0:1-H),z(o,m.scene,P,D);const M=2.6*a.brightness;let T=m.scene;m.levels.forEach((c,h)=>{const w=h===0?r:n;e.useProgram(w.program),_(0,T.texture),e.uniform1i(w.uniforms.uSource,0),e.uniform2f(w.uniforms.uTexel,1/T.width,1/T.height),h===0&&e.uniform1f(w.uniforms.uExposure,M),z(w,c.a,c.a.width,c.a.height),e.useProgram(u.program),e.uniform1i(u.uniforms.uSource,0),e.uniform2f(u.uniforms.uSize,c.a.width,c.a.height),_(0,c.a.texture),e.uniform2f(u.uniforms.uStep,1/c.a.width,0),z(u,c.b,c.a.width,c.a.height),_(0,c.b.texture),e.uniform2f(u.uniforms.uStep,0,1/c.a.height),z(u,c.a,c.a.width,c.a.height),T=c.a});for(let c=m.levels.length-2;c>=0;c--){const h=m.levels[c];e.useProgram(f.program),_(0,m.levels[c+1].a.texture),_(1,h.a.texture),e.uniform1i(f.uniforms.uSource,0),e.uniform1i(f.uniforms.uBase,1),e.uniform2f(f.uniforms.uSize,h.b.width,h.b.height),z(f,h.b,h.b.width,h.b.height);const w=h.a;h.a=h.b,h.b=w}const S=i.uniforms;e.useProgram(i.program),_(0,m.scene.texture),_(1,m.levels[0].a.texture),e.uniform1i(S.uScene,0),e.uniform1i(S.uBloom,1),e.uniform2f(S.uRes,P,D),e.uniform1f(S.uExposure,M),e.uniform1f(S.uGlow,a.glow*(a.lightMode?.06:.6)),e.uniform1f(S.uGrain,a.grain),e.uniform1f(S.uFade,a.fade),e.uniform1f(S.uFrame,t.frame%977),e.uniform1f(S.uLightMode,a.lightMode?1:0),e.uniform1f(S.uOpacity,a.opacity),z(i,null,P,D),e.bindVertexArray(null)},Re=()=>{const o=L.current,r=Math.max(1,U.clientWidth),n=Math.max(1,U.clientHeight),u=Math.min(o.dpr||window.devicePixelRatio||1,2),f=Math.max(r,n)*u,i=f>We?u*We/f:u,a=Math.max(1,Math.round(r*i)),m=Math.max(1,Math.round(n*i));(x.width!==a||x.height!==m)&&(x.width=a,x.height=m),t.width=r,t.height=n,he()},de=()=>q.filter(o=>F[o]),Me=()=>q.some(o=>{const r=F[o];return!!(r&&Q&&!e.getProgramParameter(r.program,Q.COMPLETION_STATUS_KHR))}),dt=()=>O?!1:de().length?!Q||Me()?!1:ye():!0,pe=o=>{if(E=0,!ce||!ee||document.hidden||te)return;if(!dt()){!O&&de().length&&(E=requestAnimationFrame(pe));return}const r=L.current,n=W?Math.min(.05,(o-W)/1e3):0;W=o;const u=!r.paused&&!Z,{pointer:f,look:i,cursor:a,trail:m,drag:P}=t;if(u){t.clock+=n,t.frame+=1,t.intro+=n,t.surge*=Math.exp(-n/.5);const M=v(t.intro/V,0,1),T=r.speed*(.4+.6*M*M)*(1+t.surge*3);t.travel+=n*T*1.6,t.spin+=n*r.spin*(1+t.surge*2),t.hue+=n*r.colorSpeed*.1,t.wave+=n*(.45+Math.abs(r.speed)*.2),t.streak+=n*(.8+t.surge*2),t.pulses=t.pulses.filter(S=>t.clock-S.start<ze)}else t.intro<V&&(t.intro=V+2);const D=r.mouseInteraction&&f.inside&&!Z,I=t.width/t.height,R=(f.x/t.width-.5)*I,l=.5-f.y/t.height,oe=u?.025:0,re=Math.sin(t.clock*.21)*oe*I,G=Math.sin(t.clock*.17+1.3)*oe,H=D?1:0;if(n>0){if(i.vx+=(24*(re-i.x)-9*i.vx)*n,i.vy+=(24*(G-i.y)-9*i.vy)*n,i.x+=i.vx*n,i.y+=i.vy*n,D){const j=1-Math.exp(-n/.06),Ue=(R-a.x)*j,Oe=(l-a.y)*j;a.x+=Ue,a.y+=Oe;const pt=Math.hypot(Ue,Oe)/n;a.energy+=(Math.min(1,pt*.8)-a.energy)*(1-Math.exp(-n/.25))}else a.energy*=Math.exp(-n/.4);const M=1-Math.exp(-n/.22);m.x+=(a.x-m.x)*M,m.y+=(a.y-m.y)*M;const T=.032*Math.min(r.mouseStrength,2)*a.glow,S=(a.x-m.x)*.7,c=(a.y-m.y)*.7,h=Math.hypot(S,c),w=h>T?T/h:1;P.x=S*w,P.y=c*w,a.glow+=(H-a.glow)*(1-Math.exp(-n/.3))}he();const ne=Math.hypot(i.vx,i.vy)>5e-4||Math.hypot(re-i.x,G-i.y)>5e-4||Math.hypot(a.x-m.x,a.y-m.y)>5e-4||a.energy>.002||Math.abs(H-a.glow)>.002;u||ne?E=requestAnimationFrame(pe):W=0},A=()=>{!E&&ce&&ee&&!document.hidden&&!te&&(E=requestAnimationFrame(pe))},Ce=o=>{const r=U.getBoundingClientRect(),n=o.clientX-r.left,u=o.clientY-r.top;return{x:n,y:u,inside:n>=0&&u>=0&&n<=r.width&&u<=r.height}},ke=o=>{const r=Ce(o),{pointer:n}=t;r.inside&&!n.placed&&(t.cursor.x=(r.x/Math.max(t.width,1)-.5)*(t.width/Math.max(t.height,1)),t.cursor.y=.5-r.y/Math.max(t.height,1),t.cursor.glow<.05&&(t.trail.x=t.cursor.x,t.trail.y=t.cursor.y)),n.x=r.x,n.y=r.y,n.inside=r.inside,n.placed=r.inside,A()},Le=o=>{const r=L.current;if(!(!r.mouseInteraction||!r.clickBurst||o.button!==0||Z||r.paused||o.target instanceof Element&&o.target.closest('a, button, input, textarea, select, label, [role="button"]')||!Ce(o).inside)){for(t.surge=Math.min(1.5,t.surge+1),t.pulses.push({start:t.clock});t.pulses.length>ae;)t.pulses.shift();A()}},Fe=()=>{t.pointer.inside=!1,t.pointer.placed=!1,A()},_e=()=>{W=0,A()},Ae=o=>{o.preventDefault(),te=!0,cancelAnimationFrame(E),E=0},Pe=()=>ct(o=>o+1),De=new ResizeObserver(Re);De.observe(U);const Ie=new IntersectionObserver(o=>{ee=o.some(r=>r.isIntersecting),ee&&(W=0,A())});return Ie.observe(U),window.addEventListener("pointermove",ke,{passive:!0}),window.addEventListener("pointerdown",Le),document.documentElement.addEventListener("pointerleave",Fe),document.addEventListener("visibilitychange",_e),x.addEventListener("webglcontextlost",Ae),x.addEventListener("webglcontextrestored",Pe),Re(),A(),ue.current=()=>{E||he(),A()},()=>{if(ce=!1,cancelAnimationFrame(E),ue.current=null,De.disconnect(),Ie.disconnect(),window.removeEventListener("pointermove",ke),window.removeEventListener("pointerdown",Le),document.documentElement.removeEventListener("pointerleave",Fe),document.removeEventListener("visibilitychange",_e),x.removeEventListener("webglcontextlost",Ae),x.removeEventListener("webglcontextrestored",Pe),!e.isContextLost()){e.deleteVertexArray(Ee),Te(),q.forEach(n=>{const u=se[n];u&&e.deleteProgram(u.program)});const r=()=>{const n=de();if(!(!n.length||e.isContextLost())){if(Me()){requestAnimationFrame(r);return}n.forEach(u=>{const f=F[u];f&&(e.deleteShader(f.vertex),e.deleteShader(f.fragment),e.deleteProgram(f.program),delete F[u])})}};r()}const o=()=>{J.current=0,!x.isConnected&&!e.isContextLost()&&e.getExtension("WEBGL_lose_context")?.loseContext()};x.isConnected?J.current=requestAnimationFrame(o):o()}},[lt]),Be.jsx("div",{ref:ve,className:["relative h-full w-full overflow-hidden",st].filter(Boolean).join(" "),...it,children:Be.jsx("canvas",{ref:Se,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{kt as default};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import{r as S,j as oe}from"./index-BiLDfPwS.js";const Me=24e5,O=Math.PI*2,ne={"top-right":{flipX:0,flipY:0,side:0},"top-left":{flipX:1,flipY:0,side:0},"bottom-right":{flipX:0,flipY:1,side:0},"bottom-left":{flipX:1,flipY:1,side:0},right:{flipX:0,flipY:0,side:1},left:{flipX:1,flipY:0,side:1}},Ee=`#version 300 es
|
|
2
|
+
const vec2 corners[3] = vec2[3](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
|
|
3
|
+
void main() {
|
|
4
|
+
gl_Position = vec4(corners[gl_VertexID], 0.0, 1.0);
|
|
5
|
+
}`,Fe=`#version 300 es
|
|
6
|
+
precision highp float;
|
|
7
|
+
uniform vec2 uResolution;
|
|
8
|
+
uniform float uTime;
|
|
9
|
+
uniform vec3 uColorA;
|
|
10
|
+
uniform vec3 uColorB;
|
|
11
|
+
uniform float uBlend;
|
|
12
|
+
uniform float uIntensity;
|
|
13
|
+
uniform float uSpread;
|
|
14
|
+
uniform float uDensity;
|
|
15
|
+
uniform float uSharpness;
|
|
16
|
+
uniform float uFalloff;
|
|
17
|
+
uniform float uGlow;
|
|
18
|
+
uniform float uSaturation;
|
|
19
|
+
uniform float uDust;
|
|
20
|
+
uniform float uOpacity;
|
|
21
|
+
uniform float uReveal;
|
|
22
|
+
uniform float uLight;
|
|
23
|
+
uniform vec3 uFrame;
|
|
24
|
+
uniform float uAim;
|
|
25
|
+
uniform vec3 uFocus;
|
|
26
|
+
uniform float uSway;
|
|
27
|
+
out vec4 fragColor;
|
|
28
|
+
|
|
29
|
+
float hash(vec2 p) {
|
|
30
|
+
p = fract(p * vec2(123.34, 456.21));
|
|
31
|
+
p += dot(p, p + 45.32);
|
|
32
|
+
return fract(p.x * p.y);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
float noise(vec2 p) {
|
|
36
|
+
vec2 i = floor(p);
|
|
37
|
+
vec2 f = p - i;
|
|
38
|
+
vec2 w = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
|
|
39
|
+
float a = hash(i);
|
|
40
|
+
float b = hash(i + vec2(1.0, 0.0));
|
|
41
|
+
float c = hash(i + vec2(0.0, 1.0));
|
|
42
|
+
float d = hash(i + vec2(1.0, 1.0));
|
|
43
|
+
return mix(mix(a, b, w.x), mix(c, d, w.x), w.y);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
float shafts(float u, float t, float seed, float aa) {
|
|
47
|
+
float sway = (0.4 * sin(t * 0.31 + seed) + 0.24 * sin(t * 0.17 + seed * 2.3)) * uSway;
|
|
48
|
+
float n = 0.7 * noise(vec2(u + sway + seed, t * 0.3)) + 0.3 * noise(vec2(u * 2.4 + sway * 1.5 + seed * 1.7, t * 0.45 + 3.0));
|
|
49
|
+
float width = mix(0.5, 0.1, uSharpness);
|
|
50
|
+
float s = mix(smoothstep(0.5 - width, 0.5 + width, n), 0.5, aa);
|
|
51
|
+
return mix(0.05, 1.0, s);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
float motes(vec2 p, float cell, float t, float seed) {
|
|
55
|
+
p += vec2(t * 0.021, -t * 0.013) + seed * 7.31;
|
|
56
|
+
vec2 grid = p / cell;
|
|
57
|
+
vec2 id = floor(grid);
|
|
58
|
+
vec2 f = grid - id;
|
|
59
|
+
float h = hash(id + seed);
|
|
60
|
+
if (h > 0.5) return 0.0;
|
|
61
|
+
vec2 center = 0.25 + 0.5 * vec2(hash(id + 1.7 + seed), hash(id + 3.1 + seed));
|
|
62
|
+
center += 0.1 * vec2(sin(t * 0.7 + h * 31.0), cos(t * 0.6 + h * 23.0));
|
|
63
|
+
float size = mix(0.035, 0.09, hash(id + 5.3 + seed));
|
|
64
|
+
float edge = length(fwidth(grid)) * 0.7;
|
|
65
|
+
float twinkle = 0.55 + 0.45 * sin(t * 1.9 + h * 41.0);
|
|
66
|
+
return (1.0 - smoothstep(size - edge, size + edge, length(f - center))) * twinkle;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void main() {
|
|
70
|
+
float aspect = uResolution.x / uResolution.y;
|
|
71
|
+
vec2 q = (gl_FragCoord.xy - 0.5 * uResolution) / uResolution.y;
|
|
72
|
+
if (uFrame.x > 0.5) q.x = -q.x;
|
|
73
|
+
if (uFrame.y > 0.5) q.y = -q.y;
|
|
74
|
+
vec2 source = uFrame.z > 0.5 ? vec2(aspect * 0.5 + 0.42, 0.3) : vec2(aspect * 0.5 + 0.1, 0.62);
|
|
75
|
+
float heading = (uFrame.z > 0.5 ? 3.42 : -2.48) + uAim + 0.035 * sin(uTime * 0.21) * uSway;
|
|
76
|
+
vec2 v = q - source;
|
|
77
|
+
float r = length(v);
|
|
78
|
+
float angle = mod(atan(v.y, v.x) - heading + 3.14159265, 6.28318531) - 3.14159265;
|
|
79
|
+
float t = uTime;
|
|
80
|
+
float u = angle * uDensity;
|
|
81
|
+
float aa = smoothstep(0.12, 0.45, fwidth(u));
|
|
82
|
+
float offset = uSpread * 0.22;
|
|
83
|
+
float fanA = exp(-pow((angle + offset) / uSpread, 2.0) * 1.4);
|
|
84
|
+
float fanB = exp(-pow((angle - offset) / (uSpread * 1.15), 2.0) * 1.4);
|
|
85
|
+
float focus = 1.0 + uFocus.z * exp(-pow((angle - uFocus.x) / uFocus.y, 2.0));
|
|
86
|
+
float lightA = fanA * shafts(u, t, 0.0, aa) * focus;
|
|
87
|
+
float lightB = fanB * shafts(u * 0.83, t * 0.6, 17.0, aa) * focus;
|
|
88
|
+
float reach = 1.0 / (1.0 + pow(r / 0.4, uFalloff));
|
|
89
|
+
vec3 glowColor = mix(uColorA, uColorB, uBlend);
|
|
90
|
+
vec3 light = (uColorA * lightA * (1.0 - uBlend) + uColorB * lightB * uBlend) * 2.0 * reach;
|
|
91
|
+
light += glowColor * uGlow * exp(-pow(r / 0.4, 2.0));
|
|
92
|
+
if (uDust > 0.0) {
|
|
93
|
+
float sparkle = motes(q, 0.06, t, 0.0) + 0.7 * motes(q, 0.038, t * 0.8, 9.0);
|
|
94
|
+
light += mix(glowColor, vec3(1.0), 0.6) * sparkle * (lightA + lightB) * reach * uDust * 2.5;
|
|
95
|
+
}
|
|
96
|
+
light *= uIntensity * (1.0 - smoothstep(uReveal * 2.6 - 0.45, uReveal * 2.6, r)) * smoothstep(0.0, 0.35, uReveal);
|
|
97
|
+
float gray = dot(light, vec3(0.2126, 0.7152, 0.0722));
|
|
98
|
+
light = max(mix(vec3(gray), light, uSaturation), 0.0);
|
|
99
|
+
float peak = max(light.r, max(light.g, light.b));
|
|
100
|
+
float grain = (fract(52.9829189 * fract(dot(gl_FragCoord.xy, vec2(0.06711056, 0.00583715)))) - 0.5) / 255.0;
|
|
101
|
+
if (uLight > 0.5) {
|
|
102
|
+
vec3 ink = pow(light / max(peak, 1e-4), vec3(2.0)) * 0.75;
|
|
103
|
+
float alpha = clamp(pow(1.0 - exp(-peak * 2.6), 2.5) * 0.9 * uOpacity + grain, 0.0, 1.0);
|
|
104
|
+
fragColor = vec4(pow(ink, vec3(1.0 / 2.2)) * alpha, alpha);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
float mapped = 1.0 - exp(-peak);
|
|
108
|
+
vec3 tone = light * (mapped / max(peak, 1e-4));
|
|
109
|
+
tone = mix(tone, vec3(mapped), smoothstep(0.7, 1.0, mapped) * 0.55);
|
|
110
|
+
vec3 shown = clamp(tone * uOpacity, 0.0, 1.0);
|
|
111
|
+
float alpha = max(shown.r, max(shown.g, shown.b));
|
|
112
|
+
vec3 color = clamp(shown * alpha + grain, 0.0, 1.0);
|
|
113
|
+
fragColor = vec4(min(color, vec3(alpha)), alpha);
|
|
114
|
+
}`,f=(t,i,s)=>Math.min(s,Math.max(i,t)),Le=t=>((t+Math.PI)%O+O)%O-Math.PI,ae=t=>{const i=String(t||"").trim(),s=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(i);if(s){const d=s[1].length===3?s[1].replace(/./g,h=>h+h):s[1];return[0,2,4].map(h=>parseInt(d.slice(h,h+2),16)/255)}const n=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(i);return n?[n[1],n[2],n[3]].map(d=>f(parseFloat(d)/255,0,1)):[1,1,1]},Ce=(t,i)=>({source:t.side?[i*.5+.42,.3]:[i*.5+.1,.62],heading:t.side?3.42:-2.48}),re=(t,i,s)=>{const n=t.createShader(i);return n?(t.shaderSource(n,s),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error(t.getShaderInfoLog(n)),t.deleteShader(n),null)):null},Ie=t=>{const i=re(t,t.VERTEX_SHADER,Ee),s=re(t,t.FRAGMENT_SHADER,Fe),n=i&&s?t.createProgram():null;if(!i||!s||!n)return i&&t.deleteShader(i),s&&t.deleteShader(s),null;if(t.attachShader(n,i),t.attachShader(n,s),t.linkProgram(n),t.deleteShader(i),t.deleteShader(s),!t.getProgramParameter(n,t.LINK_STATUS))return console.error(t.getProgramInfoLog(n)),t.deleteProgram(n),null;const d={},h=t.getProgramParameter(n,t.ACTIVE_UNIFORMS);for(let R=0;R<h;R++){const A=t.getActiveUniform(n,R);A&&(d[A.name]=t.getUniformLocation(n,A.name))}return{program:n,uniforms:d}},Te=({rayColor1:t="#FFC46B",rayColor2:i="#96c8ff",blend:s=.6,origin:n="top-right",speed:d=2.5,intensity:h=2,spread:R=2,density:A=5,sharpness:ie=.5,tilt:se=0,falloff:le=1.6,glow:fe=1,saturation:ce=1,dust:ue=0,followMouse:he=!0,mouseInfluence:me=.5,intro:de=!0,lightMode:pe=!1,opacity:ve=1,maxDevicePixelRatio:ge=2,className:we="",style:xe})=>{const _=S.useRef(null),G=S.useRef(null),T=S.useRef(null),[V,ye]=S.useState(0),N={colorA:ae(t),colorB:ae(i),blend:f(s,0,1),frame:ne[n]??ne["top-right"],speed:Math.max(0,d)*.4,intensity:Math.max(0,h)*.75,spread:f(R,.1,8)*.225,density:f(A,1,40),sharpness:f(ie,0,1),tilt:f(se,-180,180)*Math.PI/180,falloff:f(le,.2,6),glow:Math.max(0,fe)*1.2,saturation:Math.max(0,ce),dust:f(ue,0,1),followMouse:he,mouseInfluence:f(me,0,1),intro:de,light:pe,opacity:f(ve,0,1),maxRatio:f(ge,.5,3)},C=S.useRef(N);return C.current=N,S.useEffect(()=>{T.current?.()}),S.useEffect(()=>{const b=_.current,l=G.current;if(!b||!l)return;const o=l.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"}),I=o?Ie(o):null;if(!o||!I)return;const M=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=o.createVertexArray(),p={width:1,height:1},g={x:0,y:0,inside:!1},m={value:0,velocity:0},w={angle:0,strength:0};let j=Math.random()*100,E=C.current.intro&&!M&&V===0?0:1,x=0,P=0,k=!0,X=document.visibilityState!=="hidden",q=!1,z=!1;const Se=()=>{const a=C.current,e=b.getBoundingClientRect(),c=Math.max(1,e.width),u=Math.max(1,e.height),y=Math.min(window.devicePixelRatio||1,a.maxRatio,Math.sqrt(Me/(c*u))),F=Math.max(1,Math.round(c*y)),L=Math.max(1,Math.round(u*y));(l.width!==F||l.height!==L)&&(l.width=F,l.height=L),p.width=c,p.height=u},D=()=>{z=!0,v()},Re=a=>{let e=(g.x-p.width/2)/p.height,c=(p.height/2-g.y)/p.height;a.frame.flipX&&(e=-e),a.frame.flipY&&(c=-c);const{source:u,heading:y}=Ce(a.frame,p.width/p.height);return Le(Math.atan2(c-u[1],e-u[0])-y-a.tilt)},H=a=>{if(x=0,z&&(z=!1,Se()),q)return;const e=C.current,c=f((a-P)/1e3||0,0,.05);P=Math.max(P,a),j+=c*e.speed*(M?.3:1),E<1&&(E=Math.min(1,E+c/1.6));const u=e.followMouse&&g.inside&&!M,y=u?Re(e):0,F=u?f(y,-e.spread,e.spread)*e.mouseInfluence:0,L=u?e.mouseInfluence:0,ee=1-Math.exp(-c*6);u&&(w.angle+=(f(y-m.value,-e.spread*1.5,e.spread*1.5)-w.angle)*ee),w.strength+=(L-w.strength)*ee;const te=18,Ae=2*Math.sqrt(te);m.velocity+=((F-m.value)*te-m.velocity*Ae)*c,m.value+=m.velocity*c,o.viewport(0,0,l.width,l.height),o.useProgram(I.program),o.bindVertexArray(U);const r=I.uniforms;o.uniform2f(r.uResolution,l.width,l.height),o.uniform1f(r.uTime,j),o.uniform3f(r.uColorA,e.colorA[0],e.colorA[1],e.colorA[2]),o.uniform3f(r.uColorB,e.colorB[0],e.colorB[1],e.colorB[2]),o.uniform1f(r.uBlend,e.blend),o.uniform1f(r.uIntensity,e.intensity),o.uniform1f(r.uSpread,e.spread),o.uniform1f(r.uDensity,e.density),o.uniform1f(r.uSharpness,e.sharpness),o.uniform1f(r.uFalloff,e.falloff),o.uniform1f(r.uGlow,e.glow),o.uniform1f(r.uSaturation,e.saturation),o.uniform1f(r.uDust,e.dust),o.uniform1f(r.uOpacity,e.opacity),o.uniform1f(r.uReveal,1-Math.pow(1-E,3)),o.uniform1f(r.uLight,e.light?1:0),o.uniform3f(r.uFrame,e.frame.flipX,e.frame.flipY,e.frame.side),o.uniform1f(r.uAim,e.tilt+m.value),o.uniform3f(r.uFocus,w.angle,Math.max(.06,e.spread*.25),w.strength*1.4),o.uniform1f(r.uSway,M?0:1),o.drawArrays(o.TRIANGLES,0,3);const be=Math.abs(F-m.value)>1e-4||Math.abs(m.velocity)>1e-4||Math.abs(L-w.strength)>.001;(e.speed>0&&!M||E<1||be)&&k&&X&&(x=requestAnimationFrame(H))},v=()=>{x||q||!k||!X||(P=performance.now(),x=requestAnimationFrame(H))};T.current=()=>{D(),v()};const $=a=>{const e=b.getBoundingClientRect();g.x=a.clientX-e.left,g.y=a.clientY-e.top,g.inside=a.clientX>=e.left&&a.clientX<=e.right&&a.clientY>=e.top&&a.clientY<=e.bottom,v()},Y=()=>{g.inside=!1,v()},B=a=>{a.pointerType!=="mouse"&&Y()};window.addEventListener("pointermove",$,{passive:!0}),window.addEventListener("pointerup",B,{passive:!0}),window.addEventListener("pointercancel",B,{passive:!0}),document.documentElement.addEventListener("pointerleave",Y);const K=a=>{a.preventDefault(),q=!0,cancelAnimationFrame(x),x=0},W=()=>ye(a=>a+1);l.addEventListener("webglcontextlost",K),l.addEventListener("webglcontextrestored",W);const J=new ResizeObserver(()=>{D(),v()});J.observe(b);const Q=new IntersectionObserver(a=>{k=a.some(e=>e.isIntersecting),v()});Q.observe(b);const Z=()=>{X=document.visibilityState!=="hidden",v()};return document.addEventListener("visibilitychange",Z),D(),v(),()=>{cancelAnimationFrame(x),T.current=null,J.disconnect(),Q.disconnect(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B),document.documentElement.removeEventListener("pointerleave",Y),document.removeEventListener("visibilitychange",Z),l.removeEventListener("webglcontextlost",K),l.removeEventListener("webglcontextrestored",W),o.isContextLost()||(o.deleteVertexArray(U),o.deleteProgram(I.program))}},[V]),oe.jsx("div",{ref:_,className:`pointer-events-none relative h-full w-full overflow-hidden ${we}`.trim(),style:xe,children:oe.jsx("canvas",{ref:G,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{Te as default};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import{r as D,j as Be}from"./index-BiLDfPwS.js";const ft=`#version 300 es
|
|
2
|
+
in vec2 aCorner;
|
|
3
|
+
in vec4 aShape;
|
|
4
|
+
in vec4 aTop;
|
|
5
|
+
in vec4 aBottom;
|
|
6
|
+
uniform vec2 uView;
|
|
7
|
+
uniform float uAngle;
|
|
8
|
+
out vec2 vLocal;
|
|
9
|
+
out vec4 vShape;
|
|
10
|
+
out vec4 vTop;
|
|
11
|
+
out vec4 vBottom;
|
|
12
|
+
void main() {
|
|
13
|
+
float halo = aShape.z + 5.0;
|
|
14
|
+
float reachX = aShape.z + max(aTop.w * 2.5, halo * 2.0);
|
|
15
|
+
float reachY = aShape.w + max(aTop.w * 2.5, halo * 2.0);
|
|
16
|
+
vec2 local = aCorner * vec2(reachX, reachY);
|
|
17
|
+
vLocal = local;
|
|
18
|
+
vShape = aShape;
|
|
19
|
+
vTop = aTop;
|
|
20
|
+
vBottom = aBottom;
|
|
21
|
+
float c = cos(uAngle);
|
|
22
|
+
float s = sin(uAngle);
|
|
23
|
+
vec2 p = aShape.xy + local - uView * 0.5;
|
|
24
|
+
p = vec2(c * p.x - s * p.y, s * p.x + c * p.y) + uView * 0.5;
|
|
25
|
+
gl_Position = vec4(p.x / uView.x * 2.0 - 1.0, 1.0 - p.y / uView.y * 2.0, 0.0, 1.0);
|
|
26
|
+
}`,ht=`#version 300 es
|
|
27
|
+
precision highp float;
|
|
28
|
+
in vec2 vLocal;
|
|
29
|
+
in vec4 vShape;
|
|
30
|
+
in vec4 vTop;
|
|
31
|
+
in vec4 vBottom;
|
|
32
|
+
uniform float uGlow;
|
|
33
|
+
uniform float uSlices;
|
|
34
|
+
uniform float uBase;
|
|
35
|
+
uniform float uHalfBar;
|
|
36
|
+
uniform float uScale;
|
|
37
|
+
out vec4 outColor;
|
|
38
|
+
|
|
39
|
+
float erfApprox(float x) {
|
|
40
|
+
float a = x * x;
|
|
41
|
+
float t = 1.0 - exp(-a * (1.2732395 + 0.147 * a) / (1.0 + 0.147 * a));
|
|
42
|
+
return sign(x) * sqrt(max(t, 0.0));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
float box(float d, float h, float s) {
|
|
46
|
+
float k = 0.70710678 / max(s, 0.3);
|
|
47
|
+
return 0.5 * (erfApprox((h - d) * k) + erfApprox((h + d) * k));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void main() {
|
|
51
|
+
float blur = vTop.w;
|
|
52
|
+
float body = box(vLocal.x, vShape.z, blur) * box(vLocal.y, vShape.w, blur * 1.15);
|
|
53
|
+
float halo = vShape.z + 5.0;
|
|
54
|
+
float glow = box(vLocal.x, vShape.z, halo) * box(vLocal.y, vShape.w, halo);
|
|
55
|
+
float t = clamp(vLocal.y / max(vShape.w, 0.001) * 0.5 + 0.5, 0.0, 1.0);
|
|
56
|
+
vec3 color = mix(vTop.rgb, vBottom.rgb, t);
|
|
57
|
+
float v = clamp(vLocal.y / max(vShape.w, 0.001), -1.0, 1.0);
|
|
58
|
+
float core = exp(-pow(vLocal.x / max(vShape.z + blur * 0.5, 0.5), 2.0) * 1.5);
|
|
59
|
+
body *= (1.0 + 0.35 * core) * (1.0 - 0.35 * v * v * v * v);
|
|
60
|
+
if (uSlices > 0.0) {
|
|
61
|
+
float cell = vShape.z / max(uHalfBar, 0.00001) / uSlices;
|
|
62
|
+
float y = (uBase - vShape.y - vLocal.y) / max(cell, 0.001);
|
|
63
|
+
float f = 1.0 - abs(fract(y) - 0.5) * 2.0;
|
|
64
|
+
float soft = clamp(blur / max(cell, 0.001) * 1.6, 0.04, 1.0);
|
|
65
|
+
body *= smoothstep(0.28 - soft, 0.28 + soft, f);
|
|
66
|
+
}
|
|
67
|
+
vec3 tint = color * color / max(max(color.r, max(color.g, color.b)), 0.05);
|
|
68
|
+
outColor = vec4((color * body + tint * uGlow * glow * 0.16) * vBottom.w * uScale, 1.0);
|
|
69
|
+
}`,mt=`#version 300 es
|
|
70
|
+
in vec2 aCorner;
|
|
71
|
+
void main() {
|
|
72
|
+
gl_Position = vec4(aCorner, 0.0, 1.0);
|
|
73
|
+
}`,dt=`#version 300 es
|
|
74
|
+
precision highp float;
|
|
75
|
+
uniform sampler2D uLight;
|
|
76
|
+
uniform vec2 uResolution;
|
|
77
|
+
uniform float uScale;
|
|
78
|
+
uniform float uExposure;
|
|
79
|
+
uniform float uGrain;
|
|
80
|
+
uniform float uTime;
|
|
81
|
+
uniform float uFade;
|
|
82
|
+
uniform float uOpacity;
|
|
83
|
+
uniform float uLightMode;
|
|
84
|
+
out vec4 outColor;
|
|
85
|
+
|
|
86
|
+
float hash(vec2 p) {
|
|
87
|
+
p = fract(p * vec2(123.34, 456.21));
|
|
88
|
+
p += dot(p, p + 45.32);
|
|
89
|
+
return fract(p.x * p.y);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
float smootherstep(float edge, float x) {
|
|
93
|
+
float t = clamp(x / max(edge, 0.0001), 0.0, 1.0);
|
|
94
|
+
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void main() {
|
|
98
|
+
vec3 hdr = texelFetch(uLight, ivec2(gl_FragCoord.xy), 0).rgb / uScale * uExposure;
|
|
99
|
+
vec2 uv = gl_FragCoord.xy / uResolution;
|
|
100
|
+
float edge = uFade * 0.5;
|
|
101
|
+
float mask = smootherstep(edge, uv.x) * smootherstep(edge, 1.0 - uv.x) * smootherstep(edge, uv.y) * smootherstep(edge, 1.0 - uv.y);
|
|
102
|
+
mask *= uOpacity;
|
|
103
|
+
float grain = (hash(gl_FragCoord.xy + fract(uTime * 7.31) * 113.0) - 0.5) * uGrain;
|
|
104
|
+
float peak = max(hdr.r, max(hdr.g, hdr.b));
|
|
105
|
+
if (uLightMode > 0.5) {
|
|
106
|
+
vec3 hue = hdr / max(peak, 0.0001);
|
|
107
|
+
float tone = dot(hue, vec3(0.2126, 0.7152, 0.0722));
|
|
108
|
+
vec3 color = pow(clamp(hue * min(1.0, 0.66 / max(tone, 0.001)), 0.0, 1.0), vec3(1.0 / 2.2));
|
|
109
|
+
float alpha = clamp((1.0 - exp(-peak * 1.1)) * 0.85 * (1.0 + grain), 0.0, 1.0) * mask;
|
|
110
|
+
outColor = vec4(color * alpha, alpha);
|
|
111
|
+
} else {
|
|
112
|
+
vec3 mapped = 1.0 - exp(-hdr);
|
|
113
|
+
mapped = mix(mapped, vec3(1.0), smoothstep(1.1, 3.2, peak) * 0.75);
|
|
114
|
+
float level = max(mapped.r, max(mapped.g, mapped.b));
|
|
115
|
+
mapped = clamp(mapped + grain * (0.25 + level), 0.0, 1.0) * mask;
|
|
116
|
+
outColor = vec4(mapped, max(mapped.r, max(mapped.g, mapped.b)));
|
|
117
|
+
}
|
|
118
|
+
}`,le=Math.PI*2,pt=6,vt=1.1,C=2.6,xt=1.5,_e=2560,R=(n,f,d)=>Math.min(d,Math.max(f,n)),Le=n=>{const f=Math.sin(n*127.1+311.7)*43758.5453;return f-Math.floor(f)},bt=n=>{const f=Math.floor(n),d=n-f,h=d*d*(3-2*d);return Le(f)*(1-h)+Le(f+1)*h},Pe=(n,f,d)=>{const h=n.createShader(f);return h?(n.shaderSource(h,d),n.compileShader(h),n.getShaderParameter(h,n.COMPILE_STATUS)?h:(n.deleteShader(h),null)):null},Ue=(n,f,d,h)=>{const M=Pe(n,n.VERTEX_SHADER,f),V=Pe(n,n.FRAGMENT_SHADER,d),g=n.createProgram();return!M||!V||!g?null:(n.attachShader(g,M),n.attachShader(g,V),h.forEach((K,Q)=>n.bindAttribLocation(g,Q,K)),n.linkProgram(g),n.deleteShader(M),n.deleteShader(V),n.getProgramParameter(g,n.LINK_STATUS)?g:(n.deleteProgram(g),null))},De=(n,f,d)=>{const h={};for(const M of d)h[M]=n.getUniformLocation(f,M);return h},Rt=({color1:n="#ffd9a8",color2:f="#ff5fa2",color3:d="#5b8cff",ribbons:h=3,spacing:M=28,barWidth:V=.5,ribbonHeight:g=.26,spread:K=.1,amplitude:Q=.1,frequency:Ce=1,speed:Ve=1,perspective:Ie=.45,curve:Xe=.5,blur:Oe=.6,glow:Ne=1,brightness:Ge=1.25,position:ke=.78,rotation:Ye=0,slices:He=0,grain:We=.08,mouseInteraction:ze=!0,intro:qe=!0,fade:je=0,opacity:Ze=1,lightMode:$e=!1,paused:Ke=!1,dpr:Qe,className:Je="",...et})=>{const ue=D.useRef(null),fe=D.useRef(null),J=D.useRef(null),he={color1:String(n),color2:String(f),color3:String(d),ribbons:Math.round(R(h,1,pt)),spacing:R(M,4,200),barWidth:R(V,.05,1),ribbonHeight:Math.max(0,g),spread:Math.max(0,K),amplitude:Math.max(0,Q),frequency:Math.max(0,Ce),speed:Ve,perspective:R(Ie,0,1),curve:R(Xe,0,1),blur:R(Oe,0,2),glow:Math.max(0,Ne),brightness:Math.max(0,Ge),position:R(ke,0,1),rotation:Ye,slices:Math.max(0,Math.round(He)),grain:Math.max(0,We),mouseInteraction:ze,intro:qe,fade:R(je,0,1),opacity:R(Ze,0,1),lightMode:$e,paused:Ke,dpr:Qe},I=D.useRef(he);return I.current=he,D.useEffect(()=>{const S=ue.current,s=fe.current,e=s?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1});if(!S||!s||!e)return;const me=!!e.getExtension("EXT_color_buffer_float"),de=me?1:.25,H=Ue(e,ft,ht,["aCorner","aShape","aTop","aBottom"]),W=Ue(e,mt,dt,["aCorner"]);if(!H||!W)return;const y=De(e,H,["uView","uAngle","uGlow","uSlices","uBase","uHalfBar","uScale"]),A=De(e,W,["uLight","uResolution","uScale","uExposure","uGrain","uTime","uFade","uOpacity","uLightMode"]),ee=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,ee),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),e.STATIC_DRAW);const te=e.createBuffer(),oe=e.createVertexArray();e.bindVertexArray(oe),e.bindBuffer(e.ARRAY_BUFFER,ee),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,te);for(let t=1;t<=3;t++)e.enableVertexAttribArray(t),e.vertexAttribPointer(t,4,e.FLOAT,!1,48,(t-1)*16),e.vertexAttribDivisor(t,1);const pe=e.createBuffer(),ae=e.createVertexArray();e.bindVertexArray(ae),e.bindBuffer(e.ARRAY_BUFFER,pe),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const X=e.createTexture();e.bindTexture(e.TEXTURE_2D,X),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const re=e.createFramebuffer(),F=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),z=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,ve=new Map;let E=new Float32Array(0);const x={x:0,y:0,inside:!1},o={width:1,height:1,targetWidth:0,targetHeight:0,time:0,intro:I.current.intro&&!z?0:1,focus:C,focusVelocity:0,lift:0,liftX:0};let B=0,_=0,q=!0,ne=!0;const tt=t=>{const a=ve.get(t);if(a)return a;let r=[1,1,1];if(F&&t){F.clearRect(0,0,1,1),F.fillStyle="#000000",F.fillStyle=/^[0-9a-f]{3,8}$/i.test(t)?`#${t}`:t,F.fillRect(0,0,1,1);const[i,c,l]=F.getImageData(0,0,1,1).data;r=[i,c,l].map(u=>Math.pow(u/255,2.2))}return ve.set(t,r),r},xe=(t,a,r)=>{const i=t.length,c=(a%i+i)%i,l=Math.floor(c);let u=c-l;u=u*u*(3-2*u);const b=t[l],p=t[(l+1)%i];for(let v=0;v<3;v++)E[r+v]=b[v]+(p[v]-b[v])*u},ot=()=>{o.targetWidth===s.width&&o.targetHeight===s.height||(o.targetWidth=s.width,o.targetHeight=s.height,e.bindTexture(e.TEXTURE_2D,X),me?e.texImage2D(e.TEXTURE_2D,0,e.RGBA16F,s.width,s.height,0,e.RGBA,e.HALF_FLOAT,null):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,s.width,s.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindFramebuffer(e.FRAMEBUFFER,re),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,X,0),e.bindFramebuffer(e.FRAMEBUFFER,null))},be=t=>{const{width:a,height:r}=o,i=r*vt,c=i/C,l=t.spacing/c,u=l*t.barWidth*.5,b=t.perspective*.66,p=Math.cos(b),v=Math.sin(b),ce=t.curve*.6,j=t.rotation*Math.PI/180,O=Math.abs(Math.cos(j))*a*.5+Math.abs(Math.sin(j))*r*.5,N=Math.ceil(Math.max(a,r)/i*C*2.4/l),Z=[];for(let P=-N;P<=N;P++){const U=P*l,G=ce*Math.sin(U*.9+.8),k=U*p-G*v,m=U*v+G*p+C;if(m<.45)continue;const Y=i/m,$=a*.5+k*Y;Math.abs($-a*.5)>O+u*Y+80||Z.push({i:P,x:U,Z:m,sx:$,scale:Y})}return{bars:Z,halfBar:u,centerScale:c}},at=(t,a)=>{const{width:r,height:i}=o,{bars:c,halfBar:l,centerScale:u}=a,b=[t.color1,t.color2,t.color3].map(tt),p=o.time,v=t.ribbonHeight*i*.5/u,ce=t.spread*i/u,j=t.amplitude*i/u,O=.22*t.frequency,N=i*t.position,Z=o.focus,P=t.blur*16,U=1.6+.04*(t.ribbons-1),G=c.length*t.ribbons*12;G>E.length&&(E=new Float32Array(G+1200));let k=0;for(const m of c){const Y=l*m.scale,$=m.sx/Math.max(r,1),nt=o.lift*Math.exp(-Math.pow((m.sx-o.liftX)/Math.max(r*.12,60),2)),it=(.5+t.blur*.6+P*Math.abs(Z/m.Z-1))*(t.lightMode?.55:1);for(let T=0;T<t.ribbons;T++){const ct=(T-(t.ribbons-1)/2)*ce,st=.62*Math.sin(le*O*m.x-p*1.6+T*2.1)+.38*Math.sin(le*O*1.9*m.x+p*2.25+T*1.3),lt=ct+st*j,ut=.5+.5*Math.sin(le*O*.7*m.x+p*1.1+T*2.7),se=R((o.intro*U-$-T*.04)/.6,0,1),ye=se*se*(3-2*se),Se=v*(.6+.4*ut)*ye*m.scale;if(Se<.4)continue;const Fe=T*1.15+m.x*.3+p*.12,w=k*12;E[w]=m.sx,E[w+1]=N-lt*m.scale,E[w+2]=Y,E[w+3]=Se,xe(b,Fe-.22,w+4),E[w+7]=it,xe(b,Fe+.22,w+8),E[w+11]=(.75+.25*bt(m.i*.9+T*7.7-p*1.2))*(1+nt*.6)*(.4+.6*ye),k++}}return{count:k,halfBar:l,base:N}},ie=(t,a=be(t))=>{ot();const{count:r,halfBar:i,base:c}=at(t,a);e.bindFramebuffer(e.FRAMEBUFFER,re),e.viewport(0,0,s.width,s.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),r>0&&(e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),e.useProgram(H),e.uniform2f(y.uView,o.width,o.height),e.uniform1f(y.uAngle,t.rotation*Math.PI/180),e.uniform1f(y.uGlow,t.lightMode?t.glow*.4:t.glow),e.uniform1f(y.uSlices,t.slices),e.uniform1f(y.uBase,c),e.uniform1f(y.uHalfBar,i),e.uniform1f(y.uScale,de),e.bindVertexArray(oe),e.bindBuffer(e.ARRAY_BUFFER,te),e.bufferData(e.ARRAY_BUFFER,E.subarray(0,r*12),e.DYNAMIC_DRAW),e.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,r),e.disable(e.BLEND)),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s.width,s.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(W),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,X),e.uniform1i(A.uLight,0),e.uniform2f(A.uResolution,s.width,s.height),e.uniform1f(A.uScale,de),e.uniform1f(A.uExposure,1.6*t.brightness),e.uniform1f(A.uGrain,t.grain),e.uniform1f(A.uTime,o.time%1e3),e.uniform1f(A.uFade,t.fade),e.uniform1f(A.uOpacity,t.opacity),e.uniform1f(A.uLightMode,t.lightMode?1:0),e.bindVertexArray(ae),e.drawArrays(e.TRIANGLES,0,3),e.bindVertexArray(null)},rt=(t,a)=>{let r=null;for(const i of t.bars)(!r||Math.abs(i.sx-a)<Math.abs(r.sx-a))&&(r=i);return r?r.Z:C},ge=t=>{if(B=0,!ne||!q||document.hidden)return;const a=I.current,r=_?Math.min(.05,(t-_)/1e3):1/60;_=t;const i=!a.paused&&!z;i&&(o.time+=r*a.speed),!a.intro||z?o.intro=1:o.intro<1&&(o.intro=Math.min(1,o.intro+r/xt));const c=a.mouseInteraction&&x.inside&&!z,l=a.rotation*Math.PI/180,u=Math.cos(l)*(x.x-o.width*.5)+Math.sin(l)*(x.y-o.height*.5)+o.width*.5,b=be(a),p=c?rt(b,u):C;o.focusVelocity+=(36*(p-o.focus)-11*o.focusVelocity)*r,o.focus+=o.focusVelocity*r,o.lift+=((c?1:0)-o.lift)*(1-Math.exp(-r/(c?.25:.6))),o.liftX+=(u-o.liftX)*(1-Math.exp(-r/.12)),ie(a,b);const v=o.intro<1||Math.abs(p-o.focus)>.001||Math.abs(o.focusVelocity)>.001||o.lift>.002||c;i||v?B=requestAnimationFrame(ge):_=0},L=()=>{!B&&ne&&q&&!document.hidden&&(B=requestAnimationFrame(ge))},Ee=()=>{const t=I.current,a=Math.max(1,S.clientWidth),r=Math.max(1,S.clientHeight),i=Math.min(t.dpr||window.devicePixelRatio||1,2),c=Math.max(a,r)*i,l=c>_e?i*_e/c:i;o.width=a,o.height=r,s.width=Math.max(1,Math.round(a*l)),s.height=Math.max(1,Math.round(r*l)),ie(t),L()},Re=t=>{const a=S.getBoundingClientRect();x.x=t.clientX-a.left,x.y=t.clientY-a.top,x.inside=x.x>=0&&x.y>=0&&x.x<=a.width&&x.y<=a.height,L()},Ae=()=>{x.inside=!1,L()},Te=()=>{_=0,L()},Me=new ResizeObserver(Ee);Me.observe(S);const we=new IntersectionObserver(t=>{q=t.some(a=>a.isIntersecting),q&&(_=0,L())});return we.observe(S),window.addEventListener("pointermove",Re,{passive:!0}),document.documentElement.addEventListener("pointerleave",Ae),document.addEventListener("visibilitychange",Te),Ee(),J.current=()=>{B||ie(I.current),L()},()=>{ne=!1,cancelAnimationFrame(B),J.current=null,Me.disconnect(),we.disconnect(),window.removeEventListener("pointermove",Re),document.documentElement.removeEventListener("pointerleave",Ae),document.removeEventListener("visibilitychange",Te),e.deleteFramebuffer(re),e.deleteTexture(X),e.deleteBuffer(ee),e.deleteBuffer(te),e.deleteBuffer(pe),e.deleteVertexArray(oe),e.deleteVertexArray(ae),e.deleteProgram(H),e.deleteProgram(W)}},[]),D.useEffect(()=>{J.current?.()}),Be.jsx("div",{ref:ue,className:["relative h-full w-full overflow-hidden",Je].filter(Boolean).join(" "),...et,children:Be.jsx("canvas",{ref:fe,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{Rt as default};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{r,j as i}from"./index-BiLDfPwS.js";const Lt=["LAUNCH READY","SYNC ONLINE","SIGNAL LIVE"],P={alpha:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",alphanumeric:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",numeric:"0123456789"},Ct=`
|
|
2
|
+
.split-flap-text{gap:var(--split-flap-gap,6px);font-family:'SFMono-Regular','Roboto Mono','Cascadia Code','Liberation Mono',Menlo,monospace;font-size:var(--split-flap-font-size,52px);font-weight:760;line-height:1;letter-spacing:.035em;font-variant-numeric:tabular-nums}
|
|
3
|
+
.split-flap-text__tile{position:relative;flex:none;width:.78em;height:1.08em;overflow:hidden;border-radius:var(--split-flap-radius,8px);background:radial-gradient(circle at 50% 0%,rgba(255,255,255,.16),transparent 44%),linear-gradient(180deg,color-mix(in srgb,var(--split-flap-tile-color,#111827) 82%,white),var(--split-flap-tile-color,#111827));box-shadow:0 .035em .08em rgba(255,255,255,.08) inset,0 -.05em .1em rgba(0,0,0,.38) inset,0 calc(.16em * var(--split-flap-lift,1)) calc(.38em * var(--split-flap-lift,1)) rgba(0,0,0,var(--split-flap-drop,.28));perspective:10em;transform-style:preserve-3d;isolation:isolate}
|
|
4
|
+
.split-flap-text__tile::before{content:'';position:absolute;z-index:8;top:calc(50% - var(--split-flap-hinge,1px) / 2);left:0;width:100%;height:var(--split-flap-hinge,1px);background:linear-gradient(90deg,transparent,rgba(255,255,255,.18) 18%,rgba(0,0,0,var(--split-flap-hinge-shade,.64)) 50%,rgba(255,255,255,.14) 82%,transparent);box-shadow:0 -1px 0 rgba(255,255,255,.08),0 1px 0 rgba(0,0,0,.5);pointer-events:none}
|
|
5
|
+
.split-flap-text__tile::after{content:'';position:absolute;inset:0;z-index:9;border:1px solid rgba(255,255,255,.08);border-radius:inherit;box-shadow:0 0 0 1px rgba(0,0,0,.2) inset;pointer-events:none}
|
|
6
|
+
.split-flap-text__half,.split-flap-text__flap{position:absolute;left:0;width:100%;height:50%;overflow:hidden;background:linear-gradient(180deg,rgba(255,255,255,.07),transparent 34%),var(--split-flap-tile-color,#111827);backface-visibility:hidden}
|
|
7
|
+
.split-flap-text__half--top,.split-flap-text__flap--front{top:0}
|
|
8
|
+
.split-flap-text__half--bottom,.split-flap-text__flap--back{bottom:0}
|
|
9
|
+
.split-flap-text__half--bottom,.split-flap-text__flap--back{background:linear-gradient(0deg,rgba(255,255,255,.06),transparent 38%),color-mix(in srgb,var(--split-flap-tile-color,#111827) 92%,black)}
|
|
10
|
+
.split-flap-text__char{position:absolute;left:0;width:100%;height:200%;display:flex;align-items:center;justify-content:center;color:var(--split-flap-text-color,#f8fafc);text-shadow:0 .025em 0 rgba(255,255,255,.16),0 .09em .16em rgba(0,0,0,.42)}
|
|
11
|
+
.split-flap-text__half--top .split-flap-text__char,.split-flap-text__flap--front .split-flap-text__char{top:0}
|
|
12
|
+
.split-flap-text__half--bottom .split-flap-text__char,.split-flap-text__flap--back .split-flap-text__char{bottom:0}
|
|
13
|
+
.split-flap-text__flap{z-index:6;will-change:transform,filter;transform-style:preserve-3d}
|
|
14
|
+
.split-flap-text__flap--front{transform-origin:center bottom;box-shadow:inset 0 var(--split-flap-edge,0em) 0 rgba(255,255,255,.16);animation:split-flap-front var(--split-flap-flip-duration,.12s) linear both}
|
|
15
|
+
.split-flap-text__flap--back{transform-origin:center top;transform:rotateX(90deg);box-shadow:inset 0 calc(var(--split-flap-edge,0em) * -1) 0 rgba(0,0,0,.4);animation:split-flap-back var(--split-flap-flip-duration,.12s) linear both}
|
|
16
|
+
.split-flap-text__shade{position:absolute;z-index:4;left:0;width:100%;height:50%;pointer-events:none;animation:split-flap-shade-top var(--split-flap-flip-duration,.12s) linear both}
|
|
17
|
+
.split-flap-text__shade--top{top:0;background:linear-gradient(0deg,rgba(0,0,0,var(--split-flap-cast,0)),transparent 85%)}
|
|
18
|
+
.split-flap-text__shade--bottom{bottom:0;background:linear-gradient(180deg,rgba(0,0,0,var(--split-flap-cast,0)),transparent 90%);animation-name:split-flap-shade-bottom}
|
|
19
|
+
.split-flap-text--glare .split-flap-text__flap::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,transparent 32%,rgba(255,255,255,var(--split-flap-glare,0)) 50%,transparent 68%) 0 100% / 100% 300% no-repeat;animation:split-flap-glare-front var(--split-flap-flip-duration,.12s) linear both}
|
|
20
|
+
.split-flap-text--glare .split-flap-text__flap--back::after{animation-name:split-flap-glare-back}
|
|
21
|
+
.split-flap-text--minimal .split-flap-text__tile{background:none;box-shadow:none;-webkit-mask:linear-gradient(#000 0 0) top / 100% calc(50% - var(--split-flap-split,.045em) / 2) no-repeat,linear-gradient(#000 0 0) bottom / 100% calc(50% - var(--split-flap-split,.045em) / 2) no-repeat;mask:linear-gradient(#000 0 0) top / 100% calc(50% - var(--split-flap-split,.045em) / 2) no-repeat,linear-gradient(#000 0 0) bottom / 100% calc(50% - var(--split-flap-split,.045em) / 2) no-repeat}
|
|
22
|
+
.split-flap-text--minimal .split-flap-text__tile::before,.split-flap-text--minimal .split-flap-text__tile::after,.split-flap-text--minimal .split-flap-text__flap::after{display:none}
|
|
23
|
+
.split-flap-text--minimal .split-flap-text__half,.split-flap-text--minimal .split-flap-text__flap{background:none;box-shadow:none}
|
|
24
|
+
.split-flap-text--minimal .split-flap-text__char{text-shadow:none}
|
|
25
|
+
.split-flap-text--minimal .split-flap-text__tile.is-flipping .split-flap-text__half--top{animation:split-flap-reveal var(--split-flap-flip-duration,.12s) linear both}
|
|
26
|
+
.split-flap-text--minimal .split-flap-text__tile.is-flipping .split-flap-text__half--bottom{animation:split-flap-cover var(--split-flap-flip-duration,.12s) linear both}
|
|
27
|
+
@keyframes split-flap-front{0%{transform:rotateX(0deg);filter:brightness(var(--split-flap-front-from,1.08));animation-timing-function:cubic-bezier(.55,.055,.675,.19)}50%,100%{transform:rotateX(-90deg);filter:brightness(var(--split-flap-front-to,.52))}}
|
|
28
|
+
@keyframes split-flap-back{0%,50%{transform:rotateX(90deg);filter:brightness(var(--split-flap-back-from,.58));animation-timing-function:cubic-bezier(.215,.61,.355,1)}100%{transform:rotateX(0deg);filter:brightness(1)}}
|
|
29
|
+
@keyframes split-flap-shade-top{0%,32%{opacity:1}50%,100%{opacity:0}}
|
|
30
|
+
@keyframes split-flap-shade-bottom{0%{opacity:0;animation-timing-function:cubic-bezier(.55,.055,.675,.19)}50%,100%{opacity:1}}
|
|
31
|
+
@keyframes split-flap-glare-front{0%{background-position:0 100%;opacity:0}30%{opacity:1}50%,100%{background-position:0 0%;opacity:.75}}
|
|
32
|
+
@keyframes split-flap-glare-back{0%,50%{background-position:0 100%;opacity:.75}100%{background-position:0 0%;opacity:0}}
|
|
33
|
+
@keyframes split-flap-reveal{0%{clip-path:inset(0 0 100% 0)}23.14%{clip-path:inset(0 0 99.21% 0)}29.67%{clip-path:inset(0 0 95.55% 0)}33.95%{clip-path:inset(0 0 89.09% 0)}37.41%{clip-path:inset(0 0 79.46% 0)}40.56%{clip-path:inset(0 0 66.05% 0)}43.73%{clip-path:inset(0 0 47.69% 0)}47.38%{clip-path:inset(0 0 21.22% 0)}50%,100%{clip-path:inset(0 0 0 0)}}
|
|
34
|
+
@keyframes split-flap-cover{0%,50%{clip-path:inset(0 0 0 0)}54.42%{clip-path:inset(35.75% 0 0 0)}57.44%{clip-path:inset(55.86% 0 0 0)}60.39%{clip-path:inset(70.63% 0 0 0)}63.65%{clip-path:inset(81.86% 0 0 0)}67.65%{clip-path:inset(90.23% 0 0 0)}73.17%{clip-path:inset(96% 0 0 0)}82.62%{clip-path:inset(99.25% 0 0 0)}100%{clip-path:inset(100% 0 0 0)}}
|
|
35
|
+
@media (prefers-reduced-motion: reduce){.split-flap-text__flap,.split-flap-text__flap::after,.split-flap-text__shade,.split-flap-text__half{animation:none !important}}
|
|
36
|
+
`,Y=t=>typeof t=="number"?`${t}px`:t,Ft=t=>t&&P[t]?P[t]:typeof t=="string"&&t.length>0?t:P.alphanumeric,st=(t,e,n="left")=>{const a=String(t??"").slice(0,e);return n==="right"?a.padStart(e," "):n==="center"?a.padStart(a.length+Math.floor((e-a.length)/2)," ").padEnd(e," "):a.padEnd(e," ")},C=t=>t.split("").map(e=>({current:e,next:e,flipping:!1,tick:0})),zt=t=>t.charAt(Math.floor(Math.random()*t.length))||" ",It=(t,e,n)=>{const a=[];for(let M=0;M<e;M+=1)a.push(zt(n));return a.push(t),a},F=t=>t===" "?" ":t,Tt=t=>{const e=Array.from({length:t},(n,a)=>a);for(let n=t-1;n>0;n-=1){const a=Math.floor(Math.random()*(n+1));[e[n],e[a]]=[e[a],e[n]]}return e},qt=(t,e,n,a)=>n==="right"?e-1-t:n==="center"?Math.floor(Math.abs(t-(e-1)/2)):n==="random"&&a?a[t]:t,rt=t=>Math.min(1,Math.max(0,Number(t)||0)),m=t=>Number(t.toFixed(3)),Ut=()=>typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,Xt=()=>{const[t,e]=r.useState(Ut);return r.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia("(prefers-reduced-motion: reduce)"),a=()=>e(n.matches);return a(),n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[]),t},Yt=({words:t=["LAUNCH READY","SYNC ONLINE","SIGNAL LIVE"],text:e,flipDuration:n=.12,stagger:a=.06,cycleDelay:M=2400,charset:D="alphanumeric",flipsPerChar:G=8,tileColor:pt="#111827",textColor:ot="#f8fafc",tileRadius:ft=8,gap:ct=6,fontSize:mt=52,loop:H=!0,padTo:O=12,align:B="left",intro:z=!0,glare:ht=0,depth:ut=.5,order:V="left",tileStyle:dt="board",className:xt="",style:gt={},..._t})=>{const W=Xt(),g=r.useRef(null),d=r.useRef(null),_=r.useRef(null),x=r.useRef(0),K=r.useRef(null),bt=Array.isArray(t)&&t.length>0?t:Lt,Q=typeof e=="string"?e:bt.map(l=>String(l??"")).join(""),b=r.useMemo(()=>Q.split(""),[Q]),y=r.useMemo(()=>{const l=b.reduce((u,R)=>Math.max(u,R.length),1);return Math.max(1,Math.ceil(Number(O)||0),l)},[O,b]),c=r.useMemo(()=>b.map(l=>st(l,y,B)),[b,y,B]),I=r.useMemo(()=>({flipMs:Math.max(40,(Number(n)||.12)*1e3),staggerMs:Math.max(0,(Number(a)||0)*1e3),holdMs:Math.max(400,Number(M)||2400),flips:Math.max(0,Math.floor(Number(G)||0)),glyphs:Ft(D),order:V}),[n,a,M,G,D,V]),N=r.useRef(I),[J,E]=r.useState(()=>C(z?" ".repeat(y):c[0])),[vt,Z]=r.useState(0);r.useEffect(()=>{N.current=I},[I]),r.useEffect(()=>{let l=!1,u;const R=()=>{g.current&&cancelAnimationFrame(g.current),g.current=null},wt=s=>{const{flipMs:j,staggerMs:U,flips:jt,glyphs:Et,order:lt}=N.current,S=st(d.current??s,s.length),St=lt==="random"?Tt(s.length):null;R(),d.current=s,_.current=null;const A=[];if(!W)for(let o=0;o<s.length;o+=1)S[o]!==s[o]&&A.push({index:o,from:S[o],target:s[o],sequence:It(s[o],jt,Et),start:qt(o,s.length,lt,St)*U,step:-1,done:!1});if(!A.length)return E(C(s)),0;_.current=S,E(C(S));const At=A.reduce((o,$)=>Math.max(o,$.start+$.sequence.length*j),0),$t=performance.now(),nt=o=>{if(l)return;const $=o-$t,L=[];let X=!1;A.forEach(p=>{const k=$-p.start;if(k<0){X=!0;return}const f=Math.floor(k/j);f<p.sequence.length?(X=!0,f!==p.step&&(p.step=f,L.push({index:p.index,current:f===0?p.from:p.sequence[f-1],next:p.sequence[f],done:!1}))):p.done||(p.done=!0,L.push({index:p.index,current:p.target,next:p.target,done:!0}))}),L.length>0&&E(p=>{const k=[...p];return L.forEach(f=>{const it=k[f.index];it&&(k[f.index]={current:f.current,next:f.next,flipping:!f.done,tick:it.tick+1})}),k}),X?g.current=requestAnimationFrame(nt):(g.current=null,_.current=null)};return g.current=requestAnimationFrame(nt),At},et=s=>(x.current=s,Z(s),wt(c[s])),q=s=>{u=setTimeout(()=>{if(l)return;if(document.hidden){q(N.current.holdMs);return}const j=x.current+1;if(j>=c.length&&!H)return;const U=et(j%c.length);q(N.current.holdMs+U)},s)},Rt=K.current===c;K.current=c,d.current===null&&(d.current=z?" ".repeat(y):c[0]),!Rt||x.current>=c.length?x.current=0:_.current!==null&&(d.current=_.current);let at=0;return d.current===c[x.current]?(R(),_.current=null,Z(x.current),E(C(d.current))):at=et(x.current),c.length>1&&q(N.current.holdMs+at),()=>{l=!0,clearTimeout(u),R()}},[c,y,H,z,W]);const kt=String(b[vt]??b[0]??"").trim(),w=dt==="minimal",T=rt(ut),v=Math.min(1,T*2),h=Math.max(0,T-.5)*2,tt=w?0:rt(ht),Mt=!w&&h>0,yt=["split-flap-text",w&&"split-flap-text--minimal",tt>0&&"split-flap-text--glare","relative inline-flex items-center whitespace-pre select-none",xt].filter(Boolean).join(" "),Nt={"--split-flap-tile-color":pt,"--split-flap-text-color":ot,"--split-flap-radius":Y(ft),"--split-flap-gap":Y(ct),"--split-flap-font-size":Y(mt),"--split-flap-flip-duration":`${Math.max(.04,Number(n)||.12)}s`,"--split-flap-front-from":m(1+.08*v),"--split-flap-front-to":m(1-.48*v-.3*h),"--split-flap-back-from":m(1-.42*v-.3*h),"--split-flap-hinge":`calc(1px + ${m(h*.05)}em)`,"--split-flap-hinge-shade":m(.25+.39*v+.21*h),"--split-flap-drop":m(.28*v+.2*h),"--split-flap-lift":m(.4+.6*v+.7*h),"--split-flap-cast":m(h*.62),"--split-flap-edge":`${m(h*.035)}em`,"--split-flap-split":`${m(.015+T*.06)}em`,"--split-flap-glare":m(tt*.55),...gt};return i.jsxs(i.Fragment,{children:[i.jsx("style",{children:Ct}),i.jsxs("div",{className:yt,style:Nt,..._t,children:[i.jsx("span",{className:"sr-only",children:kt}),J.map((l,u)=>i.jsxs("span",{className:`split-flap-text__tile${l.flipping?" is-flipping":""}`,"aria-hidden":"true",children:[i.jsx("span",{className:"split-flap-text__half split-flap-text__half--top",children:i.jsx("span",{className:"split-flap-text__char",children:F(l.flipping?l.next:l.current)})},w?`top-${l.tick}`:"top"),i.jsx("span",{className:"split-flap-text__half split-flap-text__half--bottom",children:i.jsx("span",{className:"split-flap-text__char",children:F(l.current)})},w?`bottom-${l.tick}`:"bottom"),l.flipping&&i.jsxs(i.Fragment,{children:[Mt&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"split-flap-text__shade split-flap-text__shade--top"},`shade-top-${l.tick}`),i.jsx("span",{className:"split-flap-text__shade split-flap-text__shade--bottom"},`shade-bottom-${l.tick}`)]}),i.jsx("span",{className:"split-flap-text__flap split-flap-text__flap--front",children:i.jsx("span",{className:"split-flap-text__char",children:F(l.current)})},`front-${u}-${l.tick}`),i.jsx("span",{className:"split-flap-text__flap split-flap-text__flap--back",children:i.jsx("span",{className:"split-flap-text__char",children:F(l.next)})},`back-${u}-${l.tick}`)]})]},`${u}-${J.length}`))]})]})};export{Yt as default};
|