@rippleflow/water-distortion 0.1.4 → 0.1.5

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.
@@ -1,27 +1,27 @@
1
- var Ye = Object.defineProperty;
2
- var Ve = (r, e, n) => e in r ? Ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var f = (r, e, n) => Ve(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsxs as qe, jsx as de } from "react/jsx-runtime";
5
- import { forwardRef as $e, useRef as y, useImperativeHandle as Qe, useEffect as V, useState as je } from "react";
6
- function h(r, e, n) {
1
+ var Ve = Object.defineProperty;
2
+ var qe = (r, e, n) => e in r ? Ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var f = (r, e, n) => qe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsxs as $e, jsx as fe } from "react/jsx-runtime";
5
+ import { forwardRef as Qe, useRef as R, useImperativeHandle as je, useEffect as q, useState as Ze } from "react";
6
+ function d(r, e, n) {
7
7
  return Math.min(n, Math.max(e, r));
8
8
  }
9
- function Ze(r, e) {
9
+ function Je(r, e) {
10
10
  return Math.hypot(e.x - r.x, e.y - r.y);
11
11
  }
12
12
  function O(r, e, n) {
13
13
  return r + (e - r) * n;
14
14
  }
15
- const J = 24, C = 128, oe = 8, se = Math.PI * 2, fe = {
15
+ const ee = 24, V = 32, C = 128, oe = 8, se = Math.PI * 2, me = {
16
16
  causticGain: 0.1,
17
17
  screenCompensation: 1.35,
18
18
  maxAlpha: 0.9
19
- }, Je = {
19
+ }, et = {
20
20
  gradient: 8e-4,
21
21
  curvature: 8e-4,
22
22
  trough: 6e-3,
23
23
  velocity: 8e-4
24
- }, Ae = `
24
+ }, Fe = `
25
25
  attribute vec2 a_position;
26
26
  varying vec2 v_uv;
27
27
 
@@ -29,10 +29,10 @@ void main() {
29
29
  v_uv = a_position * 0.5 + 0.5;
30
30
  gl_Position = vec4(a_position, 0.0, 1.0);
31
31
  }
32
- `, et = `
32
+ `, tt = `
33
33
  precision highp float;
34
34
 
35
- #define MAX_WAKE_SEGMENTS ${J}
35
+ #define MAX_WAKE_SEGMENTS ${ee}
36
36
 
37
37
  varying vec2 v_uv;
38
38
 
@@ -122,7 +122,7 @@ void main() {
122
122
 
123
123
  gl_FragColor = vec4(height, velocity, 0.0, 1.0);
124
124
  }
125
- `, tt = `
125
+ `, rt = `
126
126
  precision highp float;
127
127
 
128
128
  varying vec2 v_uv;
@@ -131,6 +131,7 @@ uniform sampler2D u_state;
131
131
  uniform sampler2D u_background;
132
132
  uniform sampler2D u_causticMap;
133
133
  uniform vec2 u_texel;
134
+ uniform vec2 u_backgroundScale;
134
135
  uniform float u_domMode;
135
136
  uniform float u_normalScale;
136
137
  uniform float u_refractionStrength;
@@ -139,9 +140,9 @@ uniform float u_crestIntensity;
139
140
  uniform float u_causticIntensity;
140
141
  uniform float u_time;
141
142
 
142
- const float DOM_CAUSTIC_GAIN = ${fe.causticGain.toFixed(2)};
143
- const float DOM_SCREEN_COMPENSATION = ${fe.screenCompensation.toFixed(2)};
144
- const float DOM_MAX_ALPHA = ${fe.maxAlpha.toFixed(2)};
143
+ const float DOM_CAUSTIC_GAIN = ${me.causticGain.toFixed(2)};
144
+ const float DOM_SCREEN_COMPENSATION = ${me.screenCompensation.toFixed(2)};
145
+ const float DOM_MAX_ALPHA = ${me.maxAlpha.toFixed(2)};
145
146
 
146
147
  vec4 causticLayer(vec2 uv, vec2 bend, mat2 rotation, float scale, vec2 drift) {
147
148
  vec2 p = rotation * (uv * scale + drift * u_time);
@@ -161,8 +162,15 @@ void main() {
161
162
  float dy = up - down;
162
163
  float signedCurvature = left + right + down + up - height * 4.0;
163
164
  vec3 normal = normalize(vec3(-dx * u_normalScale, 1.0, -dy * u_normalScale));
164
- vec2 refractedUv = clamp(
165
- v_uv + normal.xz * u_refractionStrength * 0.025,
165
+ vec2 backgroundUv = (v_uv - vec2(0.5)) * u_backgroundScale + vec2(0.5);
166
+ vec2 refractedUv = (
167
+ v_uv + normal.xz * u_refractionStrength * 0.025 - vec2(0.5)
168
+ ) * u_backgroundScale + vec2(0.5);
169
+ vec2 textureBounds =
170
+ step(vec2(0.0), backgroundUv) * step(backgroundUv, vec2(1.0));
171
+ float textureAlpha = textureBounds.x * textureBounds.y;
172
+ refractedUv = clamp(
173
+ refractedUv,
166
174
  vec2(0.001),
167
175
  vec2(0.999)
168
176
  );
@@ -253,10 +261,10 @@ void main() {
253
261
  }
254
262
 
255
263
  vec3 color = base + highlight - vec3(0.015, 0.055, 0.070) * visibleTrough * 0.45;
256
- gl_FragColor = vec4(color, 1.0);
264
+ gl_FragColor = vec4(color, textureAlpha);
257
265
  }
258
266
  `;
259
- class rt {
267
+ class nt {
260
268
  constructor(e, n = () => {
261
269
  }) {
262
270
  f(this, "gl");
@@ -278,13 +286,15 @@ class rt {
278
286
  f(this, "textureImage");
279
287
  f(this, "textureReady", !1);
280
288
  f(this, "textureNeedsUpload", !1);
289
+ f(this, "textureWidth", 0);
290
+ f(this, "textureHeight", 0);
281
291
  f(this, "activityPixels");
282
- f(this, "wakeAUniforms", new Float32Array(J * 4));
283
- f(this, "wakeBUniforms", new Float32Array(J * 4));
284
- f(this, "wakeShapeUniforms", new Float32Array(J * 4));
292
+ f(this, "wakeAUniforms", new Float32Array(ee * 4));
293
+ f(this, "wakeBUniforms", new Float32Array(ee * 4));
294
+ f(this, "wakeShapeUniforms", new Float32Array(ee * 4));
285
295
  this.canvas = e, this.requestRender = n;
286
- const { gl: t, isWebGL2: i, canLinearFloat: a } = it(e);
287
- this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer = q(t.createBuffer(), "WebGL buffer"), this.simulationProgram = Le(t, Ae, et), this.materialProgram = Le(t, Ae, tt), this.backgroundTexture = q(t.createTexture(), "WebGL texture"), this.causticTexture = q(t.createTexture(), "WebGL texture"), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(
296
+ const { gl: t, isWebGL2: i, canLinearFloat: a } = st(e);
297
+ this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer = $(t.createBuffer(), "WebGL buffer"), this.simulationProgram = Ue(t, Fe, tt), this.materialProgram = Ue(t, Fe, rt), this.backgroundTexture = $(t.createTexture(), "WebGL texture"), this.causticTexture = $(t.createTexture(), "WebGL texture"), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(
288
298
  t.ARRAY_BUFFER,
289
299
  new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
290
300
  t.STATIC_DRAW
@@ -292,13 +302,17 @@ class rt {
292
302
  }
293
303
  resize(e, n, t, i) {
294
304
  this.cssWidth = Math.max(1, e), this.cssHeight = Math.max(1, n);
295
- const a = Math.min(2, Math.max(1, t || 1)), l = Math.max(1, Math.round(this.cssWidth * a)), c = Math.max(1, Math.round(this.cssHeight * a));
296
- (this.canvas.width !== l || this.canvas.height !== c) && (this.canvas.width = l, this.canvas.height = c);
297
- const s = Math.max(32, Math.round(i)), d = this.cssWidth / this.cssHeight, E = d >= 1 ? s : Math.max(1, Math.round(s * d)), p = d >= 1 ? Math.max(1, Math.round(s / d)) : s;
298
- E === this.simWidth && p === this.simHeight || (this.simWidth = E, this.simHeight = p, this.recreateState());
305
+ const a = Math.min(2, Math.max(1, t || 1)), s = Math.max(1, Math.round(this.cssWidth * a)), u = Math.max(1, Math.round(this.cssHeight * a));
306
+ (this.canvas.width !== s || this.canvas.height !== u) && (this.canvas.width = s, this.canvas.height = u);
307
+ const c = Math.max(
308
+ V,
309
+ Math.round(i)
310
+ ), h = this.cssWidth / this.cssHeight;
311
+ let v = c, x = c;
312
+ h >= 1 ? (x = Math.round(c / h), x < V && (x = V, v = Math.round(V * h))) : (v = Math.round(c * h), v < V && (v = V, x = Math.round(V / h))), !(v === this.simWidth && x === this.simHeight) && (this.simWidth = v, this.simHeight = x, this.recreateState());
299
313
  }
300
314
  setTextureSource(e) {
301
- if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, !e))
315
+ if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0, !e))
302
316
  return;
303
317
  if (typeof e != "string") {
304
318
  this.textureImage = e, this.textureNeedsUpload = !0;
@@ -339,7 +353,7 @@ class rt {
339
353
  } finally {
340
354
  e.bindFramebuffer(e.FRAMEBUFFER, null);
341
355
  }
342
- return ot(
356
+ return ut(
343
357
  this.activityPixels,
344
358
  this.simWidth,
345
359
  this.simHeight
@@ -360,14 +374,14 @@ class rt {
360
374
  (n = this.stateTextures) == null || n.forEach((i) => e.deleteTexture(i)), (t = this.framebuffers) == null || t.forEach((i) => e.deleteFramebuffer(i)), e.deleteTexture(this.backgroundTexture), e.deleteTexture(this.causticTexture), e.deleteBuffer(this.quadBuffer), e.deleteProgram(this.simulationProgram.program), e.deleteProgram(this.materialProgram.program);
361
375
  }
362
376
  recreateState() {
363
- var l, c;
377
+ var s, u;
364
378
  const e = this.gl;
365
- (l = this.stateTextures) == null || l.forEach((s) => e.deleteTexture(s)), (c = this.framebuffers) == null || c.forEach((s) => e.deleteFramebuffer(s));
379
+ (s = this.stateTextures) == null || s.forEach((c) => e.deleteTexture(c)), (u = this.framebuffers) == null || u.forEach((c) => e.deleteFramebuffer(c));
366
380
  const n = this.createStateTexture(), t = this.createStateTexture(), i = this.createFramebuffer(n), a = this.createFramebuffer(t);
367
381
  this.stateTextures = [n, t], this.framebuffers = [i, a], this.readIndex = 0, this.clear();
368
382
  }
369
383
  createStateTexture() {
370
- const e = this.gl, n = q(e.createTexture(), "WebGL texture");
384
+ const e = this.gl, n = $(e.createTexture(), "WebGL texture");
371
385
  if (e.bindTexture(e.TEXTURE_2D, n), e.texParameteri(
372
386
  e.TEXTURE_2D,
373
387
  e.TEXTURE_MIN_FILTER,
@@ -404,7 +418,7 @@ class rt {
404
418
  return n;
405
419
  }
406
420
  createFramebuffer(e) {
407
- const n = this.gl, t = q(n.createFramebuffer(), "WebGL framebuffer");
421
+ const n = this.gl, t = $(n.createFramebuffer(), "WebGL framebuffer");
408
422
  if (n.bindFramebuffer(n.FRAMEBUFFER, t), n.framebufferTexture2D(
409
423
  n.FRAMEBUFFER,
410
424
  n.COLOR_ATTACHMENT0,
@@ -440,11 +454,11 @@ class rt {
440
454
  0,
441
455
  e.RGBA,
442
456
  e.UNSIGNED_BYTE,
443
- nt()
457
+ ot()
444
458
  ), e.generateMipmap(e.TEXTURE_2D);
445
459
  }
446
460
  uploadTextureIfNeeded(e) {
447
- if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !at(this.textureImage))
461
+ if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !ct(this.textureImage))
448
462
  return;
449
463
  const n = this.gl;
450
464
  try {
@@ -455,9 +469,11 @@ class rt {
455
469
  n.RGBA,
456
470
  n.UNSIGNED_BYTE,
457
471
  this.textureImage
458
- ), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), this.textureReady = !0, this.textureNeedsUpload = !1;
472
+ ), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), [this.textureWidth, this.textureHeight] = at(
473
+ this.textureImage
474
+ ), this.textureReady = !0, this.textureNeedsUpload = !1;
459
475
  } catch {
460
- this.textureReady = !1, this.textureNeedsUpload = !1;
476
+ this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0;
461
477
  }
462
478
  }
463
479
  prepareQuad(e) {
@@ -465,54 +481,84 @@ class rt {
465
481
  n.bindBuffer(n.ARRAY_BUFFER, this.quadBuffer), n.enableVertexAttribArray(e.position), n.vertexAttribPointer(e.position, 2, n.FLOAT, !1, 0, 0);
466
482
  }
467
483
  setSimulationUniforms(e, n, t) {
468
- const i = this.gl, a = this.simulationProgram.program, l = Math.min(e.length, J), c = this.wakeAUniforms, s = this.wakeBUniforms, d = this.wakeShapeUniforms, E = Math.max(0, e.length - J);
469
- c.fill(0), s.fill(0), d.fill(0);
470
- for (let p = 0; p < l; p += 1) {
471
- const m = e[E + p], v = p * 4;
472
- c[v] = m.ax, c[v + 1] = m.ay, c[v + 2] = m.radius, c[v + 3] = m.wakeStrength, s[v] = m.bx, s[v + 1] = m.by, s[v + 2] = m.wakeLength, s[v + 3] = m.velocity, d[v] = m.troughStrength, d[v + 1] = m.ridgeStrength, d[v + 2] = m.ridgeOffset;
484
+ const i = this.gl, a = this.simulationProgram.program, s = Math.min(e.length, ee), u = this.wakeAUniforms, c = this.wakeBUniforms, h = this.wakeShapeUniforms, v = Math.max(0, e.length - ee);
485
+ u.fill(0), c.fill(0), h.fill(0);
486
+ for (let x = 0; x < s; x += 1) {
487
+ const m = e[v + x], p = x * 4;
488
+ u[p] = m.ax, u[p + 1] = m.ay, u[p + 2] = m.radius, u[p + 3] = m.wakeStrength, c[p] = m.bx, c[p + 1] = m.by, c[p + 2] = m.wakeLength, c[p + 3] = m.velocity, h[p] = m.troughStrength, h[p + 1] = m.ridgeStrength, h[p + 2] = m.ridgeOffset;
473
489
  }
474
- i.uniform1i(S(i, a, "u_state"), 0), i.uniform2f(S(i, a, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), i.uniform1f(S(i, a, "u_delta"), t), i.uniform1f(S(i, a, "u_damping"), n.damping), i.uniform1f(S(i, a, "u_stiffness"), n.waveSpeed), i.uniform1f(S(i, a, "u_aspect"), this.cssWidth / this.cssHeight), i.uniform1i(S(i, a, "u_wakeCount"), l), i.uniform4fv(S(i, a, "u_wakeA[0]"), c), i.uniform4fv(S(i, a, "u_wakeB[0]"), s), i.uniform4fv(S(i, a, "u_wakeShape[0]"), d);
490
+ i.uniform1i(_(i, a, "u_state"), 0), i.uniform2f(_(i, a, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), i.uniform1f(_(i, a, "u_delta"), t), i.uniform1f(_(i, a, "u_damping"), n.damping), i.uniform1f(_(i, a, "u_stiffness"), n.waveSpeed), i.uniform1f(_(i, a, "u_aspect"), this.cssWidth / this.cssHeight), i.uniform1i(_(i, a, "u_wakeCount"), s), i.uniform4fv(_(i, a, "u_wakeA[0]"), u), i.uniform4fv(_(i, a, "u_wakeB[0]"), c), i.uniform4fv(_(i, a, "u_wakeShape[0]"), h);
475
491
  }
476
492
  setMaterialUniforms(e, n) {
477
- const t = this.gl, i = this.materialProgram.program;
478
- t.uniform1i(S(t, i, "u_state"), 0), t.uniform1i(S(t, i, "u_background"), 1), t.uniform1i(S(t, i, "u_causticMap"), 2), t.uniform2f(S(t, i, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), t.uniform1f(S(t, i, "u_domMode"), e.mode === "dom" ? 1 : 0), t.uniform1f(S(t, i, "u_normalScale"), e.normalScale), t.uniform1f(S(t, i, "u_refractionStrength"), e.refractionStrength), t.uniform1f(S(t, i, "u_specularIntensity"), e.specularIntensity), t.uniform1f(S(t, i, "u_crestIntensity"), e.crestIntensity), t.uniform1f(S(t, i, "u_causticIntensity"), e.causticIntensity), t.uniform1f(S(t, i, "u_time"), n % 1e3);
493
+ const t = this.gl, i = this.materialProgram.program, [a, s] = it(
494
+ e.textureFit,
495
+ this.textureWidth,
496
+ this.textureHeight,
497
+ this.cssWidth,
498
+ this.cssHeight
499
+ );
500
+ t.uniform1i(_(t, i, "u_state"), 0), t.uniform1i(_(t, i, "u_background"), 1), t.uniform1i(_(t, i, "u_causticMap"), 2), t.uniform2f(_(t, i, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), t.uniform2f(
501
+ _(t, i, "u_backgroundScale"),
502
+ a,
503
+ s
504
+ ), t.uniform1f(_(t, i, "u_domMode"), e.mode === "dom" ? 1 : 0), t.uniform1f(_(t, i, "u_normalScale"), e.normalScale), t.uniform1f(_(t, i, "u_refractionStrength"), e.refractionStrength), t.uniform1f(_(t, i, "u_specularIntensity"), e.specularIntensity), t.uniform1f(_(t, i, "u_crestIntensity"), e.crestIntensity), t.uniform1f(_(t, i, "u_causticIntensity"), e.causticIntensity), t.uniform1f(_(t, i, "u_time"), n % 1e3);
479
505
  }
480
506
  }
481
- function nt() {
507
+ function it(r, e, n, t, i) {
508
+ if (r === "fill" || !Number.isFinite(e) || !Number.isFinite(n) || !Number.isFinite(t) || !Number.isFinite(i) || e <= 0 || n <= 0 || t <= 0 || i <= 0)
509
+ return [1, 1];
510
+ if (r === "none")
511
+ return [t / e, i / n];
512
+ const a = e / n, s = t / i;
513
+ return r === "cover" ? a > s ? [s / a, 1] : [1, a / s] : a > s ? [1, a / s] : [s / a, 1];
514
+ }
515
+ function at(r) {
516
+ const e = r, n = [
517
+ [e.naturalWidth, e.naturalHeight],
518
+ [e.videoWidth, e.videoHeight],
519
+ [e.displayWidth, e.displayHeight],
520
+ [e.width, e.height]
521
+ ];
522
+ for (const [t, i] of n)
523
+ if (typeof t == "number" && typeof i == "number" && Number.isFinite(t) && Number.isFinite(i) && t > 0 && i > 0)
524
+ return [t, i];
525
+ return [0, 0];
526
+ }
527
+ function ot() {
482
528
  const r = new Uint8Array(C * C * 4);
483
529
  for (let e = 0; e < C; e += 1)
484
530
  for (let n = 0; n < C; n += 1) {
485
- const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255), l = Math.round(ce(t, i, 11) * 255), c = Math.round(ce(t, i, 23) * 255), s = Math.round(ce(t, i, 37) * 255), d = (e * C + n) * 4;
486
- r[d] = a, r[d + 1] = l, r[d + 2] = c, r[d + 3] = s;
531
+ const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255), s = Math.round(ce(t, i, 11) * 255), u = Math.round(ce(t, i, 23) * 255), c = Math.round(ce(t, i, 37) * 255), h = (e * C + n) * 4;
532
+ r[h] = a, r[h + 1] = s, r[h + 2] = u, r[h + 3] = c;
487
533
  }
488
534
  return r;
489
535
  }
490
536
  function ce(r, e, n) {
491
- const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t, l = e * oe + i, c = Math.floor(a), s = Math.floor(l);
492
- let d = Number.POSITIVE_INFINITY, E = Number.POSITIVE_INFINITY, p = 0, m = 0;
537
+ const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t, s = e * oe + i, u = Math.floor(a), c = Math.floor(s);
538
+ let h = Number.POSITIVE_INFINITY, v = Number.POSITIVE_INFINITY, x = 0, m = 0;
493
539
  for (let P = -1; P <= 1; P += 1)
494
- for (let D = -1; D <= 1; D += 1) {
495
- const k = c + D, B = s + P, M = Ie(k, oe), I = Ie(B, oe), z = k + 0.16 + me(M, I, n) * 0.68, N = B + 0.16 + me(M, I, n + 1) * 0.68, U = Math.hypot(a - z, l - N);
496
- U < d ? (E = d, d = U, p = M, m = I) : U < E && (E = U);
540
+ for (let U = -1; U <= 1; U += 1) {
541
+ const k = u + U, B = c + P, b = Le(k, oe), I = Le(B, oe), z = k + 0.16 + ge(b, I, n) * 0.68, W = B + 0.16 + ge(b, I, n + 1) * 0.68, D = Math.hypot(a - z, s - W);
542
+ D < h ? (v = h, h = D, x = b, m = I) : D < v && (v = D);
497
543
  }
498
- const v = E - d, A = 1 - Fe(0.025, 0.13, v), w = 1 - Fe(0.08, 0.34, v), W = 0.74 + me(p, m, n + 2) * 0.26, H = A * A * 0.58 + w * 0.34;
499
- return We(Math.pow(H * W, 1.12));
544
+ const p = v - h, A = 1 - ke(0.025, 0.13, p), w = 1 - ke(0.08, 0.34, p), N = 0.74 + ge(x, m, n + 2) * 0.26, H = A * A * 0.58 + w * 0.34;
545
+ return Xe(Math.pow(H * N, 1.12));
500
546
  }
501
- function me(r, e, n) {
547
+ function ge(r, e, n) {
502
548
  const t = Math.sin(r * 127.1 + e * 311.7 + n * 74.7) * 43758.5453123;
503
549
  return t - Math.floor(t);
504
550
  }
505
- function Ie(r, e) {
551
+ function Le(r, e) {
506
552
  return (r % e + e) % e;
507
553
  }
508
- function Fe(r, e, n) {
509
- const t = We((n - r) / (e - r));
554
+ function ke(r, e, n) {
555
+ const t = Xe((n - r) / (e - r));
510
556
  return t * t * (3 - t * 2);
511
557
  }
512
- function We(r) {
558
+ function Xe(r) {
513
559
  return Math.min(1, Math.max(0, r));
514
560
  }
515
- function it(r) {
561
+ function st(r) {
516
562
  const e = {
517
563
  alpha: !0,
518
564
  antialias: !1,
@@ -544,51 +590,51 @@ function it(r) {
544
590
  canLinearFloat: !!t.getExtension("OES_texture_float_linear")
545
591
  };
546
592
  }
547
- function Le(r, e, n) {
548
- const t = ke(r, r.VERTEX_SHADER, e), i = ke(r, r.FRAGMENT_SHADER, n), a = q(r.createProgram(), "WebGL program");
593
+ function Ue(r, e, n) {
594
+ const t = De(r, r.VERTEX_SHADER, e), i = De(r, r.FRAGMENT_SHADER, n), a = $(r.createProgram(), "WebGL program");
549
595
  if (r.attachShader(a, t), r.attachShader(a, i), r.linkProgram(a), r.deleteShader(t), r.deleteShader(i), !r.getProgramParameter(a, r.LINK_STATUS)) {
550
- const c = r.getProgramInfoLog(a) || "Unknown shader link error.";
551
- throw r.deleteProgram(a), new Error(c);
596
+ const u = r.getProgramInfoLog(a) || "Unknown shader link error.";
597
+ throw r.deleteProgram(a), new Error(u);
552
598
  }
553
- const l = r.getAttribLocation(a, "a_position");
554
- if (l < 0)
599
+ const s = r.getAttribLocation(a, "a_position");
600
+ if (s < 0)
555
601
  throw new Error("WaterDistortion could not bind its quad attribute.");
556
- return { program: a, position: l };
602
+ return { program: a, position: s };
557
603
  }
558
- function ke(r, e, n) {
559
- const t = q(r.createShader(e), "WebGL shader");
604
+ function De(r, e, n) {
605
+ const t = $(r.createShader(e), "WebGL shader");
560
606
  if (r.shaderSource(t, n), r.compileShader(t), !r.getShaderParameter(t, r.COMPILE_STATUS)) {
561
607
  const i = r.getShaderInfoLog(t) || "Unknown shader compile error.";
562
608
  throw r.deleteShader(t), new Error(i);
563
609
  }
564
610
  return t;
565
611
  }
566
- function S(r, e, n) {
612
+ function _(r, e, n) {
567
613
  const t = r.getUniformLocation(e, n);
568
614
  if (!t)
569
615
  throw new Error(`WaterDistortion could not bind uniform ${n}.`);
570
616
  return t;
571
617
  }
572
- function q(r, e) {
618
+ function $(r, e) {
573
619
  if (!r)
574
620
  throw new Error(`WaterDistortion could not create ${e}.`);
575
621
  return r;
576
622
  }
577
- function at(r) {
623
+ function ct(r) {
578
624
  return typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof HTMLVideoElement < "u" && r instanceof HTMLVideoElement || typeof OffscreenCanvas < "u" && r instanceof OffscreenCanvas;
579
625
  }
580
- function ot(r, e, n, t = Je) {
626
+ function ut(r, e, n, t = et) {
581
627
  const i = Math.max(0, Math.floor(e)), a = Math.max(0, Math.floor(n));
582
628
  if (i === 0 || a === 0)
583
629
  return !1;
584
- const l = (c, s) => r[(s * i + c) * 4] ?? 0;
585
- for (let c = 0; c < a; c += 1)
586
- for (let s = 0; s < i; s += 1) {
587
- const d = (c * i + s) * 4, E = r[d] ?? 0, p = r[d + 1] ?? 0;
588
- if (E < -t.trough || Math.abs(p) > t.velocity)
630
+ const s = (u, c) => r[(c * i + u) * 4] ?? 0;
631
+ for (let u = 0; u < a; u += 1)
632
+ for (let c = 0; c < i; c += 1) {
633
+ const h = (u * i + c) * 4, v = r[h] ?? 0, x = r[h + 1] ?? 0;
634
+ if (v < -t.trough || Math.abs(x) > t.velocity)
589
635
  return !0;
590
- const m = s > 0 ? l(s - 1, c) : E, v = s < i - 1 ? l(s + 1, c) : E, A = c > 0 ? l(s, c - 1) : E, w = c < a - 1 ? l(s, c + 1) : E, W = Math.hypot(v - m, w - A), H = Math.abs(m + v + A + w - E * 4);
591
- if (W > t.gradient || H > t.curvature)
636
+ const m = c > 0 ? s(c - 1, u) : v, p = c < i - 1 ? s(c + 1, u) : v, A = u > 0 ? s(c, u - 1) : v, w = u < a - 1 ? s(c, u + 1) : v, N = Math.hypot(p - m, w - A), H = Math.abs(m + p + A + w - v * 4);
637
+ if (N > t.gradient || H > t.curvature)
592
638
  return !0;
593
639
  }
594
640
  return !1;
@@ -606,8 +652,8 @@ const L = {
606
652
  velocityClamp: 1.35,
607
653
  cursorSmoothing: 0.2,
608
654
  segmentSpacing: 18
609
- }, st = 24;
610
- function ge(r) {
655
+ }, lt = 24;
656
+ function ve(r) {
611
657
  return {
612
658
  width: Math.max(1, r.width ?? L.width),
613
659
  height: Math.max(1, r.height ?? L.height),
@@ -637,7 +683,7 @@ function ge(r) {
637
683
  0.05,
638
684
  r.velocityClamp ?? L.velocityClamp
639
685
  ),
640
- cursorSmoothing: h(
686
+ cursorSmoothing: d(
641
687
  r.cursorSmoothing ?? L.cursorSmoothing,
642
688
  0,
643
689
  0.9
@@ -648,24 +694,24 @@ function ge(r) {
648
694
  )
649
695
  };
650
696
  }
651
- function De(r, e, n = r.timeStamp) {
697
+ function Pe(r, e, n = r.timeStamp) {
652
698
  const t = typeof r.getCoalescedEvents == "function" ? r.getCoalescedEvents() : [], i = t.length > 0 ? t : [r], a = n - r.timeStamp;
653
- return i.map((l) => ({
654
- x: l.clientX - e.left,
655
- y: l.clientY - e.top,
656
- time: l.timeStamp + a
699
+ return i.map((s) => ({
700
+ x: s.clientX - e.left,
701
+ y: s.clientY - e.top,
702
+ time: s.timeStamp + a
657
703
  }));
658
704
  }
659
- class ct {
705
+ class ht {
660
706
  constructor(e = {}) {
661
707
  f(this, "options");
662
708
  f(this, "previous");
663
709
  f(this, "smoothedVelocity", 0);
664
710
  f(this, "disturbances", []);
665
- this.options = ge(e);
711
+ this.options = ve(e);
666
712
  }
667
713
  configure(e) {
668
- this.options = ge({
714
+ this.options = ve({
669
715
  ...this.options,
670
716
  ...e
671
717
  });
@@ -679,25 +725,25 @@ class ct {
679
725
  if (!t)
680
726
  return this.previous = n, this.disturbances;
681
727
  n.time <= t.time && (n.time = t.time + 0.01);
682
- const i = this.smoothSample(t, n), a = Ze(t, i);
728
+ const i = this.smoothSample(t, n), a = Je(t, i);
683
729
  if (a < 0.35)
684
730
  return this.previous = i, this.disturbances;
685
- const l = a / Math.max(0.01, i.time - t.time), c = h(1 - this.options.cursorSmoothing, 0.12, 1);
731
+ const s = a / Math.max(0.01, i.time - t.time), u = d(1 - this.options.cursorSmoothing, 0.12, 1);
686
732
  this.smoothedVelocity = O(
687
733
  this.smoothedVelocity,
688
- l,
689
- c
734
+ s,
735
+ u
690
736
  ), this.previous = i;
691
- const s = Math.min(
692
- st,
737
+ const c = Math.min(
738
+ lt,
693
739
  Math.max(1, Math.ceil(a / this.options.segmentSpacing))
694
740
  );
695
- for (let d = 0; d < s; d += 1) {
696
- const E = d / s, p = (d + 1) / s;
741
+ for (let h = 0; h < c; h += 1) {
742
+ const v = h / c, x = (h + 1) / c;
697
743
  this.disturbances.push(
698
- ve(
699
- Ue(t, i, E),
700
- Ue(t, i, p),
744
+ xe(
745
+ Be(t, i, v),
746
+ Be(t, i, x),
701
747
  this.smoothedVelocity,
702
748
  this.options
703
749
  )
@@ -707,8 +753,8 @@ class ct {
707
753
  }
708
754
  clampSample(e) {
709
755
  return {
710
- x: h(e.x, 0, this.options.width),
711
- y: h(e.y, 0, this.options.height),
756
+ x: d(e.x, 0, this.options.width),
757
+ y: d(e.y, 0, this.options.height),
712
758
  time: e.time
713
759
  };
714
760
  }
@@ -721,39 +767,40 @@ class ct {
721
767
  };
722
768
  }
723
769
  }
724
- function ve(r, e, n, t) {
725
- const i = ge(t), a = h(
770
+ function xe(r, e, n, t) {
771
+ const i = ve(t), a = d(
726
772
  n * i.velocityScale / i.velocityClamp,
727
773
  0,
728
774
  1
729
- ), l = h(r.y / i.height, 0, 1), c = h(e.y / i.height, 0, 1), s = i.wakeLength * O(0.55, 1.35, a);
775
+ ), s = d(r.y / i.height, 0, 1), u = d(e.y / i.height, 0, 1), c = i.wakeLength * O(0.55, 1.35, a);
730
776
  return {
731
- ax: h(r.x / i.width, 0, 1),
732
- ay: 1 - l,
733
- bx: h(e.x / i.width, 0, 1),
734
- by: 1 - c,
777
+ ax: d(r.x / i.width, 0, 1),
778
+ ay: 1 - s,
779
+ bx: d(e.x / i.width, 0, 1),
780
+ by: 1 - u,
735
781
  radius: i.interactionRadius / i.height,
736
782
  wakeStrength: i.wakeStrength * O(0.18, 1, a),
737
783
  troughStrength: i.troughStrength,
738
784
  ridgeStrength: i.ridgeStrength,
739
785
  ridgeOffset: i.ridgeOffset / i.height,
740
- wakeLength: s / i.height,
786
+ wakeLength: c / i.height,
741
787
  velocity: a
742
788
  };
743
789
  }
744
- function Ue(r, e, n) {
790
+ function Be(r, e, n) {
745
791
  return {
746
792
  x: O(r.x, e.x, n),
747
793
  y: O(r.y, e.y, n),
748
794
  time: O(r.time, e.time, n)
749
795
  };
750
796
  }
751
- function ut(r) {
752
- const e = h(r, 0.85, 0.998), n = Math.ceil(Math.log(0.012) / Math.log(e));
753
- return h(n * (1e3 / 60), 900, 5200);
797
+ function dt(r) {
798
+ const e = d(r, 0.85, 0.998), n = Math.ceil(Math.log(0.012) / Math.log(e));
799
+ return d(n * (1e3 / 60), 900, 5200);
754
800
  }
755
- const x = {
801
+ const E = {
756
802
  mode: "texture",
803
+ textureFit: "fill",
757
804
  damping: 0.98,
758
805
  waveSpeed: 0.4,
759
806
  normalScale: 20,
@@ -776,136 +823,137 @@ const x = {
776
823
  interactionMode: "move",
777
824
  runInBackground: !1,
778
825
  pauseKey: void 0
779
- }, G = 1e3 / 60, lt = 4, Pe = 360, Be = 24, ht = 200;
780
- function dt(r) {
826
+ }, G = 1e3 / 60, ft = 4, Ce = 360, Ne = 24, mt = 200;
827
+ function gt(r) {
781
828
  return r instanceof Element && r.closest(
782
829
  "a, button, input, select, textarea, [contenteditable]:not([contenteditable=false])"
783
830
  ) !== null;
784
831
  }
785
- function ft(r) {
832
+ function vt(r) {
786
833
  const e = r.strength === void 0 ? void 0 : r.strength / 48;
787
834
  return {
788
- mode: r.mode ?? x.mode,
835
+ mode: r.mode ?? E.mode,
789
836
  texture: r.texture,
790
- damping: h(
791
- r.damping ?? r.dissipation ?? x.damping,
837
+ textureFit: r.textureFit ?? E.textureFit,
838
+ damping: d(
839
+ r.damping ?? r.dissipation ?? E.damping,
792
840
  0.85,
793
841
  0.998
794
842
  ),
795
- waveSpeed: h(r.waveSpeed ?? x.waveSpeed, 0.05, 1),
796
- normalScale: h(
797
- r.normalScale ?? x.normalScale,
843
+ waveSpeed: d(r.waveSpeed ?? E.waveSpeed, 0.05, 1),
844
+ normalScale: d(
845
+ r.normalScale ?? E.normalScale,
798
846
  1,
799
847
  80
800
848
  ),
801
- refractionStrength: h(
802
- r.refractionStrength ?? x.refractionStrength,
849
+ refractionStrength: d(
850
+ r.refractionStrength ?? E.refractionStrength,
803
851
  0,
804
852
  2.5
805
853
  ),
806
- specularIntensity: h(
807
- r.specularIntensity ?? x.specularIntensity,
854
+ specularIntensity: d(
855
+ r.specularIntensity ?? E.specularIntensity,
808
856
  0,
809
857
  3
810
858
  ),
811
- crestIntensity: h(
812
- r.crestIntensity ?? x.crestIntensity,
859
+ crestIntensity: d(
860
+ r.crestIntensity ?? E.crestIntensity,
813
861
  0,
814
862
  3
815
863
  ),
816
- causticIntensity: h(
817
- r.causticIntensity ?? x.causticIntensity,
864
+ causticIntensity: d(
865
+ r.causticIntensity ?? E.causticIntensity,
818
866
  0,
819
867
  3
820
868
  ),
821
- simulationResolution: h(
869
+ simulationResolution: d(
822
870
  Math.round(
823
- r.simulationResolution ?? x.simulationResolution
871
+ r.simulationResolution ?? E.simulationResolution
824
872
  ),
825
873
  64,
826
874
  384
827
875
  ),
828
- wakeStrength: h(
829
- r.wakeStrength ?? r.rippleStrength ?? e ?? x.wakeStrength,
876
+ wakeStrength: d(
877
+ r.wakeStrength ?? r.rippleStrength ?? e ?? E.wakeStrength,
830
878
  0,
831
879
  3
832
880
  ),
833
- interactionRadius: h(
834
- r.interactionRadius ?? x.interactionRadius,
881
+ interactionRadius: d(
882
+ r.interactionRadius ?? E.interactionRadius,
835
883
  2,
836
884
  80
837
885
  ),
838
- troughStrength: h(
839
- r.troughStrength ?? x.troughStrength,
886
+ troughStrength: d(
887
+ r.troughStrength ?? E.troughStrength,
840
888
  0,
841
889
  3
842
890
  ),
843
- ridgeStrength: h(
844
- r.ridgeStrength ?? x.ridgeStrength,
891
+ ridgeStrength: d(
892
+ r.ridgeStrength ?? E.ridgeStrength,
845
893
  0,
846
894
  3
847
895
  ),
848
- ridgeOffset: h(
849
- r.ridgeOffset ?? x.ridgeOffset,
896
+ ridgeOffset: d(
897
+ r.ridgeOffset ?? E.ridgeOffset,
850
898
  0,
851
899
  80
852
900
  ),
853
- wakeLength: h(
854
- r.wakeLength ?? x.wakeLength,
901
+ wakeLength: d(
902
+ r.wakeLength ?? E.wakeLength,
855
903
  1,
856
904
  240
857
905
  ),
858
- velocityScale: h(
859
- r.velocityScale ?? x.velocityScale,
906
+ velocityScale: d(
907
+ r.velocityScale ?? E.velocityScale,
860
908
  0.01,
861
909
  4
862
910
  ),
863
- velocityClamp: h(
864
- r.velocityClamp ?? x.velocityClamp,
911
+ velocityClamp: d(
912
+ r.velocityClamp ?? E.velocityClamp,
865
913
  0.05,
866
914
  8
867
915
  ),
868
- cursorSmoothing: h(
869
- r.cursorSmoothing ?? x.cursorSmoothing,
916
+ cursorSmoothing: d(
917
+ r.cursorSmoothing ?? E.cursorSmoothing,
870
918
  0,
871
919
  0.9
872
920
  ),
873
- segmentSpacing: h(
874
- r.segmentSpacing ?? x.segmentSpacing,
921
+ segmentSpacing: d(
922
+ r.segmentSpacing ?? E.segmentSpacing,
875
923
  1,
876
924
  96
877
925
  ),
878
- idleTimeout: Math.max(120, r.idleTimeout ?? x.idleTimeout),
879
- interactionMode: r.interactionMode ?? x.interactionMode,
880
- runInBackground: r.runInBackground ?? x.runInBackground,
881
- pauseKey: r.pauseKey || x.pauseKey
926
+ idleTimeout: Math.max(120, r.idleTimeout ?? E.idleTimeout),
927
+ interactionMode: r.interactionMode ?? E.interactionMode,
928
+ runInBackground: r.runInBackground ?? E.runInBackground,
929
+ pauseKey: r.pauseKey || E.pauseKey
882
930
  };
883
931
  }
884
- function Ce(r, e, n) {
885
- const t = h(r.x, 0, 1) * n.width, i = h(r.y, 0, 1) * n.height, a = Math.max(0.5, e.interactionRadius * 0.08), l = e.velocityClamp / e.velocityScale, c = {
932
+ function We(r, e, n) {
933
+ const t = d(r.x, 0, 1) * n.width, i = d(r.y, 0, 1) * n.height, a = Math.max(0.5, e.interactionRadius * 0.08), s = e.velocityClamp / e.velocityScale, u = {
886
934
  ...e,
887
935
  width: n.width,
888
936
  height: n.height,
889
937
  wakeLength: e.interactionRadius * 1.5
890
938
  };
891
939
  return [
892
- ve(
940
+ xe(
893
941
  { x: t - a, y: i },
894
942
  { x: t + a, y: i },
895
- l,
896
- c
943
+ s,
944
+ u
897
945
  ),
898
- ve(
946
+ xe(
899
947
  { x: t, y: i - a },
900
948
  { x: t, y: i + a },
901
- l,
902
- c
949
+ s,
950
+ u
903
951
  )
904
952
  ];
905
953
  }
906
- function mt(r) {
907
- const [e, n] = je(!1);
908
- return V(() => {
954
+ function xt(r) {
955
+ const [e, n] = Ze(!1);
956
+ return q(() => {
909
957
  if (!r || typeof window > "u" || !window.matchMedia) {
910
958
  n(!1);
911
959
  return;
@@ -920,71 +968,72 @@ function mt(r) {
920
968
  };
921
969
  }, [r]), e;
922
970
  }
923
- const gt = $e(function(e, n) {
971
+ const pt = Qe(function(e, n) {
924
972
  const {
925
973
  underlay: t,
926
974
  children: i,
927
975
  foreground: a,
928
- className: l,
929
- style: c,
930
- reducedMotion: s = "respect"
931
- } = e, d = y(null), E = y(null), p = y(null), m = y(new ct()), v = y(null), A = y(null), w = y(() => {
932
- }), W = y(() => {
933
- }), H = y(() => {
934
- }), P = y([]), D = y(!0), k = y(!0), B = y(!1), M = y(!1), I = y(null), z = y(0), N = y(0), U = y(0), R = ft(e), g = y(R), $ = y({ width: 1, height: 1 }), Ne = mt(
935
- s === "respect"
936
- ), ue = s === "disable" || s === "respect" && Ne, Xe = a ?? i;
937
- g.current = R, Qe(
976
+ className: s,
977
+ style: u,
978
+ reducedMotion: c = "respect"
979
+ } = e, h = R(null), v = R(null), x = R(null), m = R(new ht()), p = R(null), A = R(null), w = R(() => {
980
+ }), N = R(() => {
981
+ }), H = R(() => {
982
+ }), P = R([]), U = R(!0), k = R(!0), B = R(!1), b = R(!1), I = R(null), z = R(0), W = R(0), D = R(0), T = vt(e), g = R(T), Q = R({ width: 1, height: 1 }), Ge = xt(
983
+ c === "respect"
984
+ ), ue = c === "disable" || c === "respect" && Ge, Oe = a ?? i;
985
+ g.current = T, je(
938
986
  n,
939
987
  () => ({
940
- triggerRipple(_) {
941
- B.current || M.current || H.current(
942
- Ce(
943
- _,
988
+ triggerRipple(S) {
989
+ B.current || b.current || H.current(
990
+ We(
991
+ S,
944
992
  g.current,
945
- $.current
993
+ Q.current
946
994
  )
947
995
  );
948
996
  }
949
997
  }),
950
998
  []
951
- ), V(() => {
952
- var _;
953
- B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0, N.current = 0, U.current = 0, (_ = p.current) == null || _.clear()), w.current();
954
- }, [ue]), V(() => {
955
- const _ = p.current;
956
- if (!_)
999
+ ), q(() => {
1000
+ var S;
1001
+ B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0, W.current = 0, D.current = 0, (S = x.current) == null || S.clear()), w.current();
1002
+ }, [ue]), q(() => {
1003
+ const S = x.current;
1004
+ if (!S)
957
1005
  return;
958
- const { width: K, height: b } = $.current;
959
- _.resize(
1006
+ const { width: K, height: M } = Q.current;
1007
+ S.resize(
960
1008
  K,
961
- b,
1009
+ M,
962
1010
  window.devicePixelRatio,
963
- R.simulationResolution
964
- ), _.setTextureSource(R.texture), w.current();
1011
+ T.simulationResolution
1012
+ ), S.setTextureSource(T.texture), w.current();
965
1013
  }, [
966
- R.mode,
967
- R.texture,
968
- R.damping,
969
- R.waveSpeed,
970
- R.normalScale,
971
- R.refractionStrength,
972
- R.specularIntensity,
973
- R.crestIntensity,
974
- R.causticIntensity,
975
- R.simulationResolution
976
- ]), V(() => {
977
- const _ = d.current, K = E.current;
978
- if (!_ || !K)
1014
+ T.mode,
1015
+ T.texture,
1016
+ T.textureFit,
1017
+ T.damping,
1018
+ T.waveSpeed,
1019
+ T.normalScale,
1020
+ T.refractionStrength,
1021
+ T.specularIntensity,
1022
+ T.crestIntensity,
1023
+ T.causticIntensity,
1024
+ T.simulationResolution
1025
+ ]), q(() => {
1026
+ const S = h.current, K = v.current;
1027
+ if (!S || !K)
979
1028
  return;
980
1029
  k.current = typeof document.hasFocus == "function" ? document.hasFocus() : !0;
981
- let b = null, ie, ee = G, xe = !1, te;
1030
+ let M = null, ae, te = G, pe = !1, re;
982
1031
  const Y = () => {
983
- v.current !== null && (window.cancelAnimationFrame(v.current), v.current = null), A.current !== null && (window.clearTimeout(A.current), A.current = null);
984
- }, Oe = (o, u) => {
1032
+ p.current !== null && (window.cancelAnimationFrame(p.current), p.current = null), A.current !== null && (window.clearTimeout(A.current), A.current = null);
1033
+ }, ze = (o, l) => {
985
1034
  m.current.configure({
986
1035
  width: o,
987
- height: u,
1036
+ height: l,
988
1037
  interactionRadius: g.current.interactionRadius,
989
1038
  wakeStrength: g.current.wakeStrength,
990
1039
  troughStrength: g.current.troughStrength,
@@ -996,56 +1045,56 @@ const gt = $e(function(e, n) {
996
1045
  cursorSmoothing: g.current.cursorSmoothing,
997
1046
  segmentSpacing: g.current.segmentSpacing
998
1047
  });
999
- }, He = (o, u) => {
1000
- const F = Math.max(1, o), T = Math.max(1, u);
1001
- $.current = { width: F, height: T }, Oe(F, T), b == null || b.resize(
1048
+ }, Ke = (o, l) => {
1049
+ const F = Math.max(1, o), y = Math.max(1, l);
1050
+ Q.current = { width: F, height: y }, ze(F, y), M == null || M.resize(
1002
1051
  F,
1003
- T,
1052
+ y,
1004
1053
  window.devicePixelRatio,
1005
1054
  g.current.simulationResolution
1006
1055
  );
1007
1056
  }, Ee = () => {
1008
- b == null || b.render(g.current, performance.now() * 1e-3);
1057
+ M == null || M.render(g.current, performance.now() * 1e-3);
1009
1058
  }, X = () => {
1010
- ie = void 0, ee = G;
1011
- }, re = () => {
1012
- Y(), m.current.reset(), I.current = null, X(), te === void 0 && (te = performance.now());
1013
- }, Q = () => {
1059
+ ae = void 0, te = G;
1060
+ }, ne = () => {
1061
+ Y(), m.current.reset(), I.current = null, X(), re === void 0 && (re = performance.now());
1062
+ }, j = () => {
1014
1063
  const o = g.current;
1015
- let u = !1;
1016
- if (!(!B.current && !M.current && D.current && (o.runInBackground || !document.hidden && k.current))) {
1064
+ let l = !1;
1065
+ if (!(!B.current && !b.current && U.current && (o.runInBackground || !document.hidden && k.current))) {
1017
1066
  X();
1018
1067
  return;
1019
1068
  }
1020
- if (te !== void 0) {
1021
- const T = performance.now() - te;
1022
- z.current += T, N.current += T, U.current += T, te = void 0, u = !0;
1069
+ if (re !== void 0) {
1070
+ const y = performance.now() - re;
1071
+ z.current += y, W.current += y, D.current += y, re = void 0, l = !0;
1023
1072
  }
1024
- (!o.runInBackground || u) && X(), Ee(), w.current();
1025
- }, pe = (o) => {
1026
- v.current = null;
1027
- const u = g.current;
1028
- if (!b || M.current || !D.current || !u.runInBackground && (document.hidden || !k.current)) {
1073
+ (!o.runInBackground || l) && X(), Ee(), w.current();
1074
+ }, _e = (o) => {
1075
+ p.current = null;
1076
+ const l = g.current;
1077
+ if (!M || b.current || !U.current || !l.runInBackground && (document.hidden || !k.current)) {
1029
1078
  X();
1030
1079
  return;
1031
1080
  }
1032
1081
  if (B.current) {
1033
- P.current = [], b.render(u, o * 1e-3), X();
1082
+ P.current = [], M.render(l, o * 1e-3), X();
1034
1083
  return;
1035
1084
  }
1036
- const F = u.runInBackground ? Pe : lt, T = ie === void 0 ? G : h(
1037
- o - ie,
1085
+ const F = l.runInBackground ? Ce : ft, y = ae === void 0 ? G : d(
1086
+ o - ae,
1038
1087
  0,
1039
- u.runInBackground ? G * Pe : 64
1088
+ l.runInBackground ? G * Ce : 64
1040
1089
  );
1041
- ie = o, ee = Math.min(
1042
- ee + T,
1090
+ ae = o, te = Math.min(
1091
+ te + y,
1043
1092
  G * F
1044
1093
  );
1045
- let Z = P.current.splice(0), be = 0;
1046
- for (; ee >= G && be < F; )
1047
- b.step(Z, u, 1), Z = [], ee -= G, be += 1;
1048
- if (b.render(u, o * 1e-3), P.current.length > 0) {
1094
+ let J = P.current.splice(0), Ie = 0;
1095
+ for (; te >= G && Ie < F; )
1096
+ M.step(J, l, 1), J = [], te -= G, Ie += 1;
1097
+ if (M.render(l, o * 1e-3), P.current.length > 0) {
1049
1098
  w.current();
1050
1099
  return;
1051
1100
  }
@@ -1053,131 +1102,131 @@ const gt = $e(function(e, n) {
1053
1102
  w.current();
1054
1103
  return;
1055
1104
  }
1056
- if (xe) {
1057
- o < N.current ? w.current() : X();
1105
+ if (pe) {
1106
+ o < W.current ? w.current() : X();
1058
1107
  return;
1059
1108
  }
1060
- if (o < U.current) {
1109
+ if (o < D.current) {
1061
1110
  w.current();
1062
1111
  return;
1063
1112
  }
1064
1113
  try {
1065
- b.hasVisibleActivity() ? (U.current = o + ht, w.current()) : X();
1114
+ M.hasVisibleActivity() ? (D.current = o + mt, w.current()) : X();
1066
1115
  } catch {
1067
- xe = !0, o < N.current ? w.current() : X();
1116
+ pe = !0, o < W.current ? w.current() : X();
1068
1117
  }
1069
1118
  }, le = () => {
1070
- M.current || v.current !== null || A.current !== null || (g.current.runInBackground && document.hidden ? A.current = window.setTimeout(() => {
1071
- A.current = null, pe(performance.now());
1072
- }, G) : v.current = window.requestAnimationFrame(pe));
1119
+ b.current || p.current !== null || A.current !== null || (g.current.runInBackground && document.hidden ? A.current = window.setTimeout(() => {
1120
+ A.current = null, _e(performance.now());
1121
+ }, G) : p.current = window.requestAnimationFrame(_e));
1073
1122
  };
1074
1123
  w.current = le;
1075
1124
  try {
1076
- b = new rt(K, () => {
1125
+ M = new nt(K, () => {
1077
1126
  w.current();
1078
- }), p.current = b, b.setTextureSource(g.current.texture);
1127
+ }), x.current = M, M.setTextureSource(g.current.texture);
1079
1128
  } catch {
1080
- return K.style.display = "none", p.current = null, w.current = () => {
1129
+ return K.style.display = "none", x.current = null, w.current = () => {
1081
1130
  }, () => {
1082
1131
  };
1083
1132
  }
1084
- const ae = () => {
1133
+ const he = () => {
1085
1134
  const o = K.getBoundingClientRect();
1086
- return He(o.width, o.height), o;
1087
- }, ze = () => {
1088
- ae(), Ee();
1089
- }, he = (o) => {
1090
- if (M.current || o.length === 0)
1135
+ return Ke(o.width, o.height), o;
1136
+ }, Se = () => {
1137
+ he(), Ee();
1138
+ }, de = (o) => {
1139
+ if (b.current || o.length === 0)
1091
1140
  return;
1092
- const u = P.current;
1093
- for (const Z of o)
1094
- u.push(Z);
1095
- u.length > Be && u.splice(0, u.length - Be);
1096
- const T = performance.now() + g.current.idleTimeout;
1097
- z.current = Math.max(z.current, T), N.current = Math.max(
1098
- N.current,
1099
- T + ut(g.current.damping)
1100
- ), U.current = 0, le();
1141
+ const l = P.current;
1142
+ for (const J of o)
1143
+ l.push(J);
1144
+ l.length > Ne && l.splice(0, l.length - Ne);
1145
+ const y = performance.now() + g.current.idleTimeout;
1146
+ z.current = Math.max(z.current, y), W.current = Math.max(
1147
+ W.current,
1148
+ y + dt(g.current.damping)
1149
+ ), D.current = 0, le();
1101
1150
  };
1102
- H.current = he;
1103
- const _e = (o) => {
1104
- const u = g.current;
1105
- if (B.current || M.current || !D.current || u.interactionMode === "event" || !u.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1151
+ H.current = de;
1152
+ const Te = (o) => {
1153
+ const l = g.current;
1154
+ if (B.current || b.current || !U.current || l.interactionMode === "event" || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1106
1155
  return;
1107
1156
  m.current.reset();
1108
- const F = ae(), [T] = De(o, F, performance.now());
1109
- T && ((u.interactionMode === "click" || u.interactionMode === "drag") && he(
1110
- Ce(
1157
+ const F = he(), [y] = Pe(o, F, performance.now());
1158
+ y && ((l.interactionMode === "click" || l.interactionMode === "drag") && de(
1159
+ We(
1111
1160
  {
1112
- x: T.x / $.current.width,
1113
- y: T.y / $.current.height
1161
+ x: y.x / Q.current.width,
1162
+ y: y.y / Q.current.height
1114
1163
  },
1115
- u,
1116
- $.current
1164
+ l,
1165
+ Q.current
1117
1166
  )
1118
- ), u.interactionMode === "drag" ? (I.current = o.pointerId, m.current.addSample(T)) : u.interactionMode === "move" && m.current.addSample(T));
1119
- }, Se = (o) => {
1120
- const u = g.current;
1121
- if (B.current || M.current || !D.current || u.interactionMode !== "move" && (u.interactionMode !== "drag" || I.current !== o.pointerId) || !u.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1167
+ ), l.interactionMode === "drag" ? (I.current = o.pointerId, m.current.addSample(y)) : l.interactionMode === "move" && m.current.addSample(y));
1168
+ }, ye = (o) => {
1169
+ const l = g.current;
1170
+ if (B.current || b.current || !U.current || l.interactionMode !== "move" && (l.interactionMode !== "drag" || I.current !== o.pointerId) || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
1122
1171
  return;
1123
- const F = ae(), T = De(o, F, performance.now());
1124
- for (const Z of T)
1125
- he(m.current.addSample(Z));
1126
- }, j = (o) => {
1172
+ const F = he(), y = Pe(o, F, performance.now());
1173
+ for (const J of y)
1174
+ de(m.current.addSample(J));
1175
+ }, Z = (o) => {
1127
1176
  I.current !== null && I.current !== o.pointerId || (I.current = null, m.current.reset());
1128
- }, Te = (o) => {
1129
- const u = g.current.pauseKey;
1130
- !u || o.code !== u || o.repeat || o.altKey || o.ctrlKey || o.metaKey || dt(o.target) || (o.preventDefault(), M.current = !M.current, M.current ? re() : (Y(), Q()));
1131
- }, ye = () => {
1132
- Y(), document.hidden && !g.current.runInBackground ? re() : Q();
1133
- }, Re = () => {
1134
- k.current = !1, g.current.runInBackground ? (Y(), Q()) : re();
1177
+ }, Re = (o) => {
1178
+ const l = g.current.pauseKey;
1179
+ !l || o.code !== l || o.repeat || o.altKey || o.ctrlKey || o.metaKey || gt(o.target) || (o.preventDefault(), b.current = !b.current, b.current ? ne() : (Y(), j()));
1135
1180
  }, we = () => {
1136
- k.current = !0, Y(), Q();
1137
- }, Ke = () => {
1138
- Y(), !g.current.runInBackground && (document.hidden || !k.current) ? re() : Q();
1181
+ Y(), document.hidden && !g.current.runInBackground ? ne() : j();
1182
+ }, be = () => {
1183
+ k.current = !1, g.current.runInBackground ? (Y(), j()) : ne();
1184
+ }, Me = () => {
1185
+ k.current = !0, Y(), j();
1186
+ }, Ye = () => {
1187
+ Y(), !g.current.runInBackground && (document.hidden || !k.current) ? ne() : j();
1139
1188
  };
1140
- W.current = Ke, ze();
1141
- const Me = new ResizeObserver(() => {
1142
- ae(), le();
1189
+ N.current = Ye, Se();
1190
+ const Ae = new ResizeObserver(() => {
1191
+ Se(), le();
1143
1192
  });
1144
- Me.observe(K);
1145
- let ne;
1146
- return "IntersectionObserver" in window && (ne = new IntersectionObserver((o) => {
1147
- const u = o[0];
1148
- D.current = u ? u.isIntersecting : !0, D.current ? Q() : re();
1149
- }), ne.observe(_)), _.addEventListener("pointerdown", _e, {
1193
+ Ae.observe(K);
1194
+ let ie;
1195
+ return "IntersectionObserver" in window && (ie = new IntersectionObserver((o) => {
1196
+ const l = o[0];
1197
+ U.current = l ? l.isIntersecting : !0, U.current ? j() : ne();
1198
+ }), ie.observe(S)), S.addEventListener("pointerdown", Te, {
1150
1199
  passive: !0
1151
- }), _.addEventListener("pointermove", Se, {
1200
+ }), S.addEventListener("pointermove", ye, {
1152
1201
  passive: !0
1153
- }), _.addEventListener("pointerup", j, {
1202
+ }), S.addEventListener("pointerup", Z, {
1154
1203
  passive: !0
1155
- }), _.addEventListener("pointerleave", j, {
1204
+ }), S.addEventListener("pointerleave", Z, {
1156
1205
  passive: !0
1157
- }), _.addEventListener("pointercancel", j, {
1206
+ }), S.addEventListener("pointercancel", Z, {
1158
1207
  passive: !0
1159
- }), window.addEventListener("blur", Re), window.addEventListener("focus", we), document.addEventListener("keydown", Te), document.addEventListener("visibilitychange", ye), () => {
1208
+ }), window.addEventListener("blur", be), window.addEventListener("focus", Me), document.addEventListener("keydown", Re), document.addEventListener("visibilitychange", we), () => {
1160
1209
  var o;
1161
- Y(), Me.disconnect(), ne == null || ne.disconnect(), _.removeEventListener("pointerdown", _e), _.removeEventListener("pointermove", Se), _.removeEventListener("pointerup", j), _.removeEventListener("pointerleave", j), _.removeEventListener("pointercancel", j), window.removeEventListener("blur", Re), window.removeEventListener("focus", we), document.removeEventListener("keydown", Te), document.removeEventListener("visibilitychange", ye), (o = p.current) == null || o.dispose(), p.current = null, w.current = () => {
1162
- }, W.current = () => {
1210
+ Y(), Ae.disconnect(), ie == null || ie.disconnect(), S.removeEventListener("pointerdown", Te), S.removeEventListener("pointermove", ye), S.removeEventListener("pointerup", Z), S.removeEventListener("pointerleave", Z), S.removeEventListener("pointercancel", Z), window.removeEventListener("blur", be), window.removeEventListener("focus", Me), document.removeEventListener("keydown", Re), document.removeEventListener("visibilitychange", we), (o = x.current) == null || o.dispose(), x.current = null, w.current = () => {
1211
+ }, N.current = () => {
1163
1212
  }, H.current = () => {
1164
1213
  };
1165
1214
  };
1166
- }, []), V(() => {
1215
+ }, []), q(() => {
1167
1216
  m.current.reset(), I.current = null;
1168
- }, [R.interactionMode]), V(() => {
1169
- W.current();
1170
- }, [R.runInBackground]), V(() => {
1171
- !R.pauseKey && M.current && (M.current = !1, W.current());
1172
- }, [R.pauseKey]);
1173
- const Ge = {
1174
- ...c,
1217
+ }, [T.interactionMode]), q(() => {
1218
+ N.current();
1219
+ }, [T.runInBackground]), q(() => {
1220
+ !T.pauseKey && b.current && (b.current = !1, N.current());
1221
+ }, [T.pauseKey]);
1222
+ const He = {
1223
+ ...u,
1175
1224
  position: "relative",
1176
1225
  overflow: "hidden",
1177
1226
  isolation: "isolate"
1178
1227
  };
1179
- return /* @__PURE__ */ qe("div", { ref: d, className: l, style: Ge, children: [
1180
- t ? /* @__PURE__ */ de(
1228
+ return /* @__PURE__ */ $e("div", { ref: h, className: s, style: He, children: [
1229
+ t ? /* @__PURE__ */ fe(
1181
1230
  "div",
1182
1231
  {
1183
1232
  style: {
@@ -1190,10 +1239,10 @@ const gt = $e(function(e, n) {
1190
1239
  children: t
1191
1240
  }
1192
1241
  ) : null,
1193
- /* @__PURE__ */ de(
1242
+ /* @__PURE__ */ fe(
1194
1243
  "canvas",
1195
1244
  {
1196
- ref: E,
1245
+ ref: v,
1197
1246
  "aria-hidden": "true",
1198
1247
  style: {
1199
1248
  position: "absolute",
@@ -1202,24 +1251,24 @@ const gt = $e(function(e, n) {
1202
1251
  width: "100%",
1203
1252
  height: "100%",
1204
1253
  pointerEvents: "none",
1205
- mixBlendMode: R.mode === "dom" ? "screen" : "normal"
1254
+ mixBlendMode: T.mode === "dom" ? "screen" : "normal"
1206
1255
  }
1207
1256
  }
1208
1257
  ),
1209
- /* @__PURE__ */ de(
1258
+ /* @__PURE__ */ fe(
1210
1259
  "div",
1211
1260
  {
1212
1261
  style: {
1213
1262
  position: "relative",
1214
1263
  zIndex: 2
1215
1264
  },
1216
- children: Xe
1265
+ children: Oe
1217
1266
  }
1218
1267
  )
1219
1268
  ] });
1220
- }), pt = gt;
1269
+ }), Tt = pt;
1221
1270
  export {
1222
- gt as WaterDistortion,
1223
- pt as WaterLayer
1271
+ pt as WaterDistortion,
1272
+ Tt as WaterLayer
1224
1273
  };
1225
1274
  //# sourceMappingURL=water-distortion.js.map