ai-wrapped 1.16.0 → 1.18.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.
Files changed (47) hide show
  1. package/LICENSE +24 -0
  2. package/dist/assets/Aurora-gPgXaQaG.js +145 -0
  3. package/dist/assets/{BotAvatar-DF0epPmz.js → BotAvatar-Bur2fckZ.js} +1 -1
  4. package/dist/assets/{CrystalizedBall-8nXHKUrK.js → CrystalizedBall-KWGPAJYI.js} +1 -1
  5. package/dist/assets/DarkVeil-BgGKjyIE.js +164 -0
  6. package/dist/assets/{EchoText-BBpfwkNe.js → EchoText-BrB32uyp.js} +1 -1
  7. package/dist/assets/FaultyTerminal-DDw4c9b4.js +391 -0
  8. package/dist/assets/Galaxy-Dgc9RDEH.js +197 -0
  9. package/dist/assets/{GlowCursor-Cyc4E_Sy.js → GlowCursor-BZCHElFf.js} +1 -1
  10. package/dist/assets/{Heatwave-BRCZhums.js → Heatwave-CJzverw9.js} +1 -1
  11. package/dist/assets/Iridescence-BvMXvo4z.js +103 -0
  12. package/dist/assets/LetterGlitch-BfoWmQyO.js +94 -0
  13. package/dist/assets/{LightTunnel-BhYVyLW0.js → LightTunnel-Dig-ybUd.js} +1 -1
  14. package/dist/assets/{LineSpiral-DXvjTFr3.js → LineSpiral-BORPdW5M.js} +1 -1
  15. package/dist/assets/Plasma-CHJExTBw.js +113 -0
  16. package/dist/assets/Prism-19JE2gzg.js +78 -0
  17. package/dist/assets/{SideRays-D3YRo98l.js → SideRays-DcOr-gOm.js} +1 -1
  18. package/dist/assets/{SlicedWaves-_jMt9oC8.js → SlicedWaves-BUD_9aqV.js} +1 -1
  19. package/dist/assets/{SplitFlapText-Cm16Tvxb.js → SplitFlapText-D5KE4_3P.js} +1 -1
  20. package/dist/assets/{Strands-Bn08Tum0.js → Strands-CtNx3Esy.js} +1 -1
  21. package/dist/assets/{TechText-CQvGbyFP.js → TechText-BtSyI_Dm.js} +1 -1
  22. package/dist/assets/Threads-H6WESD1W.js +124 -0
  23. package/dist/assets/index-BstFwFxc.js +161 -0
  24. package/dist/assets/index-yPH2MNv-.css +1 -0
  25. package/dist/index.html +2 -2
  26. package/package.json +1 -1
  27. package/skills/ai-wrapped/SKILL.md +3 -1
  28. package/src/bun/aggregator.ts +7 -9
  29. package/src/bun/discovery/claude.ts +29 -7
  30. package/src/bun/headless.ts +2 -0
  31. package/src/bun/normalizer.ts +12 -0
  32. package/src/bun/parsers/additional.ts +26 -2
  33. package/src/bun/parsers/claude.ts +57 -0
  34. package/src/bun/parsers/codex.ts +28 -17
  35. package/src/bun/parsers/promptCounts.test.ts +53 -0
  36. package/src/bun/promptWords.test.ts +17 -0
  37. package/src/bun/promptWords.ts +39 -0
  38. package/src/bun/queries.ts +4 -0
  39. package/src/bun/scan.test.ts +64 -0
  40. package/src/bun/scan.ts +101 -38
  41. package/src/bun/store.ts +49 -2
  42. package/src/shared/buildPayload.ts +1 -0
  43. package/src/shared/schema.ts +2 -0
  44. package/src/shared/session-types.ts +4 -0
  45. package/src/shared/shareData.ts +22 -2
  46. package/dist/assets/index-CH-7pBbW.js +0 -161
  47. package/dist/assets/index-Dh3d1sc7.css +0 -1
@@ -0,0 +1,197 @@
1
+ import{r as T,m as De,j as ce}from"./index-BstFwFxc.js";const fe=8,q=4,Ge=2.2,ze=`#version 300 es
2
+ in vec2 aPosition;
3
+ void main() {
4
+ gl_Position = vec4(aPosition, 0.0, 1.0);
5
+ }`,Be=`#version 300 es
6
+ precision highp float;
7
+ precision highp int;
8
+ uniform float uTime;
9
+ uniform vec2 uResolution;
10
+ uniform vec2 uFocal;
11
+ uniform vec2 uRotation;
12
+ uniform float uGloss;
13
+ uniform float uDepth;
14
+ uniform float uDensity;
15
+ uniform float uHueShift;
16
+ uniform float uSpeed;
17
+ uniform vec2 uMouse;
18
+ uniform float uStarGlow;
19
+ uniform float uFlareGain;
20
+ uniform float uSquash;
21
+ uniform float uSaturation;
22
+ uniform float uMouseRepulsion;
23
+ uniform float uTwinkleIntensity;
24
+ uniform float uRotationAngle;
25
+ uniform float uRepulsionStrength;
26
+ uniform float uMouseActiveFactor;
27
+ uniform float uAutoCenterRepulsion;
28
+ uniform int uLayers;
29
+ uniform vec3 uColors[${q}];
30
+ uniform int uColorCount;
31
+ uniform float uWarp;
32
+ uniform float uReveal;
33
+ uniform float uMode;
34
+ uniform vec3 uBackground;
35
+ uniform float uOpacity;
36
+ out vec4 outColor;
37
+
38
+ #define STAR_COLOR_CUTOFF 0.2
39
+ #define MAT45 mat2(0.7071, -0.7071, 0.7071, 0.7071)
40
+ #define PERIOD 3.0
41
+
42
+ float Hash21(vec2 p) {
43
+ p = fract(p * vec2(123.34, 456.21));
44
+ p += dot(p, p + 45.32);
45
+ return fract(p.x * p.y);
46
+ }
47
+
48
+ float tri(float x) {
49
+ return abs(fract(x) * 2.0 - 1.0);
50
+ }
51
+
52
+ float tris(float x) {
53
+ float t = fract(x);
54
+ return 1.0 - smoothstep(0.0, 1.0, abs(2.0 * t - 1.0));
55
+ }
56
+
57
+ float trisn(float x) {
58
+ float t = fract(x);
59
+ return 2.0 * (1.0 - smoothstep(0.0, 1.0, abs(2.0 * t - 1.0))) - 1.0;
60
+ }
61
+
62
+ vec3 hsv2rgb(vec3 c) {
63
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
64
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
65
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
66
+ }
67
+
68
+ float Star(vec2 uv, float flare, vec2 radial, float invReach) {
69
+ #ifdef WARP
70
+ float along = dot(uv, radial);
71
+ float d = sqrt(max(dot(uv, uv) - uSquash * along * along, 0.0));
72
+ #else
73
+ float d = length(uv);
74
+ #endif
75
+ float m = uStarGlow / d;
76
+ float rays = smoothstep(0.0, 1.0, 1.0 - abs(uv.x * uv.y * 1000.0));
77
+ m += rays * flare * uFlareGain;
78
+ uv *= MAT45;
79
+ rays = smoothstep(0.0, 1.0, 1.0 - abs(uv.x * uv.y * 1000.0));
80
+ m += rays * 0.3 * flare * uFlareGain;
81
+ m *= smoothstep(1.0, 0.2, d * invReach);
82
+ #ifdef WARP
83
+ m *= mix(1.0, smoothstep(1.0, 0.55, length(uv) * invReach), min(uWarp * 4.0, 1.0));
84
+ #endif
85
+ return m;
86
+ }
87
+
88
+ vec3 StarLayer(vec2 uv, vec2 radial, vec2 repelAt, float pushCells, float spread) {
89
+ vec3 col = vec3(0.0);
90
+ vec2 gv = fract(uv) - 0.5;
91
+ vec2 id = floor(uv);
92
+ for (int y = -1; y <= 1; y++) {
93
+ for (int x = -1; x <= 1; x++) {
94
+ vec2 offset = vec2(float(x), float(y));
95
+ vec2 si = id + offset;
96
+ float seed = Hash21(si);
97
+ float size = fract(seed * 345.32);
98
+ float glossLocal = tri(uGloss / (PERIOD * seed + 1.0));
99
+ float flareSize = smoothstep(0.9, 1.0, size) * glossLocal;
100
+
101
+ #ifdef PALETTE
102
+ float pick = Hash21(si + 7.0) * float(uColorCount);
103
+ vec3 base = uColors[int(min(floor(pick), float(uColorCount - 1)))];
104
+ #else
105
+ float red = smoothstep(STAR_COLOR_CUTOFF, 1.0, Hash21(si + 1.0)) + STAR_COLOR_CUTOFF;
106
+ float blu = smoothstep(STAR_COLOR_CUTOFF, 1.0, Hash21(si + 3.0)) + STAR_COLOR_CUTOFF;
107
+ float grn = min(red, blu) * seed;
108
+ vec3 base = vec3(red, grn, blu);
109
+ float hue = atan(base.g - base.r, base.b - base.r) / (2.0 * 3.14159) + 0.5;
110
+ hue = fract(hue + uHueShift / 360.0);
111
+ float sat = length(base - vec3(dot(base, vec3(0.299, 0.587, 0.114)))) * uSaturation;
112
+ float val = max(max(base.r, base.g), base.b);
113
+ base = hsv2rgb(vec3(hue, sat, val));
114
+ #endif
115
+
116
+ vec2 pad = vec2(tris(seed * 34.0 + uTime * uSpeed / 10.0), tris(seed * 38.0 + uTime * uSpeed / 30.0)) - 0.5;
117
+ vec2 shift = vec2(0.0);
118
+ float invReach = 1.0;
119
+ #ifdef REPEL
120
+ vec2 away = si + 0.5 + pad - repelAt;
121
+ float dist = length(away);
122
+ float q = dist * spread;
123
+ float cells = pushCells * exp(-q * q);
124
+ float moved = cells * inversesqrt(1.0 + cells * cells * 2.78);
125
+ shift = away * (moved / max(dist, 0.0001));
126
+ invReach = 1.0 / (1.0 - moved);
127
+ #endif
128
+ float star = Star(gv - offset - pad - shift, flareSize, radial, invReach);
129
+ float twinkle = trisn(uTime * uSpeed + seed * 6.2831) * 0.5 + 1.0;
130
+ twinkle = mix(1.0, twinkle, uTwinkleIntensity);
131
+ col += star * twinkle * size * base;
132
+ }
133
+ }
134
+ return col;
135
+ }
136
+
137
+ void main() {
138
+ vec2 focalPx = uFocal * uResolution;
139
+ vec2 uv = (gl_FragCoord.xy - focalPx) / uResolution.y;
140
+ vec2 mouseNorm = uMouse - vec2(0.5);
141
+
142
+ vec2 repelAt = vec2(0.0);
143
+ float strength = 0.0;
144
+ float push = 0.0;
145
+ if (uAutoCenterRepulsion > 0.0) {
146
+ strength = uAutoCenterRepulsion;
147
+ push = strength * 0.05;
148
+ } else if (uMouseRepulsion > 0.5) {
149
+ repelAt = (uMouse * uResolution - focalPx) / uResolution.y;
150
+ strength = max(uRepulsionStrength, 0.0);
151
+ push = strength * 0.05 * uMouseActiveFactor;
152
+ } else {
153
+ uv += mouseNorm * 0.1 * uMouseActiveFactor;
154
+ }
155
+ float radius = 0.16 + 0.04 * strength;
156
+
157
+ vec2 radial = length(uv) > 0.0001 ? normalize(uv) : vec2(1.0, 0.0);
158
+ float angle = uRotationAngle;
159
+ uv = mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * uv;
160
+ uv = mat2(uRotation.x, -uRotation.y, uRotation.y, uRotation.x) * uv;
161
+ radial = mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * radial;
162
+ radial = mat2(uRotation.x, -uRotation.y, uRotation.y, uRotation.x) * radial;
163
+ repelAt = mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * repelAt;
164
+ repelAt = mat2(uRotation.x, -uRotation.y, uRotation.y, uRotation.x) * repelAt;
165
+
166
+ vec3 col = vec3(0.0);
167
+ float layers = float(uLayers);
168
+ for (int k = 0; k < ${fe}; k++) {
169
+ if (k >= uLayers) break;
170
+ float i = float(k) / layers;
171
+ float depth = fract(i + uDepth);
172
+ float scale = mix(20.0 * uDensity, 0.5 * uDensity, depth);
173
+ float fade = depth * smoothstep(1.0, 0.9, depth);
174
+ vec2 offset = vec2(i * 453.32);
175
+ col += StarLayer(uv * scale + offset, radial, repelAt * scale + offset, push * scale, 1.0 / (scale * radius)) * fade;
176
+ }
177
+ col *= uReveal;
178
+
179
+ if (uMode > 1.5) {
180
+ vec3 lit = col * smoothstep(0.0, 0.3, length(col));
181
+ float energy = max(max(lit.r, lit.g), lit.b);
182
+ vec3 tint = lit / max(energy, 0.0001);
183
+ vec3 ink = tint * (0.16 / max(dot(tint, vec3(0.2126, 0.7152, 0.0722)), 0.16));
184
+ float coverage = pow(min(energy * 1.3, 1.0), 1.3) * 0.92 * uOpacity;
185
+ outColor = uMode > 2.5 ? vec4(ink * coverage, coverage) : vec4(mix(uBackground, ink, coverage), 1.0);
186
+ } else if (uMode > 0.5) {
187
+ float alpha = min(smoothstep(0.0, 0.3, length(col)), 1.0) * uOpacity;
188
+ outColor = vec4(col * alpha, alpha);
189
+ } else {
190
+ outColor = vec4(mix(uBackground, col, uOpacity), 1.0);
191
+ }
192
+ }`,_=(a,u,f)=>Math.min(f,Math.max(u,a)),He=(a,u,f)=>(a?4:0)+(u?2:0)+(f?1:0),Ue=(a,u,f,k)=>{const R=`${u?`#define PALETTE
193
+ `:""}${f?`#define REPEL
194
+ `:""}${k?`#define WARP
195
+ `:""}`,c=a.createProgram(),y=a.createShader(a.VERTEX_SHADER),x=a.createShader(a.FRAGMENT_SHADER);return!c||!y||!x?null:(a.shaderSource(y,ze),a.shaderSource(x,Be.replace(`
196
+ `,`
197
+ ${R}`)),a.compileShader(y),a.compileShader(x),a.attachShader(c,y),a.attachShader(c,x),a.bindAttribLocation(c,0,"aPosition"),a.linkProgram(c),a.deleteShader(y),a.deleteShader(x),c)},Ne=(a,u)=>{if(!a.getProgramParameter(u,a.LINK_STATUS))return null;const f={},k=a.getProgramParameter(u,a.ACTIVE_UNIFORMS);for(let R=0;R<k;R++){const c=a.getActiveUniform(u,R);c&&(f[c.name.replace("[0]","")]=a.getUniformLocation(u,c.name))}return{program:u,uniforms:f}},qe=({focal:a=[.5,.5],rotation:u=[1,0],starSpeed:f=.5,density:k=1,hueShift:R=140,disableAnimation:c=!1,speed:y=1,mouseInteraction:x=!0,glowIntensity:me=.3,saturation:de=0,mouseRepulsion:ve=!0,repulsionStrength:pe=2,twinkleIntensity:he=.3,rotationSpeed:ge=.1,autoCenterRepulsion:Re=0,transparent:ye=!0,lightMode:xe=!1,starColors:V,starSize:be=1,flareIntensity:Ae=1,layers:we=4,direction:Se="forward",clickWarp:Me=!0,intro:Ee=!0,backgroundColor:Ce,opacity:Te=1,dpr:ke,className:Le="",style:Fe,...Oe})=>{const K=T.useRef(null),$=T.useRef(null),I=T.useRef(null),Pe=Array.isArray(V)?V.filter(Boolean).slice(0,q):[],j={focal:Array.isArray(a)?a:[.5,.5],rotation:Array.isArray(u)?u:[1,0],starSpeed:f,density:Math.max(.01,k),hueShift:R,disableAnimation:c,speed:y,mouseInteraction:x,glowIntensity:Math.max(0,me),saturation:Math.max(0,de),mouseRepulsion:ve,repulsionStrength:pe,twinkleIntensity:_(he,0,1),rotationSpeed:ge,autoCenterRepulsion:Math.max(0,Re),transparent:ye,lightMode:xe,palette:Pe,starSize:Math.max(0,be),flareIntensity:Math.max(0,Ae),layers:_(Math.round(we),2,fe),reverse:Se==="backward",clickWarp:Me,intro:Ee,backgroundColor:Ce,opacity:_(Te,0,1),dpr:ke},m=T.useRef(j);return m.current=j,T.useEffect(()=>{const A=K.current,d=$.current,t=d?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1});if(!A||!d||!t)return;const X=t.getExtension("KHR_parallel_shader_compile"),L=new Map,F=(e,n,i)=>{const s=He(e,n,i);let l=L.get(s);return l||(l={program:Ue(t,e,n,i),linked:null,done:!1},L.set(s,l)),l},D=(e,n,i,s)=>{const l=F(e,n,i);if(!l.done&&l.program){if(!s&&X&&!t.getProgramParameter(l.program,X.COMPLETION_STATUS_KHR))return null;l.linked=Ne(t,l.program),l.done=!0}return l.linked},h=m.current;if(!D(h.palette.length>0,!1,!1,!0)){L.forEach(e=>e.program&&t.deleteProgram(e.program));return}const Y=t.createBuffer(),G=t.createVertexArray();t.bindVertexArray(G),t.bindBuffer(t.ARRAY_BUFFER,Y),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),t.STATIC_DRAW),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,0);const w=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),S=De().matches,Q=new Map,J=(e,n)=>{if(!e)return n;const i=String(e),s=Q.get(i);if(s)return s;let l=n;if(w){w.clearRect(0,0,1,1),w.fillStyle="#000000",w.fillStyle=i,w.fillRect(0,0,1,1);const[g,b,p]=w.getImageData(0,0,1,1).data;l=[g/255,b/255,p/255]}return Q.set(i,l),l},Z=new Float32Array(q*3),v={x:.5,y:.5,inside:!1},o={time:0,gloss:0,depth:0,angle:0,mx:.5,my:.5,active:0,boost:0,reveal:m.current.intro&&!S?0:1};let M=0,E=0,O=!0;const z=()=>{const e=m.current;e.palette.forEach((_e,Ie)=>Z.set(J(_e,[1,1,1]),Ie*3));const n=e.lightMode?e.transparent?3:2:e.transparent?1:0,i=J(e.backgroundColor,e.lightMode?[1,1,1]:[0,0,0]),s=o.reveal,l=e.palette.length>0,g=e.autoCenterRepulsion>0||e.mouseRepulsion&&e.repulsionStrength>0&&o.active>0,b=o.boost>0,p=D(l,!1,!1,!0);if(!p)return;const U=(g||b?D(l,g,b,!1):null)??p,r=U.uniforms;t.viewport(0,0,d.width,d.height),t.useProgram(U.program),t.bindVertexArray(G),t.uniform1f(r.uTime,o.time),t.uniform2f(r.uResolution,d.width,d.height),t.uniform2f(r.uFocal,e.focal[0],e.focal[1]),t.uniform2f(r.uRotation,e.rotation[0],e.rotation[1]),t.uniform1f(r.uGloss,o.gloss),t.uniform1f(r.uDepth,o.depth),t.uniform1f(r.uDensity,e.density),t.uniform1f(r.uHueShift,e.hueShift),t.uniform1f(r.uSpeed,e.speed),t.uniform2f(r.uMouse,o.mx,o.my);const N=1+o.boost*5;t.uniform1f(r.uStarGlow,.05*e.glowIntensity*e.starSize/Math.pow(N,.6)),t.uniform1f(r.uFlareGain,e.glowIntensity*e.flareIntensity),t.uniform1f(r.uSquash,1-1/(N*N)),t.uniform1f(r.uSaturation,e.saturation),t.uniform1f(r.uMouseRepulsion,e.mouseRepulsion?1:0),t.uniform1f(r.uTwinkleIntensity,e.twinkleIntensity),t.uniform1f(r.uRotationAngle,o.angle),t.uniform1f(r.uRepulsionStrength,e.repulsionStrength),t.uniform1f(r.uMouseActiveFactor,o.active),t.uniform1f(r.uAutoCenterRepulsion,e.autoCenterRepulsion),t.uniform1i(r.uLayers,e.layers),t.uniform3fv(r.uColors,Z),t.uniform1i(r.uColorCount,e.palette.length),t.uniform1f(r.uWarp,o.boost);const W=Math.min(1,s/.35);t.uniform1f(r.uReveal,W*W*(3-2*W)),t.uniform1f(r.uMode,n),t.uniform3fv(r.uBackground,i),t.uniform1f(r.uOpacity,e.opacity),t.drawArrays(t.TRIANGLES,0,3)},ee=e=>{if(M=0,!O||document.hidden)return;const n=m.current,i=E?_((e-E)/1e3,5e-4,.05):1/60;E=e;const s=n.disableAnimation||S?0:1;n.intro&&!S&&o.reveal<1?(o.reveal=Math.min(1,o.reveal+i/Ge),o.boost=Math.max(o.boost,Math.pow(1-o.reveal,2)*1.4)):(!n.intro||S)&&(o.reveal=1);const l=n.starSpeed/10*(n.reverse?-1:1);o.time+=i*s,o.gloss+=i*l*s,o.depth+=i*l*n.speed*s*(1+o.boost*14),o.angle+=i*n.rotationSpeed*s,o.boost*=Math.exp(-i*1.3),o.boost<.001&&(o.boost=0);const g=1-Math.exp(-i/.325),b=n.mouseInteraction&&v.inside&&!S;b&&(o.mx+=(v.x-o.mx)*g,o.my+=(v.y-o.my)*g);const p=b?1:0;o.active+=(p-o.active)*g,Math.abs(p-o.active)<.001&&(o.active=p),z(),s>0||o.boost>0||o.active!==p||o.reveal<1?M=requestAnimationFrame(ee):E=0},C=()=>{!M&&O&&!document.hidden&&(M=requestAnimationFrame(ee))},B=()=>{const e=m.current,n=Math.max(1,A.clientWidth),i=Math.max(1,A.clientHeight),s=Math.min(e.dpr||window.devicePixelRatio||1,2);d.width=Math.max(1,Math.round(n*s)),d.height=Math.max(1,Math.round(i*s)),z(),C()},te=e=>{const n=A.getBoundingClientRect(),i=e.clientX-n.left,s=e.clientY-n.top;v.inside=i>=0&&s>=0&&i<=n.width&&s<=n.height,v.x=i/Math.max(1,n.width),v.y=1-s/Math.max(1,n.height)},oe=e=>{te(e),C()},ne=e=>{const n=m.current;te(e),!(!v.inside||!n.clickWarp||S)&&(o.boost=Math.min(1.6,o.boost+1),C())},P=e=>{e.pointerType!=="mouse"&&(v.inside=!1)},ae=()=>{v.inside=!1},re=()=>{E=0,C()},ie=new ResizeObserver(B);ie.observe(A);const se=new IntersectionObserver(e=>{O=e.some(n=>n.isIntersecting),O&&(E=0,C())});se.observe(A),window.addEventListener("pointermove",oe,{passive:!0}),window.addEventListener("pointerdown",ne,{passive:!0}),window.addEventListener("pointerup",P,{passive:!0}),window.addEventListener("pointercancel",P,{passive:!0}),document.documentElement.addEventListener("pointerleave",ae),document.addEventListener("visibilitychange",re),B();const le=h.autoCenterRepulsion>0||h.mouseInteraction&&h.mouseRepulsion,H=h.palette.length>0;(h.clickWarp||h.intro)&&F(H,!1,!0),le&&F(H,!0,!1),le&&h.clickWarp&&F(H,!0,!0);let ue=m.current.dpr;return I.current=()=>{const e=m.current;if(e.dpr!==ue){ue=e.dpr,B();return}M||z(),C()},()=>{cancelAnimationFrame(M),I.current=null,ie.disconnect(),se.disconnect(),window.removeEventListener("pointermove",oe),window.removeEventListener("pointerdown",ne),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P),document.documentElement.removeEventListener("pointerleave",ae),document.removeEventListener("visibilitychange",re),L.forEach(e=>e.program&&t.deleteProgram(e.program)),t.deleteBuffer(Y),t.deleteVertexArray(G),d.isConnected||t.getExtension("WEBGL_lose_context")?.loseContext()}},[]),T.useEffect(()=>{I.current?.()}),ce.jsx("div",{ref:K,className:["relative h-full w-full overflow-hidden",Le].filter(Boolean).join(" "),style:Fe,...Oe,children:ce.jsx("canvas",{ref:$,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{qe as default};
@@ -1,4 +1,4 @@
1
- import{r as k,m as He,j as Q}from"./index-CH-7pBbW.js";const We=`#version 300 es
1
+ import{r as k,m as He,j as Q}from"./index-BstFwFxc.js";const We=`#version 300 es
2
2
  in vec2 aPosition;
3
3
  uniform vec2 uTexel;
4
4
  out vec2 vUv;
@@ -1,4 +1,4 @@
1
- import{r as C,m as Ke,j as pe}from"./index-CH-7pBbW.js";const V=8,B=3,ge=2400,z=3.4,ve=2.8,xe=["#4a3a9c","#8eb2ea","#6e8c3c","#d6f2ef","#f2d48c"],Ue=`#version 300 es
1
+ import{r as C,m as Ke,j as pe}from"./index-BstFwFxc.js";const V=8,B=3,ge=2400,z=3.4,ve=2.8,xe=["#4a3a9c","#8eb2ea","#6e8c3c","#d6f2ef","#f2d48c"],Ue=`#version 300 es
2
2
  void main() {
3
3
  vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
4
4
  gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
@@ -0,0 +1,103 @@
1
+ import{r as A,m as ke,j as de}from"./index-BstFwFxc.js";const Oe="relative h-full w-full overflow-hidden",Ge="absolute inset-0 block h-full w-full",Be=`#version 300 es
2
+ in vec2 aPosition;
3
+ out vec2 vUv;
4
+ void main() {
5
+ vUv = aPosition * 0.5 + 0.5;
6
+ gl_Position = vec4(aPosition, 0.0, 1.0);
7
+ }`,Ne=`#version 300 es
8
+ precision highp float;
9
+ uniform vec2 uResolution;
10
+ uniform float uTime;
11
+ uniform vec3 uColor;
12
+ uniform vec2 uMouse;
13
+ uniform float uAmplitude;
14
+ uniform float uScale;
15
+ uniform float uRotation;
16
+ uniform int uDetail;
17
+ uniform float uWarp;
18
+ uniform float uHue;
19
+ uniform float uSaturation;
20
+ uniform float uBrightness;
21
+ uniform float uContrast;
22
+ uniform float uGrain;
23
+ uniform float uSeed;
24
+ uniform float uFade;
25
+ uniform float uOpacity;
26
+ uniform sampler2D uField;
27
+ uniform float uStir;
28
+ uniform vec3 uPointer;
29
+ uniform float uSheen;
30
+ uniform vec4 uSwirls[6];
31
+ in vec2 vUv;
32
+ out vec4 outColor;
33
+
34
+ vec3 hueRotate(vec3 c, float angle) {
35
+ const vec3 k = vec3(0.57735027);
36
+ float ca = cos(angle);
37
+ return c * ca + cross(k, c) * sin(angle) + k * dot(k, c) * (1.0 - ca);
38
+ }
39
+
40
+ float smootherstep(float edge, float x) {
41
+ float t = clamp(x / edge, 0.0, 1.0);
42
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
43
+ }
44
+
45
+ float hash(vec2 p) {
46
+ p = fract(p * vec2(443.897, 441.423));
47
+ p += dot(p, p.yx + 19.19);
48
+ return fract((p.x + p.y) * p.x);
49
+ }
50
+
51
+ void main() {
52
+ float mr = min(uResolution.x, uResolution.y);
53
+ vec2 aspect = uResolution / mr;
54
+ vec2 st = vUv - texture(uField, vUv).rg * uStir;
55
+
56
+ for (int k = 0; k < 6; k++) {
57
+ vec4 swirl = uSwirls[k];
58
+ if (swirl.w == 0.0) continue;
59
+ vec2 delta = (st - swirl.xy) * aspect;
60
+ float angle = swirl.w * exp(-dot(delta, delta) / (swirl.z * swirl.z));
61
+ float ca = cos(angle);
62
+ float sa = sin(angle);
63
+ st = swirl.xy + vec2(ca * delta.x - sa * delta.y, sa * delta.x + ca * delta.y) / aspect;
64
+ }
65
+
66
+ vec2 uv = (st * 2.0 - 1.0) * aspect;
67
+ float c = cos(uRotation);
68
+ float s = sin(uRotation);
69
+ uv = mat2(c, -s, s, c) * uv / uScale;
70
+ uv += (uMouse - vec2(0.5)) * uAmplitude;
71
+
72
+ float d = -uTime * 0.5;
73
+ float a = 0.0;
74
+ for (int i = 0; i < 24; i++) {
75
+ if (i >= uDetail) break;
76
+ float fi = float(i);
77
+ a += cos(fi - d - a * uv.x * uWarp);
78
+ d += sin(uv.y * fi + a);
79
+ }
80
+ d += uTime * 0.5;
81
+ vec3 col = vec3(cos(uv * vec2(d, a)) * 0.6 + 0.4, cos(a + d) * 0.5 + 0.5);
82
+ col = cos(col * cos(vec3(d, a, 2.5)) * 0.5 + 0.5) * uColor;
83
+
84
+ vec2 toPointer = (vUv - uPointer.xy) * aspect;
85
+ col += col * uPointer.z * uSheen * 0.8 * exp(-dot(toPointer, toPointer) / 0.09);
86
+
87
+ col = hueRotate(col, uHue);
88
+ float luma = dot(col, vec3(0.2126, 0.7152, 0.0722));
89
+ col = mix(vec3(luma), col, uSaturation);
90
+ col = (col - 0.5) * uContrast + 0.5;
91
+ col *= uBrightness;
92
+ col += (hash(gl_FragCoord.xy + uSeed) - 0.5) * uGrain * 0.12;
93
+ col = clamp(col, 0.0, 1.0);
94
+
95
+ float alpha = uOpacity;
96
+ if (uFade > 0.0) {
97
+ vec2 px = vUv * uResolution;
98
+ float edge = uFade * mr * 0.5;
99
+ alpha *= smootherstep(edge, px.x) * smootherstep(edge, uResolution.x - px.x);
100
+ alpha *= smootherstep(edge, px.y) * smootherstep(edge, uResolution.y - px.y);
101
+ }
102
+ outColor = vec4(col * alpha, alpha);
103
+ }`,We=48,he=6,q=3.2,g=(f,S,F)=>Math.min(F,Math.max(S,f)),ve=(f,S,F)=>{const p=f.createShader(S);return p?(f.shaderSource(p,F),f.compileShader(p),f.getShaderParameter(p,f.COMPILE_STATUS)?p:(f.deleteShader(p),null)):null},ze=({color:f=[1,1,1],speed:S=1,amplitude:F=.1,mouseReact:p=!0,scale:pe=1,detail:xe=8,rotation:Re=0,warp:ge=1,hueShift:we=0,saturation:Ee=1,brightness:Te=1.5,contrast:Me=1,stir:ye=.5,sheen:Ae=.3,clickSwirl:Se=!0,grain:Fe=0,fade:Pe=0,opacity:be=1,resolution:_e=1,paused:Ue=!1,className:Y="",style:Le})=>{const $=A.useRef(null),Q=A.useRef(null),I=A.useRef(null),J={colorKey:Array.isArray(f)?f.join(","):String(f),color:f,speed:S,amplitude:F,mouseReact:p,scale:Math.max(.05,pe),detail:g(Math.round(xe),1,24),rotation:Re,warp:ge,hueShift:we,saturation:Math.max(0,Ee),brightness:Math.max(0,Te),contrast:Math.max(0,Me),stir:Math.max(0,ye),sheen:Math.max(0,Ae),clickSwirl:Se,grain:g(Fe,0,1),fade:g(Pe,0,1),opacity:g(be,0,1),resolution:g(_e,.1,2),paused:Ue},x=A.useRef(J);return x.current=J,A.useEffect(()=>{const w=$.current,R=Q.current,e=R?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1});if(!w||!R||!e)return;const X=ve(e,e.VERTEX_SHADER,Be),k=ve(e,e.FRAGMENT_SHADER,Ne),v=e.createProgram();if(!X||!k||!v||(e.attachShader(v,X),e.attachShader(v,k),e.linkProgram(v),!e.getProgramParameter(v,e.LINK_STATUS)))return;e.useProgram(v);const Z=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Z),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW);const ee=e.getAttribLocation(v,"aPosition");e.enableVertexAttribArray(ee),e.vertexAttribPointer(ee,2,e.FLOAT,!1,0,0);const n={};for(const o of["uResolution","uTime","uColor","uMouse","uAmplitude","uScale","uRotation","uDetail","uWarp","uHue","uSaturation","uBrightness","uContrast","uGrain","uSeed","uFade","uOpacity","uField","uStir","uPointer","uSheen","uSwirls"])n[o]=e.getUniformLocation(v,o);const U=e.createTexture();e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,U),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),e.uniform1i(n.uField,0);const O=document.createElement("canvas");O.width=1,O.height=1;const E=O.getContext("2d",{willReadFrequently:!0}),G=ke().matches,u={x:.5,y:.5,inside:!1,tracked:!1},t={width:1,height:1,phase:0,mouse:[.5,.5],presence:0,color:[1,1,1],colorKey:"",cols:0,rows:0,field:new Float32Array(0),scratch:new Float32Array(0),fieldActive:!1,swirls:[],seed:0},B=new Float32Array(he*4);let T=0,P=0,L=!0,N=!0;const Ce=o=>{if(o.colorKey===t.colorKey)return;if(t.colorKey=o.colorKey,Array.isArray(o.color)){const s=o.color;t.color=[0,1,2].map(m=>g(Number(s[m]??1),0,1));return}if(!E)return;E.clearRect(0,0,1,1),E.fillStyle="#ffffff",E.fillStyle=String(o.color),E.fillRect(0,0,1,1);const[r,i,a]=E.getImageData(0,0,1,1).data;t.color=[r/255,i/255,a/255]},De=()=>{const o=We,r=g(Math.round(o*t.height/t.width),6,96);o===t.cols&&r===t.rows||(t.cols=o,t.rows=r,t.field=new Float32Array(o*r*2),t.scratch=new Float32Array(o*r*2),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,U),e.texImage2D(e.TEXTURE_2D,0,e.RG16F,o,r,0,e.RG,e.FLOAT,t.field))},Ie=(o,r,i,a)=>{const{cols:s,rows:m,field:h}=t,c=.22,d=t.width/t.height,b=Math.max(0,Math.floor((o-c/d)*s)),H=Math.min(s-1,Math.ceil((o+c/d)*s)),z=Math.max(0,Math.floor((r-c)*m)),j=Math.min(m-1,Math.ceil((r+c)*m));for(let y=z;y<=j;y++)for(let l=b;l<=H;l++){const C=((l+.5)/s-o)*d,ce=(y+.5)/m-r,_=1-(C*C+ce*ce)/(c*c);if(_<=0)continue;const D=(y*s+l)*2,ue=h[D]+i*_*_*3.2,le=h[D+1]+a*_*_*3.2,V=Math.hypot(ue,le),fe=.4,me=V>0?fe*Math.tanh(V/fe)/V:0;h[D]=ue*me,h[D+1]=le*me}t.fieldActive=!0},Xe=o=>{const{cols:r,rows:i,field:a,scratch:s}=t,m=Math.exp(-o*1.4);let h=0;for(let c=0;c<i;c++)for(let d=0;d<r;d++){const b=(c*r+d)*2,H=(c*r+Math.max(0,d-1))*2,z=(c*r+Math.min(r-1,d+1))*2,j=(Math.max(0,c-1)*r+d)*2,y=(Math.min(i-1,c+1)*r+d)*2;for(let l=0;l<2;l++){const C=(a[b+l]*12+a[H+l]+a[z+l]+a[j+l]+a[y+l])/16;s[b+l]=C*m,h=Math.max(h,Math.abs(s[b+l]))}}a.set(s),h<4e-4&&(a.fill(0),t.fieldActive=!1)},W=()=>{const o=x.current;Ce(o),De(),e.viewport(0,0,R.width,R.height),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,U),e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.cols,t.rows,e.RG,e.FLOAT,t.field),B.fill(0),t.swirls.forEach((r,i)=>{const a=.21*(1+.4*r.age),s=Math.exp(-r.age*1.35)-Math.exp(-r.age*10),m=Math.min(1,(q-r.age)/.8);B.set([r.x,r.y,a,3*s*m*(.21/a)**2],i*4)}),e.uniform2f(n.uResolution,t.width,t.height),e.uniform1f(n.uTime,t.phase),e.uniform3f(n.uColor,t.color[0],t.color[1],t.color[2]),e.uniform2f(n.uMouse,t.mouse[0],t.mouse[1]),e.uniform1f(n.uAmplitude,o.amplitude),e.uniform1f(n.uScale,o.scale),e.uniform1f(n.uRotation,o.rotation*Math.PI/180),e.uniform1i(n.uDetail,o.detail),e.uniform1f(n.uWarp,o.warp),e.uniform1f(n.uHue,o.hueShift*Math.PI/180),e.uniform1f(n.uSaturation,o.saturation),e.uniform1f(n.uBrightness,o.brightness),e.uniform1f(n.uContrast,o.contrast),e.uniform1f(n.uGrain,o.grain),e.uniform1f(n.uSeed,t.seed),e.uniform1f(n.uFade,o.fade),e.uniform1f(n.uOpacity,o.opacity),e.uniform1f(n.uStir,o.mouseReact?o.stir:0),e.uniform3f(n.uPointer,u.x,u.y,o.mouseReact?t.presence:0),e.uniform1f(n.uSheen,o.sheen),e.uniform4fv(n.uSwirls,B),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLES,0,3)},te=o=>{if(T=0,!N||!L)return;const r=x.current,i=P?Math.min(.05,(o-P)/1e3):1/60;P=o;const a=!r.paused&&!G;a&&(t.phase+=i*r.speed);const s=r.mouseReact&&u.tracked?[u.x,u.y]:[.5,.5],m=1-Math.exp(-i*5);t.mouse[0]+=(s[0]-t.mouse[0])*m,t.mouse[1]+=(s[1]-t.mouse[1])*m,t.presence+=((u.inside?1:0)-t.presence)*(1-Math.exp(-i*4)),t.fieldActive&&Xe(i),t.swirls=t.swirls.filter(c=>(c.age+=i)<q),r.grain>0&&a&&(t.seed=Math.floor(o/42)%997),W();const h=Math.abs(s[0]-t.mouse[0])>5e-4||Math.abs(s[1]-t.mouse[1])>5e-4||Math.abs((u.inside?1:0)-t.presence)>.002;a||h||t.fieldActive||t.swirls.length?T=requestAnimationFrame(te):P=0},M=()=>{T||!N||!L||(T=requestAnimationFrame(te))},oe=o=>{const r=w.getBoundingClientRect();return{x:(o.clientX-r.left)/Math.max(1,r.width),y:1-(o.clientY-r.top)/Math.max(1,r.height)}},re=o=>{const r=x.current,{x:i,y:a}=oe(o),s=i>=0&&i<=1&&a>=0&&a<=1;s&&r.mouseReact&&!G&&u.inside&&r.stir>0&&Ie(i,a,i-u.x,a-u.y),u.x=i,u.y=a,u.inside=s,s&&(u.tracked=!0),M()},ae=()=>{u.inside=!1,M()},ie=o=>{if(!x.current.clickSwirl||G)return;const{x:i,y:a}=oe(o);if(!(i<0||i>1||a<0||a>1)){if(t.swirls.length>=he){if(t.swirls[0].age<q-.4)return;t.swirls.shift()}t.swirls.push({x:i,y:a,age:0}),M()}},K=()=>{const o=x.current,r=Math.min(window.devicePixelRatio||1,2)*o.resolution;t.width=Math.max(1,w.clientWidth),t.height=Math.max(1,w.clientHeight),R.width=Math.max(1,Math.round(t.width*r)),R.height=Math.max(1,Math.round(t.height*r)),W(),M()};I.current=()=>{const o=Math.min(window.devicePixelRatio||1,2)*x.current.resolution;R.width!==Math.max(1,Math.round(t.width*o))?K():T||W(),M()};const ne=new ResizeObserver(K);ne.observe(w);const se=new IntersectionObserver(o=>{L=o.some(r=>r.isIntersecting),L&&(P=0,M())});return se.observe(w),window.addEventListener("pointermove",re,{passive:!0}),window.addEventListener("pointerdown",ie,{passive:!0}),document.documentElement.addEventListener("pointerleave",ae),K(),()=>{N=!1,cancelAnimationFrame(T),I.current=null,ne.disconnect(),se.disconnect(),window.removeEventListener("pointermove",re),window.removeEventListener("pointerdown",ie),document.documentElement.removeEventListener("pointerleave",ae),e.deleteTexture(U),e.deleteBuffer(Z),e.deleteProgram(v),e.deleteShader(X),e.deleteShader(k)}},[]),A.useEffect(()=>{I.current?.()}),de.jsx("div",{ref:$,className:`${Oe}${Y?` ${Y}`:""}`,style:Le,children:de.jsx("canvas",{ref:Q,className:Ge,"aria-hidden":"true"})})};export{ze as default};
@@ -0,0 +1,94 @@
1
+ import{r as j,m as Pt,j as Ze}from"./index-BstFwFxc.js";const et="ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$&*()-_+=/[]{};:<>.,0123456789",tt="ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace",Lt=["#ffffff","#61dca3"],Dt=["#18181b","#0f9f6e"],Fe=8,kt=1.4,It=.2,Ut=.1,Xt=48,Bt=`#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
+ }`,Ot=`#version 300 es
6
+ precision highp float;
7
+ precision highp int;
8
+ uniform sampler2D uAtlas;
9
+ uniform sampler2D uState;
10
+ uniform ivec2 uCell;
11
+ uniform ivec2 uGrid;
12
+ uniform int uAtlasColumns;
13
+ uniform vec2 uResolution;
14
+ uniform vec2 uOrigin;
15
+ uniform vec3 uBase;
16
+ uniform float uBaseOpacity;
17
+ uniform vec3 uColors[8];
18
+ uniform float uEdge;
19
+ uniform float uCenter;
20
+ uniform vec2 uPointer;
21
+ uniform float uRadius;
22
+ uniform float uPresence;
23
+ uniform float uReveal;
24
+ uniform float uTime;
25
+ uniform float uFlow;
26
+ uniform float uFlowScale;
27
+ uniform vec4 uBackground;
28
+ out vec4 outColor;
29
+
30
+ float hash(vec2 p) {
31
+ vec3 q = fract(vec3(p.xyx) * 0.1031);
32
+ q += dot(q, q.yzx + 33.33);
33
+ return fract((q.x + q.y) * q.z);
34
+ }
35
+
36
+ float noise(vec2 p) {
37
+ vec2 i = floor(p);
38
+ vec2 f = fract(p);
39
+ vec2 w = f * f * (3.0 - 2.0 * f);
40
+ float a = hash(i);
41
+ float b = hash(i + vec2(1.0, 0.0));
42
+ float c = hash(i + vec2(0.0, 1.0));
43
+ float d = hash(i + vec2(1.0, 1.0));
44
+ return mix(mix(a, b, w.x), mix(c, d, w.x), w.y);
45
+ }
46
+
47
+ float smoother(float x) {
48
+ x = clamp(x, 0.0, 1.0);
49
+ return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);
50
+ }
51
+
52
+ void main() {
53
+ vec2 frag = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y) - uOrigin;
54
+ ivec2 q = ivec2(floor(frag));
55
+ ivec2 cell = q / uCell;
56
+ vec4 color = vec4(0.0);
57
+ if (all(greaterThanEqual(q, ivec2(0))) && all(lessThan(cell, uGrid))) {
58
+ vec4 state = texelFetch(uState, cell, 0);
59
+ int glyph = int(state.r * 255.0 + 0.5);
60
+ ivec2 texel = ivec2(glyph % uAtlasColumns, glyph / uAtlasColumns) * uCell + (q - cell * uCell);
61
+ float coverage = texelFetch(uAtlas, texel, 0).a;
62
+ if (coverage > 0.0) {
63
+ vec2 center = vec2(cell * uCell) + vec2(uCell) * 0.5 + uOrigin;
64
+ float mask = 1.0;
65
+ if (uEdge > 0.0) {
66
+ vec2 edge = min(center, uResolution - center) / uEdge;
67
+ mask = smoother(edge.x) * smoother(edge.y);
68
+ }
69
+ if (uCenter > 0.0) {
70
+ vec2 room = max(abs(center - uResolution * 0.5) - uResolution * vec2(0.3, 0.24), 0.0);
71
+ float soft = min(uResolution.x, uResolution.y) * 0.24;
72
+ mask *= 1.0 - uCenter * (1.0 - smoother(length(room) / soft));
73
+ }
74
+ float seed = hash(vec2(cell) + 17.0);
75
+ float rest = state.g * uBaseOpacity * (0.8 + 0.2 * sin(uTime * (0.5 + 1.2 * seed) + seed * 40.0));
76
+ if (uFlow > 0.0) {
77
+ vec2 p = center / uFlowScale;
78
+ float n = 0.65 * noise(p + vec2(uTime * 0.05, uTime * 0.03)) + 0.35 * noise(p * 2.03 - vec2(uTime * 0.04, -uTime * 0.06));
79
+ rest *= mix(1.0, 0.1 + 1.7 * smoothstep(0.25, 0.8, n), uFlow);
80
+ }
81
+ if (uPresence > 0.0) {
82
+ float d = length(center - uPointer) / uRadius;
83
+ float f = clamp(1.0 - d * d, 0.0, 1.0);
84
+ rest = mix(rest, max(rest, uReveal * step(0.004, state.g)), f * f * uPresence);
85
+ }
86
+ float heat = state.b;
87
+ rest = min(rest, 1.0) * (1.0 - heat);
88
+ vec3 tint = uColors[int(state.a * 255.0 + 0.5)];
89
+ float weight = coverage * mask;
90
+ color = vec4((uBase * rest + tint * heat) * weight, (rest + heat) * weight);
91
+ }
92
+ }
93
+ outColor = color + uBackground * (1.0 - color.a);
94
+ }`,S=(f,E,_)=>Math.min(_,Math.max(E,f)),Gt=f=>{const E=S(f,0,1);return E*E*E*(E*(E*6-15)+10)},nt=(f,E,_)=>{const M=f.createShader(E);return M?(f.shaderSource(M,_),f.compileShader(M),f.getShaderParameter(M,f.COMPILE_STATUS)?M:(f.deleteShader(M),null)):null},Wt=f=>{const E=nt(f,f.VERTEX_SHADER,Bt),_=nt(f,f.FRAGMENT_SHADER,Ot),M=f.createProgram();if(!E||!_||!M)return null;if(f.attachShader(M,E),f.attachShader(M,_),f.linkProgram(M),f.deleteShader(E),f.deleteShader(_),!f.getProgramParameter(M,f.LINK_STATUS))return f.deleteProgram(M),null;const ne={},pe=f.getProgramParameter(M,f.ACTIVE_UNIFORMS);for(let K=0;K<pe;K++){const oe=f.getActiveUniform(M,K);if(!oe)continue;const re=oe.name.replace(/\[0\]$/,"");ne[re]=f.getUniformLocation(M,re)}return{program:M,uniforms:ne}},qt=({glitchColors:f,baseColor:E,characters:_=et,fontFamily:M=tt,fontSize:ne=14,spacing:pe=.6,density:K=.9,baseOpacity:oe=.16,glitchAmount:re=.5,speed:ot=1,smooth:rt=!0,interactive:at=!0,cursorRadius:st=140,clickEffect:it="tear",flow:ct=.5,edgeFade:lt=0,centerFade:ut=0,intro:ft=!0,lightMode:Se=!1,backgroundColor:ht,dpr:mt,className:dt="",style:pt,...gt})=>{const _e=j.useRef(null),Pe=j.useRef(null),ge=j.useRef(null),Le={colors:((Array.isArray(f)&&f.length?f:null)||(Se?Dt:Lt)).slice(0,Fe),baseColor:E||(Se?"#18181b":"#ffffff"),characters:_||et,fontFamily:M||tt,fontSize:S(ne,6,96),spacing:S(pe,0,2),density:S(K,0,1),baseOpacity:S(oe,0,1),glitchAmount:S(re,0,1),speed:Math.max(0,ot),smooth:rt,interactive:at,cursorRadius:Math.max(0,st),clickEffect:it,flow:S(ct,0,1),edgeFade:S(lt,0,.5),centerFade:S(ut,0,1),intro:ft,backgroundColor:ht,dpr:mt},T=j.useRef(Le);return T.current=Le,j.useEffect(()=>{const B=_e.current,y=Pe.current,o=y?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1});if(!B||!y||!o)return;const ae=Wt(o);if(!ae)return;const d=ae.uniforms,De=o.createVertexArray(),ke=()=>{const t=o.createTexture();return o.bindTexture(o.TEXTURE_2D,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),t},Me=ke(),xe=ke(),Mt=o.getParameter(o.MAX_TEXTURE_SIZE),se=document.createElement("canvas"),P=se.getContext("2d"),O=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});if(!P)return;const Ie=new Map,ve=t=>{const n=String(t),e=Ie.get(n);if(e)return e;let a=[1,1,1];if(O){O.clearRect(0,0,1,1),O.fillStyle="#ffffff",O.fillStyle=n,O.fillRect(0,0,1,1);const[c,s,l]=O.getImageData(0,0,1,1).data;a=[c/255,s/255,l/255]}return Ie.set(n,a),a},k=Pt().matches,x={width:1,height:1,ratio:1},r={cols:0,rows:0,cellW:0,cellH:0,originX:0,originY:0,atlasColumns:1},i={x:0,y:0,sx:0,sy:0,inside:!1,presence:0,stir:0,fresh:!0},I=[],ie=new Float32Array(Fe*3),Ue=new Set;let J=[0],ce="",Xe="",le=1,A=0,w=new Uint8Array(0),G=new Float32Array(0),W=new Float32Array(0),D=new Float32Array(0),Q=new Float32Array(0),Z=new Float32Array(0),H=new Float32Array(0),ue=new Float32Array(0),we=new Float32Array(0),N=new Float32Array(0),U=new Int32Array(0),q=new Int32Array(0),z=0,fe=T.current.intro&&!k,Be=0,Oe=0,ye=-1,Ee=0,Te=0,Re=0,F=!0,ee=0,Y=0,he=!0,Ge=!0;const te=()=>J[Math.random()*J.length|0],X=()=>Math.random()*le|0,Ae=(t,n=1)=>ue[t]<T.current.density?Math.round(we[t]*255*n):0,me=(t,n)=>{const e=Math.floor((t-r.originX)/r.cellW),a=Math.floor((n-r.originY)/r.cellH);return e<0||a<0||e>=r.cols||a>=r.rows?-1:a*r.cols+e},V=(t,n,e,a,c,s=0)=>{if(U[t]<0){U[t]=z,q[z++]=t,G[t]=0,D[t]=e,W[t]=n,Q[t]=a,Z[t]=0,H[t]=s,w[t*4+3]=c;return}G[t]<.15&&(w[t*4+3]=c),W[t]=D[t]>0?Math.max(W[t],n):n,D[t]=Math.max(D[t],e),Q[t]=Math.max(Q[t],a),H[t]=Math.min(H[t],s)},xt=t=>{const n=q[t],e=q[--z];q[t]=e,U[e]=t,U[n]=-1,G[n]=0,w[n*4+2]=0},vt=()=>{const t=T.current,n=t.fontSize*x.ratio,e=`${n}px ${t.fontFamily}`,a=Array.from(t.characters),c=Array.from(new Set(a)).slice(0,256);P.font=e;let s=1;c.forEach(v=>{s=Math.max(s,P.measureText(v).width)});const l=P.measureText("M"),p=Math.max(2,Math.ceil(s+n*t.spacing)),R=Math.max(2,Math.ceil(n*(.95+t.spacing))),u=Math.max(1,Math.min(c.length,Math.floor(Mt/p)));se.width=u*p,se.height=Math.ceil(c.length/u)*R,P.font=e,P.textAlign="center",P.textBaseline="alphabetic",P.fillStyle="#ffffff";const m=R/2+(l.actualBoundingBoxAscent-l.actualBoundingBoxDescent)/2;c.forEach((v,$)=>{P.fillText(v,$%u*p+p/2,Math.floor($/u)*R+m)}),o.bindTexture(o.TEXTURE_2D,Me),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,se);const h=new Map(c.map((v,$)=>[v,$])),g=a.map(v=>h.get(v)).filter(v=>v!==void 0),b=g.length!==J.length||g.some((v,$)=>v!==J[$]);J=g.length?g:[0];const C=p!==r.cellW||R!==r.cellH;return r.cellW=p,r.cellH=R,r.atlasColumns=u,!Ue.has(e)&&document.fonts?.load&&(Ue.add(e),document.fonts.load(e,t.characters).then(()=>{Ge&&(ce="",L())}).catch(()=>{})),{resized:C,charsChanged:b}},wt=(t,n,e,a)=>{const c=(t+.5)/e-.5,s=(n+.5)/a-.5,l=Math.min(1,Math.hypot(c,s*.8)*1.6);return kt*(.3*l+.7*Math.random()**1.3)},We=()=>{const t=Math.ceil(y.width/r.cellW)+1,n=Math.ceil(y.height/r.cellH)+1;if(r.originX=Math.floor((y.width-t*r.cellW)/2),r.originY=Math.floor((y.height-n*r.cellH)/2),t===r.cols&&n===r.rows)return;const e=t*n,a=new Uint8Array(e*4),c=new Float32Array(e),s=new Float32Array(e),l=new Float32Array(e),p=Math.floor((r.cols-t)/2),R=Math.floor((r.rows-n)/2);for(let u=0;u<n;u++)for(let m=0;m<t;m++){const h=u*t+m,g=m+p,b=u+R;if(g>=0&&b>=0&&g<r.cols&&b<r.rows){const C=b*r.cols+g;a[h*4]=w[C*4],a[h*4+1]=w[C*4+1],c[h]=ue[C],s[h]=we[C],l[h]=N[C]}else a[h*4]=te(),c[h]=Math.random(),s[h]=.55+.45*Math.random(),l[h]=fe?wt(m,u,t,n):-1}r.cols=t,r.rows=n,A=e,w=a,ue=c,we=s,N=l,G=new Float32Array(e),W=new Float32Array(e),D=new Float32Array(e),Q=new Float32Array(e),Z=new Float32Array(e),H=new Float32Array(e),U=new Int32Array(e).fill(-1),q=new Int32Array(e),z=0,I.length=0;for(let u=0;u<e;u++)w[u*4+1]=N[u]>=0?0:Ae(u);ye=T.current.density,o.bindTexture(o.TEXTURE_2D,xe),o.texImage2D(o.TEXTURE_2D,0,o.RGBA8,t,n,0,o.RGBA,o.UNSIGNED_BYTE,w),F=!1},He=()=>{const t=T.current,n=`${t.fontSize*x.ratio}|${t.fontFamily}|${t.spacing}|${t.characters}`;if(n===ce)return;ce=n;const{resized:e,charsChanged:a}=vt();if((e||!r.cols)&&We(),a){for(let c=0;c<A;c++)w[c*4]=te();F=!0}},yt=()=>{const t=T.current,n=t.colors.join(",");if(n!==Xe){Xe=n,le=Math.max(1,t.colors.length);for(let e=0;e<Fe;e++){const a=ve(t.colors[Math.min(e,le-1)]??"#ffffff");ie[e*3]=a[0],ie[e*3+1]=a[1],ie[e*3+2]=a[2]}for(let e=0;e<A;e++)w[e*4+3]>=le&&(w[e*4+3]=X());F=!0}},be=t=>{I.length<Xt&&I.push({carry:0,after:0,wiggle:0,branch:0,...t})},Et=(t,n)=>{const e=me(t,n);if(e<0)return;const a=Math.floor(e/r.cols),c=r.cols*r.cellW;for(let s=-2;s<=2;s++){const l=a+s;if(l<0||l>=r.rows)continue;const p=1-Math.abs(s)/3;if(s!==0&&Math.random()>.3+.6*p)continue;const R=X(),u=r.originY+(l+.5)*r.cellH,m=(Math.random()-.5)*6*r.cellW*(1-p);[0,Math.PI].forEach(h=>{const g=c*(.12+.5*p*(.4+.6*Math.random()));be({x:t+m,y:u,angle:h,life:g,span:g,speed:(2200+Math.random()*1200)*x.ratio,after:Math.abs(s)*.035+Math.random()*.03,color:R})})}},Tt=(t,n)=>{const e=Math.min(x.width,x.height)*x.ratio,a=5+(Math.random()*3|0),c=Math.random()*Math.PI*2;for(let s=0;s<a;s++){const l=e*(.25+Math.random()*.3);be({x:t,y:n,angle:c+s/a*Math.PI*2+(Math.random()-.5)*.4,life:l,span:l,speed:(700+Math.random()*400)*x.ratio,wiggle:.2,branch:.03,color:X()})}},Rt=(t,n)=>{const e=me(t,n);e<0||(V(e,1,.08,.8,X()),T.current.clickEffect==="burst"?Tt(t,n):Et(t,n))},At=t=>{for(let n=I.length-1;n>=0;n--){const e=I[n];if(e.after>0){e.after-=t;continue}const a=Math.max(1,Math.abs(Math.cos(e.angle))*r.cellW+Math.abs(Math.sin(e.angle))*r.cellH*.6);for(e.carry+=e.speed*t;e.carry>=a&&e.life>0;){e.carry-=a,e.life-=a,e.angle+=(Math.random()-.5)*e.wiggle,e.x+=Math.cos(e.angle)*a,e.y+=Math.sin(e.angle)*a;const c=me(e.x,e.y);if(c<0){e.life=0;break}const s=e.life/e.span;if(V(c,.5+.5*s,.03+Math.random()*.05,.5+.5*s,e.color),e.branch&&Math.random()<e.branch){const l=Math.random()<.5?-1:1,p=e.life*(.45+Math.random()*.3);be({x:e.x,y:e.y,angle:e.angle+l*(.5+Math.random()*.5),life:p,span:e.span,speed:e.speed,wiggle:e.wiggle,color:e.color})}}e.life<=0&&I.splice(n,1)}},bt=t=>{const n=T.current;if(k||n.speed<=0||!A)return;Ee+=A*It*n.speed*t;let e=Math.min(A,Ee|0);for(Ee-=e;e-- >0;){const s=Math.random()*A|0;U[s]<0&&(w[s*4]=te(),F=!0)}const a=Math.max(n.speed,.2);Te+=A*n.glitchAmount**1.6*Ut*n.speed*t;let c=Math.min(A,Te|0);for(Te-=c;c-- >0;){const s=Math.random()*A|0,l=X(),p=.45+.55*Math.random(),R=(.04+Math.random()*.26)/a,u=(.45+Math.random()*.6)/a,m=Math.random();if(m<.24){const h=s%r.cols,g=m<.015,b=Math.min(r.cols-h,g?10+(Math.random()*24|0):2+(Math.random()*7|0)),C=(g?.012:.028)/a;for(let v=0;v<b;v++)V(s+v,p,R,u,l,v*C)}else V(s,p,R,u,l)}},Ct=t=>{const n=T.current;if(i.presence<.02||k||!A)return;const e=n.cursorRadius*x.ratio;if(e<1)return;const a=Math.max(0,Math.floor((i.sx-e-r.originX)/r.cellW)),c=Math.min(r.cols-1,Math.floor((i.sx+e-r.originX)/r.cellW)),s=Math.max(0,Math.floor((i.sy-e-r.originY)/r.cellH)),l=Math.min(r.rows-1,Math.floor((i.sy+e-r.originY)/r.cellH)),p=i.presence*(3+9*i.stir)*t;for(let m=s;m<=l;m++){const h=(r.originY+(m+.5)*r.cellH-i.sy)/e;for(let g=a;g<=c;g++){const b=(r.originX+(g+.5)*r.cellW-i.sx)/e,C=b*b+h*h;if(C>=1)continue;const v=m*r.cols+g;U[v]<0&&Math.random()<(1-C)*(1-C)*p&&(w[v*4]=te(),F=!0)}}const R=Math.PI*e*e/(r.cellW*r.cellH);Re+=R*i.presence*(.15+4*i.stir)*t;let u=Math.min(512,Re|0);for(Re-=u;u-- >0;){const m=Math.random()*Math.PI*2,h=Math.sqrt(Math.random()),g=(1-h*h)**2;if(Math.random()>g)continue;const b=me(i.sx+Math.cos(m)*h*e,i.sy+Math.sin(m)*h*e);b<0||V(b,(.3+.7*Math.random())*(.45+.55*i.stir),.02+Math.random()*.08,.35+Math.random()*.4,X())}},Ft=t=>{const n=T.current,e=Math.max(n.speed,.5),a=1-Math.exp(-t/.05);for(let c=0;c<z;){const s=q[c];if(H[s]>0){H[s]-=t,c++;continue}let l=G[s];if(D[s]>0?(D[s]-=t,l=n.smooth?l+(W[s]-l)*a:W[s]):l=n.smooth?l*Math.exp(-t*4/Math.max(Q[s],.05)):0,l<.012&&D[s]<=0){xt(c),F=!0;continue}G[s]=l,Z[s]-=t,Z[s]<=0&&(w[s*4]=te(),Z[s]=(.045+.45*(1-l)*(1-l))*(.6+.8*Math.random())/e),w[s*4+2]=Math.round(l*255),F=!0,c++}},St=t=>{if(!fe)return;const n=T.current;let e=!1;for(let a=0;a<A;a++){const c=N[a];if(c<0)continue;const s=Be-c;if(s<0){e=!0;continue}s<t&&Math.random()<(ue[a]<n.density?.45:.12)&&V(a,.4+.5*Math.random(),.02,.35+Math.random()*.35,X());const l=n.smooth?Gt(s/.35):1;w[a*4+1]=Ae(a,l),l>=1?N[a]=-1:e=!0}F=!0,e||(fe=!1)},Ne=t=>{if(ee=0,Ce&&(Ce=!1,_t()),!he||document.hidden)return;const n=T.current,e=Y?S((t-Y)/1e3,5e-4,.05):1/60;if(Y=t,Be+=e,k||(Oe+=e*n.speed),He(),yt(),n.density!==ye){ye=n.density;for(let u=0;u<A;u++)N[u]<0&&(w[u*4+1]=Ae(u));F=!0}const a=n.interactive&&i.inside&&!k?1:0;i.presence+=(a-i.presence)*(1-Math.exp(-e/.25)),Math.abs(a-i.presence)<.002&&(i.presence=a);const c=i.sx,s=i.sy,l=1-Math.exp(-e/.07);i.sx+=(i.x-i.sx)*l,i.sy+=(i.y-i.sy)*l;const p=Math.hypot(i.sx-c,i.sy-s)/x.ratio/e;if(i.stir+=(S(p/1400,0,1)-i.stir)*(1-Math.exp(-e/.12)),i.stir<.001&&(i.stir=0),St(e),bt(e),Ct(e),At(e),Ft(e),o.viewport(0,0,y.width,y.height),o.disable(o.BLEND),o.useProgram(ae.program),o.bindVertexArray(De),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,xe),F&&(o.texSubImage2D(o.TEXTURE_2D,0,0,0,r.cols,r.rows,o.RGBA,o.UNSIGNED_BYTE,w),F=!1),o.uniform1i(d.uState,1),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,Me),o.uniform1i(d.uAtlas,0),o.uniform2i(d.uCell,r.cellW,r.cellH),o.uniform2i(d.uGrid,r.cols,r.rows),o.uniform1i(d.uAtlasColumns,r.atlasColumns),o.uniform2f(d.uResolution,y.width,y.height),o.uniform2f(d.uOrigin,r.originX,r.originY),o.uniform3fv(d.uBase,ve(n.baseColor)),o.uniform1f(d.uBaseOpacity,n.baseOpacity),o.uniform3fv(d.uColors,ie),o.uniform1f(d.uEdge,n.edgeFade*Math.min(y.width,y.height)),o.uniform1f(d.uCenter,n.centerFade),o.uniform2f(d.uPointer,i.sx,i.sy),o.uniform1f(d.uRadius,Math.max(1,n.cursorRadius*x.ratio)),o.uniform1f(d.uPresence,i.presence),o.uniform1f(d.uReveal,Math.min(1,n.baseOpacity*3.5)),o.uniform1f(d.uTime,Oe),o.uniform1f(d.uFlow,n.flow),o.uniform1f(d.uFlowScale,Math.max(y.width,y.height)*.32),n.backgroundColor){const[u,m,h]=ve(n.backgroundColor);o.uniform4f(d.uBackground,u,m,h,1)}else o.uniform4f(d.uBackground,0,0,0,0);o.drawArrays(o.TRIANGLES,0,3),!k&&n.speed>0||z>0||I.length>0||fe||i.presence!==0&&i.presence!==1||i.stir>0?ee=requestAnimationFrame(Ne):Y=0};function L(){!ee&&he&&!document.hidden&&(ee=requestAnimationFrame(Ne))}let Ce=!1;const _t=()=>{const t=T.current;x.width=Math.max(1,B.clientWidth),x.height=Math.max(1,B.clientHeight),x.ratio=Math.min(t.dpr||window.devicePixelRatio||1,2),y.width=Math.max(1,Math.round(x.width*x.ratio)),y.height=Math.max(1,Math.round(x.height*x.ratio)),He(),r.cols&&We()},qe=()=>{Ce=!0,L()},ze=t=>{const n=B.getBoundingClientRect(),e=t.clientX-n.left,a=t.clientY-n.top;i.inside=e>=0&&a>=0&&e<=n.width&&a<=n.height,i.x=e*x.ratio,i.y=a*x.ratio,(i.fresh||i.presence<.02)&&(i.sx=i.x,i.sy=i.y,i.fresh=!1)},Ye=t=>{ze(t),L()},Ve=t=>{ze(t);const n=T.current;!i.inside||n.clickEffect==="none"||k||!A||(Rt(i.x,i.y),L())},de=t=>{t.pointerType!=="mouse"&&(i.inside=!1)},$e=()=>{i.inside=!1,L()},je=()=>{Y=0,L()},Ke=()=>{ce="",L()},Je=new ResizeObserver(qe);Je.observe(B);const Qe=new IntersectionObserver(t=>{he=t.some(n=>n.isIntersecting),he&&(Y=0,L())});return Qe.observe(B),window.addEventListener("pointermove",Ye,{passive:!0}),window.addEventListener("pointerdown",Ve,{passive:!0}),window.addEventListener("pointerup",de,{passive:!0}),window.addEventListener("pointercancel",de,{passive:!0}),document.documentElement.addEventListener("pointerleave",$e),document.addEventListener("visibilitychange",je),document.fonts?.addEventListener?.("loadingdone",Ke),qe(),ge.current=L,()=>{Ge=!1,cancelAnimationFrame(ee),ge.current=null,Je.disconnect(),Qe.disconnect(),window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerdown",Ve),window.removeEventListener("pointerup",de),window.removeEventListener("pointercancel",de),document.documentElement.removeEventListener("pointerleave",$e),document.removeEventListener("visibilitychange",je),document.fonts?.removeEventListener?.("loadingdone",Ke),o.deleteTexture(Me),o.deleteTexture(xe),o.deleteVertexArray(De),o.deleteProgram(ae.program),y.isConnected||o.getExtension("WEBGL_lose_context")?.loseContext()}},[]),j.useEffect(()=>{ge.current?.()}),Ze.jsx("div",{ref:_e,className:["relative h-full w-full overflow-hidden",dt].filter(Boolean).join(" "),style:pt,...gt,children:Ze.jsx("canvas",{ref:Pe,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{qt as default};
@@ -1,4 +1,4 @@
1
- import{r as k,m as Ne,j as re}from"./index-CH-7pBbW.js";const _e=1.8,Ue=`#version 300 es
1
+ import{r as k,m as Ne,j as re}from"./index-BstFwFxc.js";const _e=1.8,Ue=`#version 300 es
2
2
  in vec2 aPosition;
3
3
  void main() {
4
4
  gl_Position = vec4(aPosition, 0.0, 1.0);
@@ -1,4 +1,4 @@
1
- import{r as C,m as gt,j as Be}from"./index-CH-7pBbW.js";const ge=8,ae=3,Ge=4,We=2400,xt=4,V=2.4,ze=2.2,Xe=["#f2f5ff","#7fb2ff","#2f6bff"],vt=`#version 300 es
1
+ import{r as C,m as gt,j as Be}from"./index-BstFwFxc.js";const ge=8,ae=3,Ge=4,We=2400,xt=4,V=2.4,ze=2.2,Xe=["#f2f5ff","#7fb2ff","#2f6bff"],vt=`#version 300 es
2
2
  void main() {
3
3
  vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
4
4
  gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
@@ -0,0 +1,113 @@
1
+ import{r as w,m as we,j as re}from"./index-BstFwFxc.js";const Me=`#version 300 es
2
+ in vec2 aPosition;
3
+ void main() {
4
+ gl_Position = vec4(aPosition, 0.0, 1.0);
5
+ }`,Ae=`#version 300 es
6
+ precision highp float;
7
+ uniform vec2 uView;
8
+ uniform vec2 uScale;
9
+ uniform float uZoom;
10
+ uniform float uTime;
11
+ uniform float uTwist;
12
+ uniform float uWave;
13
+ uniform float uSharpness;
14
+ uniform vec2 uOrbit;
15
+ uniform float uDither;
16
+ out vec4 outColor;
17
+
18
+ float hash(vec2 p) {
19
+ p = fract(p * vec2(123.34, 456.21));
20
+ p += dot(p, p + 45.32);
21
+ return fract(p.x * p.y);
22
+ }
23
+
24
+ void main() {
25
+ vec2 c = (gl_FragCoord.xy * uScale - 0.5 * uView) / uZoom;
26
+ vec3 rd = normalize(vec3(c, uView.y));
27
+ vec3 ro = vec3(0.0, 0.0, -4.0);
28
+ float cy = cos(uOrbit.x);
29
+ float sy = sin(uOrbit.x);
30
+ float cx = cos(uOrbit.y);
31
+ float sx = sin(uOrbit.y);
32
+ mat3 orbit = mat3(cy, 0.0, -sy, 0.0, 1.0, 0.0, sy, 0.0, cy) * mat3(1.0, 0.0, 0.0, 0.0, cx, sx, 0.0, -sx, cx);
33
+ ro = orbit * ro;
34
+ rd = orbit * rd;
35
+ float z = 0.0;
36
+ float density = 0.0;
37
+ float band = 0.0;
38
+ for (int i = 0; i < 60; i++) {
39
+ vec3 p = ro + rd * z;
40
+ vec3 s = p;
41
+ float d = p.y - uTime;
42
+ p.x += uWave * (1.0 + p.y) * sin(d + p.x * 0.1) * cos(0.34 * d + p.x * 0.05);
43
+ vec2 q = p.xz *= mat2(cos(p.y * uTwist + vec4(0.0, 11.0, 33.0, 0.0) - uTime));
44
+ float shell = abs(sqrt(length(q * q)) - 0.25 * (5.0 + s.y)) / 3.0;
45
+ float stepLength = shell + 0.0008;
46
+ z += stepLength;
47
+ float phase = s.y + p.z * 0.5 + s.z - length(s - p);
48
+ float weight = (1.0 + sin(phase + 8.0)) * exp(-shell * uSharpness) * stepLength;
49
+ density += weight;
50
+ band += weight * (0.5 + 0.5 * sin(phase * 0.5 + 1.0));
51
+ }
52
+ vec2 encoded = sqrt(vec2(density, band) / (1.0 + vec2(density, band)));
53
+ encoded += (vec2(hash(gl_FragCoord.xy), hash(gl_FragCoord.yx + 17.0)) - 0.5) * uDither;
54
+ outColor = vec4(encoded, 0.0, 1.0);
55
+ }`,_e=`#version 300 es
56
+ precision highp float;
57
+ uniform sampler2D uVolume;
58
+ uniform vec2 uResolution;
59
+ uniform vec3 uColor;
60
+ uniform vec3 uHighlight;
61
+ uniform vec3 uInk;
62
+ uniform float uGain;
63
+ uniform float uShine;
64
+ uniform float uPresence;
65
+ uniform float uGrain;
66
+ uniform float uFade;
67
+ uniform float uOpacity;
68
+ uniform float uTime;
69
+ uniform float uLightMode;
70
+ uniform vec3 uHeat;
71
+ out vec4 outColor;
72
+
73
+ float hash(vec2 p) {
74
+ p = fract(p * vec2(123.34, 456.21));
75
+ p += dot(p, p + 45.32);
76
+ return fract(p.x * p.y);
77
+ }
78
+
79
+ float smootherstep(float edge, float x) {
80
+ float t = clamp(x / max(edge, 0.0001), 0.0, 1.0);
81
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
82
+ }
83
+
84
+ void main() {
85
+ vec2 uv = gl_FragCoord.xy / uResolution;
86
+ vec2 encoded = clamp(texture(uVolume, uv).rg, 0.0, 0.9995);
87
+ encoded *= encoded;
88
+ vec2 volume = encoded / (1.0 - encoded);
89
+ vec2 offset = (gl_FragCoord.xy - uHeat.xy) / uResolution.y;
90
+ float heat = uHeat.z * exp(-dot(offset, offset) / 0.05);
91
+ float density = volume.r * uGain * uPresence * (1.0 + heat * 0.35);
92
+ float band = clamp(volume.g / max(volume.r, 0.00001), 0.0, 1.0);
93
+ vec3 tint = mix(uColor, uHighlight, band * 0.35);
94
+ vec3 hdr = tint * density + uHighlight * density * density * uShine;
95
+ float peak = max(hdr.r, max(hdr.g, hdr.b));
96
+ float level = 1.0 - exp(-peak);
97
+ float hot = smoothstep(1.0, 3.0, peak);
98
+ float edge = uFade * 0.5;
99
+ float mask = smootherstep(edge, uv.x) * smootherstep(edge, 1.0 - uv.x) * smootherstep(edge, uv.y) * smootherstep(edge, 1.0 - uv.y);
100
+ mask *= uOpacity;
101
+ float grain = (hash(gl_FragCoord.xy + fract(uTime * 7.31) * 113.0) - 0.5) * uGrain;
102
+ if (uLightMode > 0.5) {
103
+ vec3 color = mix(uInk, vec3(1.0), hot * 0.75);
104
+ float alpha = clamp(pow(level, 0.8) * 0.9 * (1.0 + grain), 0.0, 1.0) * mask;
105
+ outColor = vec4(color * alpha, alpha);
106
+ } else {
107
+ vec3 hue = hdr / max(peak, 0.0001);
108
+ vec3 color = mix(hue * level, vec3(level), hot * 0.6);
109
+ color = pow(color, vec3(1.0 / 2.2));
110
+ color = clamp(color + grain * level, 0.0, 1.0) * mask;
111
+ outColor = vec4(color, max(color.r, max(color.g, color.b)));
112
+ }
113
+ }`,Fe=1.6,ie=16e5,U=(i,x,p)=>Math.min(p,Math.max(x,i)),ne=(i,x,p)=>{const m=i.createShader(x);return m?(i.shaderSource(m,p),i.compileShader(m),i.getShaderParameter(m,i.COMPILE_STATUS)?m:(i.deleteShader(m),null)):null},ae=(i,x)=>{const p=ne(i,i.VERTEX_SHADER,Me),m=ne(i,i.FRAGMENT_SHADER,x),l=i.createProgram();if(!p||!m||!l)return null;if(i.attachShader(l,p),i.attachShader(l,m),i.bindAttribLocation(l,0,"aPosition"),i.linkProgram(l),i.deleteShader(p),i.deleteShader(m),!i.getProgramParameter(l,i.LINK_STATUS))return i.deleteProgram(l),null;const _={},V=i.getProgramParameter(l,i.ACTIVE_UNIFORMS);for(let M=0;M<V;M++){const A=i.getActiveUniform(l,M);A&&(_[A.name]=i.getUniformLocation(l,A.name))}return{program:l,uniforms:_}},Se=({color:i="#a6a3b8",speed:x=1,direction:p="forward",scale:m=1,twist:l=1,wave:_=1,softness:V=.5,shine:M=1,brightness:A=1,grain:se=.04,quality:ce=.75,mouseInteractive:ue=!0,intro:le=!0,fade:fe=0,opacity:me=1,lightMode:he=!1,paused:de=!1,dpr:pe,className:ve="",...ge})=>{const B=w.useRef(null),H=w.useRef(null),D=w.useRef(null),N={color:String(i),speed:x,direction:p,scale:Math.max(.1,m),twist:l,wave:Math.max(0,_),softness:U(V,0,1),shine:Math.max(0,M),brightness:Math.max(0,A),grain:Math.max(0,se),quality:U(ce,.25,1),mouseInteractive:ue,intro:le,fade:U(fe,0,1),opacity:U(me,0,1),lightMode:he,paused:de,dpr:pe},v=w.useRef(N);return v.current=N,w.useEffect(()=>{const y=B.current,h=H.current,e=h?.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"});if(!y||!h||!e)return;const q=!!e.getExtension("EXT_color_buffer_float"),z=ae(e,Ae),W=ae(e,_e);if(!z||!W)return;const F={volume:z,composite:W},Y=e.createBuffer(),O=e.createVertexArray();e.bindVertexArray(O),e.bindBuffer(e.ARRAY_BUFFER,Y),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);const P=e.createTexture(),I=e.createFramebuffer(),g={width:0,height:0},xe=(t,r)=>{g.width===t&&g.height===r||(g.width=t,g.height=r,e.bindTexture(e.TEXTURE_2D,P),q?e.texImage2D(e.TEXTURE_2D,0,e.RGBA16F,t,r,0,e.RGBA,e.HALF_FLOAT,null):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,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),e.bindFramebuffer(e.FRAMEBUFFER,I),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,P,0))},E=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),S=we().matches,j=new Map,ye=t=>{const r=j.get(t);if(r)return r;let n=[1,1,1];if(E){E.clearRect(0,0,1,1),E.fillStyle="#ffffff",E.fillStyle=t,E.fillRect(0,0,1,1);const[a,s,c]=E.getImageData(0,0,1,1).data;n=[a,s,c].map(d=>Math.pow(d/255,2.2))}return j.set(t,n),n},u={width:1,height:1,volumeWidth:1,volumeHeight:1},f={x:0,y:0,inside:!1},o={clock:0,intro:v.current.intro&&!S?0:1,yaw:0,pitch:0,yawVelocity:0,pitchVelocity:0,heat:0,heatX:0,heatY:0};let T=0,R=0,L=!0;const Ee=t=>{const r=o.clock*.4;if(t.direction==="reverse")return-r;if(t.direction!=="pingpong")return r;const n=10,a=o.clock%n/n,s=a*a*(3-2*a);return(Math.floor(o.clock/n)%2===0?s:1-s)*n*.4},X=()=>{const t=v.current,r=o.intro*o.intro*(3-2*o.intro);e.bindVertexArray(O),xe(u.volumeWidth,u.volumeHeight);const n=F.volume,a=n.uniforms;e.bindFramebuffer(e.FRAMEBUFFER,I),e.viewport(0,0,g.width,g.height),e.useProgram(n.program),e.uniform2f(a.uView,u.width,u.height),e.uniform2f(a.uScale,u.width/g.width,u.height/g.height),e.uniform1f(a.uZoom,t.scale),e.uniform1f(a.uTime,Ee(t)+(1-r)*1.4),e.uniform1f(a.uTwist,t.twist),e.uniform1f(a.uWave,.4*t.wave),e.uniform1f(a.uSharpness,100-t.softness*90),e.uniform2f(a.uOrbit,o.yaw,o.pitch),e.uniform1f(a.uDither,q?0:1/255),e.drawArrays(e.TRIANGLES,0,3);const s=F.composite,c=s.uniforms,d=ye(t.color),G=d.map(C=>C+(1-C)*.85),Te=.2126*d[0]+.7152*d[1]+.0722*d[2],Re=Math.min(1,.16/Math.max(Te,.001)),be=d.map(C=>Math.pow(Math.min(1,C*Re),1/2.2));e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,h.width,h.height),e.useProgram(s.program),e.uniform2f(c.uResolution,h.width,h.height),e.uniform3fv(c.uColor,d),e.uniform3fv(c.uHighlight,G),e.uniform3fv(c.uInk,be),e.uniform1f(c.uGain,4.8*t.brightness),e.uniform1f(c.uShine,.025*t.shine),e.uniform1f(c.uPresence,r),e.uniform1f(c.uGrain,t.grain),e.uniform1f(c.uFade,t.fade),e.uniform1f(c.uOpacity,t.opacity),e.uniform1f(c.uTime,o.clock%1e3),e.uniform1f(c.uLightMode,t.lightMode?1:0),e.uniform3f(c.uHeat,o.heatX*h.width/u.width,(u.height-o.heatY)*h.height/u.height,o.heat),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,P),e.uniform1i(c.uVolume,0),e.drawArrays(e.TRIANGLES,0,3)},Q=t=>{if(T=0,!L||document.hidden)return;const r=v.current,n=R?Math.min(.05,(t-R)/1e3):1/60;R=t;const a=!r.paused&&!S;a&&(o.clock+=n*r.speed),!r.intro||S?o.intro=1:o.intro<1&&(o.intro=Math.min(1,o.intro+n/Fe));const s=r.mouseInteractive&&f.inside&&!S,c=s?(f.x/u.width-.5)*.9:0,d=s?(f.y/u.height-.5)*.18:0;o.yawVelocity+=(40*(c-o.yaw)-11*o.yawVelocity)*n,o.pitchVelocity+=(40*(d-o.pitch)-11*o.pitchVelocity)*n,o.yaw+=o.yawVelocity*n,o.pitch+=o.pitchVelocity*n,o.heat+=((s?1:0)-o.heat)*(1-Math.exp(-n*(s?4:2))),o.heatX+=(f.x-o.heatX)*(1-Math.exp(-n*8)),o.heatY+=(f.y-o.heatY)*(1-Math.exp(-n*8)),X();const G=o.intro<1||Math.abs(c-o.yaw)>5e-4||Math.abs(o.yawVelocity)>5e-4||Math.abs(d-o.pitch)>5e-4||Math.abs(o.pitchVelocity)>5e-4||Math.abs((s?1:0)-o.heat)>.002;a||G?T=requestAnimationFrame(Q):R=0},b=()=>{!T&&L&&!document.hidden&&(T=requestAnimationFrame(Q))},k=()=>{const t=v.current,r=Math.max(1,y.clientWidth),n=Math.max(1,y.clientHeight),a=Math.min(t.dpr||window.devicePixelRatio||1,2);u.width=r,u.height=n,h.width=Math.max(1,Math.round(r*a)),h.height=Math.max(1,Math.round(n*a));let s=t.quality;r*n*s*s>ie&&(s=Math.sqrt(ie/(r*n))),u.volumeWidth=Math.max(1,Math.round(r*s)),u.volumeHeight=Math.max(1,Math.round(n*s)),X(),b()},Z=t=>{const r=y.getBoundingClientRect();f.x=t.clientX-r.left,f.y=t.clientY-r.top,f.inside=f.x>=0&&f.y>=0&&f.x<=r.width&&f.y<=r.height,b()},K=()=>{f.inside=!1,b()},J=()=>{R=0,b()},$=new ResizeObserver(k);$.observe(y);const ee=new IntersectionObserver(t=>{L=t.some(r=>r.isIntersecting),L&&(R=0,b())});ee.observe(y),window.addEventListener("pointermove",Z,{passive:!0}),document.documentElement.addEventListener("pointerleave",K),document.addEventListener("visibilitychange",J),k();let te=v.current.quality,oe=v.current.dpr;return D.current=()=>{const t=v.current;if(t.quality!==te||t.dpr!==oe){te=t.quality,oe=t.dpr,k();return}T||X(),b()},()=>{cancelAnimationFrame(T),D.current=null,$.disconnect(),ee.disconnect(),window.removeEventListener("pointermove",Z),document.documentElement.removeEventListener("pointerleave",K),document.removeEventListener("visibilitychange",J),e.deleteTexture(P),e.deleteFramebuffer(I),e.deleteProgram(F.volume.program),e.deleteProgram(F.composite.program),e.deleteBuffer(Y),e.deleteVertexArray(O),h.isConnected||e.getExtension("WEBGL_lose_context")?.loseContext()}},[]),w.useEffect(()=>{D.current?.()}),re.jsx("div",{ref:B,className:["relative h-full w-full overflow-hidden",ve].filter(Boolean).join(" "),...ge,children:re.jsx("canvas",{ref:H,className:"absolute inset-0 block h-full w-full","aria-hidden":"true"})})};export{Se as Plasma,Se as default};