@factorialco/f0-react 1.413.0 → 1.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{F0AiChat-C58IuYYg.js → F0AiChat-CBy7rZCW.js} +5436 -5100
- package/dist/F0AnalyticsDashboard-Doa70ufI.js +54136 -0
- package/dist/F0AnalyticsDashboard.css +1 -1
- package/dist/F0ChatDashboard.d.ts +6 -6
- package/dist/F0ChatDashboard.js +290 -2
- package/dist/{F0HILActionConfirmation-CasXGy89.js → F0HILActionConfirmation-BvAjbJKj.js} +382 -370
- package/dist/{F0Input-JjjfHKNJ.js → F0Input-C9w04Jpr.js} +92 -93
- package/dist/ai.d.ts +101 -35
- package/dist/ai.js +43 -41
- package/dist/experimental.d.ts +12 -6
- package/dist/experimental.js +1902 -1998
- package/dist/f0.d.ts +101 -35
- package/dist/f0.js +250 -247
- package/dist/i18n-provider-defaults.d.ts +12 -6
- package/dist/i18n-provider-defaults.js +6 -0
- package/dist/{index-DuS_uOqo.js → index-C0vtKpW9.js} +3 -3
- package/dist/styles.css +1 -1
- package/dist/useDataCollectionSource-CzKsWqw5.js +10111 -0
- package/dist/useDataCollectionSource.css +1 -0
- package/package.json +1 -1
- package/dist/F0AnalyticsDashboard-HOK1Grhk.js +0 -64242
- package/dist/F0ChatDashboard-e_oKQtbl.js +0 -292
|
@@ -1,88 +1,89 @@
|
|
|
1
1
|
import { jsx as q, jsxs as le } from "react/jsx-runtime";
|
|
2
|
-
import { useInsertionEffect as ze, createContext as
|
|
3
|
-
import { r as He, i as je, m as Ke, a as Qe, b as Me, d as Je, c as Ze, f as et, e as tt, s as
|
|
2
|
+
import { useInsertionEffect as ze, createContext as Ye, useContext as Xe, useRef as B, useEffect as ie, useState as Ue, useCallback as $e, useMemo as qe } from "react";
|
|
3
|
+
import { r as He, i as je, m as Ke, a as Qe, b as Me, d as Je, c as Ze, f as et, e as tt, s as rt, g as Oe, p as nt, V as ot, h as it, j as st, k as at, S as ct, H as ut, v as se, l as lt, n as ft, o as ht, q as dt, t as mt, w as pt, F as fe, x as vt } from "./F0Input-C9w04Jpr.js";
|
|
4
4
|
import { useTrackVolume as gt } from "@livekit/components-react";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { G as wt } from "./F0AiChat-CBy7rZCW.js";
|
|
6
|
+
function yt(t, e, r) {
|
|
7
|
+
ze(() => t.on(e, r), [t, e, r]);
|
|
7
8
|
}
|
|
8
9
|
function ue(t) {
|
|
9
10
|
return typeof t == "object" && !Array.isArray(t);
|
|
10
11
|
}
|
|
11
|
-
function Ne(t, e,
|
|
12
|
-
return typeof t == "string" && ue(e) ? He(t,
|
|
12
|
+
function Ne(t, e, r, n) {
|
|
13
|
+
return typeof t == "string" && ue(e) ? He(t, r, n) : t instanceof NodeList ? Array.from(t) : Array.isArray(t) ? t : [t];
|
|
13
14
|
}
|
|
14
|
-
function Tt(t, e,
|
|
15
|
+
function Tt(t, e, r) {
|
|
15
16
|
return t * (e + 1);
|
|
16
17
|
}
|
|
17
|
-
function he(t, e,
|
|
18
|
-
return typeof e == "number" ? e : e.startsWith("-") || e.startsWith("+") ? Math.max(0, t + parseFloat(e)) : e === "<" ?
|
|
18
|
+
function he(t, e, r, n) {
|
|
19
|
+
return typeof e == "number" ? e : e.startsWith("-") || e.startsWith("+") ? Math.max(0, t + parseFloat(e)) : e === "<" ? r : n.get(e) ?? t;
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
return ((
|
|
21
|
+
const bt = (t, e, r) => {
|
|
22
|
+
const n = e - t;
|
|
23
|
+
return ((r - t) % n + n) % n + t;
|
|
23
24
|
};
|
|
24
25
|
function Be(t, e) {
|
|
25
|
-
return je(t) ? t[
|
|
26
|
+
return je(t) ? t[bt(0, t.length, e)] : t;
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
for (let
|
|
29
|
-
const o = t[
|
|
30
|
-
o.at > e && o.at <
|
|
28
|
+
function Et(t, e, r) {
|
|
29
|
+
for (let n = 0; n < t.length; n++) {
|
|
30
|
+
const o = t[n];
|
|
31
|
+
o.at > e && o.at < r && (Qe(t, o), n--);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
34
|
+
function At(t, e, r, n, o, c) {
|
|
35
|
+
Et(t, o, c);
|
|
35
36
|
for (let m = 0; m < e.length; m++)
|
|
36
37
|
t.push({
|
|
37
38
|
value: e[m],
|
|
38
|
-
at: Ke(o, c,
|
|
39
|
-
easing: Be(
|
|
39
|
+
at: Ke(o, c, n[m]),
|
|
40
|
+
easing: Be(r, m)
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
function At(t, e) {
|
|
43
|
-
for (let n = 0; n < t.length; n++)
|
|
44
|
-
t[n] = t[n] / (e + 1);
|
|
45
|
-
}
|
|
46
43
|
function Rt(t, e) {
|
|
44
|
+
for (let r = 0; r < t.length; r++)
|
|
45
|
+
t[r] = t[r] / (e + 1);
|
|
46
|
+
}
|
|
47
|
+
function xt(t, e) {
|
|
47
48
|
return t.at === e.at ? t.value === null ? 1 : e.value === null ? -1 : 0 : t.at - e.at;
|
|
48
49
|
}
|
|
49
|
-
const
|
|
50
|
-
function
|
|
50
|
+
const St = "easeInOut", Lt = 20;
|
|
51
|
+
function Ct(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
51
52
|
const c = e.duration || 0.3, m = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), v = {}, R = /* @__PURE__ */ new Map();
|
|
52
53
|
let p = 0, g = 0, x = 0;
|
|
53
54
|
for (let l = 0; l < t.length; l++) {
|
|
54
|
-
const
|
|
55
|
-
if (typeof
|
|
56
|
-
R.set(
|
|
55
|
+
const y = t[l];
|
|
56
|
+
if (typeof y == "string") {
|
|
57
|
+
R.set(y, g);
|
|
57
58
|
continue;
|
|
58
|
-
} else if (!Array.isArray(
|
|
59
|
-
R.set(
|
|
59
|
+
} else if (!Array.isArray(y)) {
|
|
60
|
+
R.set(y.name, he(g, y.at, p, R));
|
|
60
61
|
continue;
|
|
61
62
|
}
|
|
62
|
-
let [F, d, S = {}] =
|
|
63
|
+
let [F, d, S = {}] = y;
|
|
63
64
|
S.at !== void 0 && (g = he(g, S.at, p, R));
|
|
64
65
|
let C = 0;
|
|
65
|
-
const U = (
|
|
66
|
-
const A =
|
|
66
|
+
const U = (T, w, I, P = 0, D = 0) => {
|
|
67
|
+
const A = It(T), { delay: f = 0, times: _ = Je(A), type: N = "keyframes", repeat: W, repeatType: k, repeatDelay: H = 0, ...z } = w;
|
|
67
68
|
let { ease: M = e.ease || "easeOut", duration: L } = w;
|
|
68
69
|
const O = typeof f == "function" ? f(P, D) : f, j = A.length, Z = tt(N) ? N : o?.[N];
|
|
69
70
|
if (j <= 2 && Z) {
|
|
70
71
|
let K = 100;
|
|
71
|
-
if (j === 2 &&
|
|
72
|
+
if (j === 2 && Pt(A)) {
|
|
72
73
|
const J = A[1] - A[0];
|
|
73
74
|
K = Math.abs(J);
|
|
74
75
|
}
|
|
75
76
|
const Q = { ...z };
|
|
76
|
-
L !== void 0 && (Q.duration =
|
|
77
|
+
L !== void 0 && (Q.duration = rt(L));
|
|
77
78
|
const ee = Ze(Q, K, Z);
|
|
78
79
|
M = ee.ease, L = ee.duration;
|
|
79
80
|
}
|
|
80
81
|
L ?? (L = c);
|
|
81
82
|
const $ = g + O;
|
|
82
83
|
_.length === 1 && _[0] === 0 && (_[1] = 1);
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
Oe(W <
|
|
84
|
+
const re = _.length - A.length;
|
|
85
|
+
if (re > 0 && et(_, re), A.length === 1 && A.unshift(null), W) {
|
|
86
|
+
Oe(W < Lt, "Repeat count too high, must be less than 20"), L = Tt(L, W);
|
|
86
87
|
const K = [...A], Q = [..._];
|
|
87
88
|
M = Array.isArray(M) ? [...M] : [M];
|
|
88
89
|
const ee = [...M];
|
|
@@ -91,45 +92,45 @@ function Lt(t, { defaultTransition: e = {}, ...n } = {}, r, o) {
|
|
|
91
92
|
for (let i = 0; i < K.length; i++)
|
|
92
93
|
_.push(Q[i] + (J + 1)), M.push(i === 0 ? "linear" : Be(ee, i - 1));
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
+
Rt(_, W);
|
|
95
96
|
}
|
|
96
|
-
const
|
|
97
|
-
|
|
97
|
+
const ne = $ + L;
|
|
98
|
+
At(I, A, M, _, $, ne), C = Math.max(O + L, C), x = Math.max(ne, x);
|
|
98
99
|
};
|
|
99
100
|
if (Me(F)) {
|
|
100
|
-
const
|
|
101
|
-
U(d, S, me("default",
|
|
101
|
+
const T = de(F, b);
|
|
102
|
+
U(d, S, me("default", T));
|
|
102
103
|
} else {
|
|
103
|
-
const
|
|
104
|
+
const T = Ne(F, d, n, v), w = T.length;
|
|
104
105
|
for (let I = 0; I < w; I++) {
|
|
105
106
|
d = d, S = S;
|
|
106
|
-
const P =
|
|
107
|
+
const P = T[I], D = de(P, b);
|
|
107
108
|
for (const A in d)
|
|
108
|
-
U(d[A],
|
|
109
|
+
U(d[A], _t(S, A), me(A, D), I, w);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
p = g, g += C;
|
|
112
113
|
}
|
|
113
|
-
return b.forEach((l,
|
|
114
|
+
return b.forEach((l, y) => {
|
|
114
115
|
for (const F in l) {
|
|
115
116
|
const d = l[F];
|
|
116
|
-
d.sort(
|
|
117
|
+
d.sort(xt);
|
|
117
118
|
const S = [], C = [], U = [];
|
|
118
119
|
for (let w = 0; w < d.length; w++) {
|
|
119
120
|
const { at: I, value: P, easing: D } = d[w];
|
|
120
|
-
S.push(P), C.push(
|
|
121
|
+
S.push(P), C.push(nt(0, x, I)), U.push(D || "easeOut");
|
|
121
122
|
}
|
|
122
|
-
C[0] !== 0 && (C.unshift(0), S.unshift(S[0]), U.unshift(
|
|
123
|
+
C[0] !== 0 && (C.unshift(0), S.unshift(S[0]), U.unshift(St)), C[C.length - 1] !== 1 && (C.push(1), S.push(null)), m.has(y) || m.set(y, {
|
|
123
124
|
keyframes: {},
|
|
124
125
|
transition: {}
|
|
125
126
|
});
|
|
126
|
-
const
|
|
127
|
-
|
|
127
|
+
const T = m.get(y);
|
|
128
|
+
T.keyframes[F] = S, T.transition[F] = {
|
|
128
129
|
...e,
|
|
129
130
|
duration: x,
|
|
130
131
|
ease: U,
|
|
131
132
|
times: C,
|
|
132
|
-
...
|
|
133
|
+
...r
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
136
|
}), m;
|
|
@@ -140,49 +141,49 @@ function de(t, e) {
|
|
|
140
141
|
function me(t, e) {
|
|
141
142
|
return e[t] || (e[t] = []), e[t];
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
+
function It(t) {
|
|
144
145
|
return Array.isArray(t) ? t : [t];
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function _t(t, e) {
|
|
147
148
|
return t && t[e] ? {
|
|
148
149
|
...t,
|
|
149
150
|
...t[e]
|
|
150
151
|
} : { ...t };
|
|
151
152
|
}
|
|
152
|
-
const
|
|
153
|
-
function
|
|
153
|
+
const Ft = (t) => typeof t == "number", Pt = (t) => t.every(Ft);
|
|
154
|
+
function Ut(t, e) {
|
|
154
155
|
return t in e;
|
|
155
156
|
}
|
|
156
|
-
class
|
|
157
|
+
class Mt extends ot {
|
|
157
158
|
constructor() {
|
|
158
159
|
super(...arguments), this.type = "object";
|
|
159
160
|
}
|
|
160
|
-
readValueFromInstance(e,
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
if (typeof
|
|
164
|
-
return
|
|
161
|
+
readValueFromInstance(e, r) {
|
|
162
|
+
if (Ut(r, e)) {
|
|
163
|
+
const n = e[r];
|
|
164
|
+
if (typeof n == "string" || typeof n == "number")
|
|
165
|
+
return n;
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
getBaseTargetFromProps() {
|
|
168
169
|
}
|
|
169
|
-
removeValueFromRenderState(e,
|
|
170
|
-
delete
|
|
170
|
+
removeValueFromRenderState(e, r) {
|
|
171
|
+
delete r.output[e];
|
|
171
172
|
}
|
|
172
173
|
measureInstanceViewportBox() {
|
|
173
174
|
return it();
|
|
174
175
|
}
|
|
175
|
-
build(e,
|
|
176
|
-
Object.assign(e.output,
|
|
176
|
+
build(e, r) {
|
|
177
|
+
Object.assign(e.output, r);
|
|
177
178
|
}
|
|
178
|
-
renderInstance(e, { output:
|
|
179
|
-
Object.assign(e,
|
|
179
|
+
renderInstance(e, { output: r }) {
|
|
180
|
+
Object.assign(e, r);
|
|
180
181
|
}
|
|
181
182
|
sortInstanceNodePosition() {
|
|
182
183
|
return 0;
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function Ot(t) {
|
|
186
187
|
const e = {
|
|
187
188
|
presenceContext: null,
|
|
188
189
|
props: {},
|
|
@@ -196,10 +197,10 @@ function Mt(t) {
|
|
|
196
197
|
},
|
|
197
198
|
latestValues: {}
|
|
198
199
|
}
|
|
199
|
-
},
|
|
200
|
-
|
|
200
|
+
}, r = st(t) && !at(t) ? new ct(e) : new ut(e);
|
|
201
|
+
r.mount(t), se.set(t, r);
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function Nt(t) {
|
|
203
204
|
const e = {
|
|
204
205
|
presenceContext: null,
|
|
205
206
|
props: {},
|
|
@@ -209,35 +210,35 @@ function Ot(t) {
|
|
|
209
210
|
},
|
|
210
211
|
latestValues: {}
|
|
211
212
|
}
|
|
212
|
-
},
|
|
213
|
-
|
|
213
|
+
}, r = new Mt(e);
|
|
214
|
+
r.mount(t), se.set(t, r);
|
|
214
215
|
}
|
|
215
|
-
function
|
|
216
|
+
function Bt(t, e) {
|
|
216
217
|
return Me(t) || typeof t == "number" || typeof t == "string" && !ue(e);
|
|
217
218
|
}
|
|
218
|
-
function De(t, e,
|
|
219
|
+
function De(t, e, r, n) {
|
|
219
220
|
const o = [];
|
|
220
|
-
if (
|
|
221
|
-
o.push(lt(t, ue(e) && e.default || e,
|
|
221
|
+
if (Bt(t, e))
|
|
222
|
+
o.push(lt(t, ue(e) && e.default || e, r && (r.default || r)));
|
|
222
223
|
else {
|
|
223
|
-
const c = Ne(t, e,
|
|
224
|
+
const c = Ne(t, e, n), m = c.length;
|
|
224
225
|
Oe(!!m, "No valid elements provided.");
|
|
225
226
|
for (let b = 0; b < m; b++) {
|
|
226
|
-
const v = c[b], R = v instanceof Element ?
|
|
227
|
+
const v = c[b], R = v instanceof Element ? Ot : Nt;
|
|
227
228
|
se.has(v) || R(v);
|
|
228
|
-
const p = se.get(v), g = { ...
|
|
229
|
+
const p = se.get(v), g = { ...r };
|
|
229
230
|
"delay" in g && typeof g.delay == "function" && (g.delay = g.delay(b, m)), o.push(...ft(p, { ...e, transition: g }, {}));
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
return o;
|
|
233
234
|
}
|
|
234
|
-
function
|
|
235
|
-
const
|
|
236
|
-
return
|
|
237
|
-
|
|
238
|
-
}),
|
|
235
|
+
function Dt(t, e, r) {
|
|
236
|
+
const n = [];
|
|
237
|
+
return Ct(t, e, r, { spring: ht }).forEach(({ keyframes: c, transition: m }, b) => {
|
|
238
|
+
n.push(...De(b, c, m));
|
|
239
|
+
}), n;
|
|
239
240
|
}
|
|
240
|
-
class
|
|
241
|
+
class Vt {
|
|
241
242
|
constructor(e) {
|
|
242
243
|
this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
|
|
243
244
|
}
|
|
@@ -250,15 +251,15 @@ class Dt {
|
|
|
250
251
|
getAll(e) {
|
|
251
252
|
return this.animations[0][e];
|
|
252
253
|
}
|
|
253
|
-
setAll(e,
|
|
254
|
-
for (let
|
|
255
|
-
this.animations[
|
|
254
|
+
setAll(e, r) {
|
|
255
|
+
for (let n = 0; n < this.animations.length; n++)
|
|
256
|
+
this.animations[n][e] = r;
|
|
256
257
|
}
|
|
257
258
|
attachTimeline(e) {
|
|
258
|
-
const
|
|
259
|
+
const r = this.animations.map((n) => n.attachTimeline(e));
|
|
259
260
|
return () => {
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
r.forEach((n, o) => {
|
|
262
|
+
n && n(), this.animations[o].stop();
|
|
262
263
|
});
|
|
263
264
|
};
|
|
264
265
|
}
|
|
@@ -282,12 +283,12 @@ class Dt {
|
|
|
282
283
|
}
|
|
283
284
|
get duration() {
|
|
284
285
|
let e = 0;
|
|
285
|
-
for (let
|
|
286
|
-
e = Math.max(e, this.animations[
|
|
286
|
+
for (let r = 0; r < this.animations.length; r++)
|
|
287
|
+
e = Math.max(e, this.animations[r].duration);
|
|
287
288
|
return e;
|
|
288
289
|
}
|
|
289
290
|
runAll(e) {
|
|
290
|
-
this.animations.forEach((
|
|
291
|
+
this.animations.forEach((r) => r[e]());
|
|
291
292
|
}
|
|
292
293
|
play() {
|
|
293
294
|
this.runAll("play");
|
|
@@ -302,27 +303,27 @@ class Dt {
|
|
|
302
303
|
this.runAll("complete");
|
|
303
304
|
}
|
|
304
305
|
}
|
|
305
|
-
class
|
|
306
|
-
then(e,
|
|
306
|
+
class Gt extends Vt {
|
|
307
|
+
then(e, r) {
|
|
307
308
|
return this.finished.finally(e).then(() => {
|
|
308
309
|
});
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
|
-
function
|
|
312
|
+
function kt(t) {
|
|
312
313
|
return Array.isArray(t) && t.some(Array.isArray);
|
|
313
314
|
}
|
|
314
|
-
function
|
|
315
|
-
function e(
|
|
315
|
+
function Wt(t) {
|
|
316
|
+
function e(r, n, o) {
|
|
316
317
|
let c = [];
|
|
317
|
-
return
|
|
318
|
+
return kt(r) ? c = Dt(r, n, t) : c = De(r, n, o, t), new Gt(c);
|
|
318
319
|
}
|
|
319
320
|
return e;
|
|
320
321
|
}
|
|
321
|
-
const
|
|
322
|
+
const zt = Wt(), Er = ["xs", "sm", "md", "lg"], Ar = [
|
|
322
323
|
"inProgress",
|
|
323
324
|
"executing",
|
|
324
325
|
"completed"
|
|
325
|
-
],
|
|
326
|
+
], Rr = {
|
|
326
327
|
ai: {
|
|
327
328
|
openChat: "Open Chat with One AI",
|
|
328
329
|
closeChat: "Close Chat with One AI",
|
|
@@ -378,61 +379,67 @@ const Wt = kt(), yn = ["xs", "sm", "md", "lg"], bn = [
|
|
|
378
379
|
dataDownload: {
|
|
379
380
|
download: "Download {{format}}"
|
|
380
381
|
},
|
|
382
|
+
pong: {
|
|
383
|
+
ai: "AI",
|
|
384
|
+
you: "YOU",
|
|
385
|
+
youWin: "You win!",
|
|
386
|
+
youLose: "You lose!"
|
|
387
|
+
},
|
|
381
388
|
unsavedChanges: "Unsaved changes",
|
|
382
389
|
saveChanges: "Save changes",
|
|
383
390
|
discardChanges: "Discard"
|
|
384
391
|
}
|
|
385
|
-
}, Ve =
|
|
386
|
-
function
|
|
392
|
+
}, Ve = Ye(null);
|
|
393
|
+
function xr({
|
|
387
394
|
children: t,
|
|
388
395
|
translations: e
|
|
389
396
|
}) {
|
|
390
397
|
return /* @__PURE__ */ q(Ve.Provider, { value: e, children: t });
|
|
391
398
|
}
|
|
392
|
-
function
|
|
393
|
-
const t =
|
|
399
|
+
function Sr() {
|
|
400
|
+
const t = Xe(Ve);
|
|
394
401
|
if (t === null)
|
|
395
402
|
throw new Error(
|
|
396
403
|
"useAiChatTranslations must be used within an AiChatTranslationsProvider"
|
|
397
404
|
);
|
|
398
405
|
return t;
|
|
399
406
|
}
|
|
400
|
-
function pe(t, e,
|
|
401
|
-
const o = Math.max(1, Math.min(t, e)), c = Math.min(
|
|
407
|
+
function pe(t, e, r, n) {
|
|
408
|
+
const o = Math.max(1, Math.min(t, e)), c = Math.min(r, 20), b = Math.min(c + n, o), v = Math.min(b, Math.floor(t / 2)), R = Math.min(b, Math.floor(e / 2)), p = ($) => $ / t * 2 - 1, g = ($) => $ / e * 2 - 1, x = 0, l = t, y = 0, F = e, d = v, S = t - v, C = R, U = e - R, T = p(x), w = p(l), I = g(y), P = g(F), D = p(d), A = p(S), f = g(C), _ = g(U), N = 0, W = 0, k = 1, H = 1, z = v / t, M = 1 - v / t, L = R / e, O = 1 - R / e, j = new Float32Array([
|
|
402
409
|
// Top strip
|
|
403
|
-
|
|
410
|
+
T,
|
|
404
411
|
I,
|
|
405
412
|
w,
|
|
406
413
|
I,
|
|
407
|
-
|
|
414
|
+
T,
|
|
408
415
|
f,
|
|
409
|
-
|
|
416
|
+
T,
|
|
410
417
|
f,
|
|
411
418
|
w,
|
|
412
419
|
I,
|
|
413
420
|
w,
|
|
414
421
|
f,
|
|
415
422
|
// Bottom strip
|
|
416
|
-
|
|
423
|
+
T,
|
|
417
424
|
_,
|
|
418
425
|
w,
|
|
419
426
|
_,
|
|
420
|
-
|
|
427
|
+
T,
|
|
421
428
|
P,
|
|
422
|
-
|
|
429
|
+
T,
|
|
423
430
|
P,
|
|
424
431
|
w,
|
|
425
432
|
_,
|
|
426
433
|
w,
|
|
427
434
|
P,
|
|
428
435
|
// Left strip
|
|
429
|
-
|
|
436
|
+
T,
|
|
430
437
|
f,
|
|
431
438
|
D,
|
|
432
439
|
f,
|
|
433
|
-
|
|
440
|
+
T,
|
|
434
441
|
_,
|
|
435
|
-
|
|
442
|
+
T,
|
|
436
443
|
_,
|
|
437
444
|
D,
|
|
438
445
|
f,
|
|
@@ -507,23 +514,23 @@ function pe(t, e, n, r) {
|
|
|
507
514
|
]);
|
|
508
515
|
return { positions: j, uvs: Z };
|
|
509
516
|
}
|
|
510
|
-
function ve(t, e,
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
513
|
-
if (t.shaderSource(
|
|
514
|
-
const o = t.getShaderInfoLog(
|
|
515
|
-
throw t.deleteShader(
|
|
517
|
+
function ve(t, e, r) {
|
|
518
|
+
const n = t.createShader(e);
|
|
519
|
+
if (!n) throw new Error("Failed to create shader");
|
|
520
|
+
if (t.shaderSource(n, r), t.compileShader(n), !t.getShaderParameter(n, t.COMPILE_STATUS)) {
|
|
521
|
+
const o = t.getShaderInfoLog(n) || "Unknown shader error";
|
|
522
|
+
throw t.deleteShader(n), new Error(o);
|
|
516
523
|
}
|
|
517
|
-
return
|
|
524
|
+
return n;
|
|
518
525
|
}
|
|
519
|
-
function
|
|
520
|
-
const
|
|
526
|
+
function Yt(t, e, r) {
|
|
527
|
+
const n = ve(t, t.VERTEX_SHADER, e), o = ve(t, t.FRAGMENT_SHADER, r), c = t.createProgram();
|
|
521
528
|
if (!c) throw new Error("Failed to create program");
|
|
522
|
-
if (t.attachShader(c,
|
|
529
|
+
if (t.attachShader(c, n), t.attachShader(c, o), t.linkProgram(c), !t.getProgramParameter(c, t.LINK_STATUS)) {
|
|
523
530
|
const m = t.getProgramInfoLog(c) || "Unknown link error";
|
|
524
|
-
throw t.deleteProgram(c), t.deleteShader(
|
|
531
|
+
throw t.deleteProgram(c), t.deleteShader(n), t.deleteShader(o), new Error(m);
|
|
525
532
|
}
|
|
526
|
-
return t.deleteShader(
|
|
533
|
+
return t.deleteShader(n), t.deleteShader(o), c;
|
|
527
534
|
}
|
|
528
535
|
const Xt = `#version 300 es
|
|
529
536
|
precision lowp float;
|
|
@@ -731,7 +738,8 @@ void main() {
|
|
|
731
738
|
float alpha = mix(glow, 1.0, border);
|
|
732
739
|
|
|
733
740
|
outColor = vec4(color, alpha);
|
|
734
|
-
}
|
|
741
|
+
}
|
|
742
|
+
`, $t = `#version 300 es
|
|
735
743
|
|
|
736
744
|
in vec2 aPosition;
|
|
737
745
|
in vec2 aUV;
|
|
@@ -739,7 +747,8 @@ out vec2 vUV;
|
|
|
739
747
|
void main() {
|
|
740
748
|
vUV = aUV;
|
|
741
749
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
742
|
-
}
|
|
750
|
+
}
|
|
751
|
+
`, qt = [
|
|
743
752
|
"rgb(229, 25, 67)",
|
|
744
753
|
// #E51943 red
|
|
745
754
|
"rgb(229, 86, 25)",
|
|
@@ -749,14 +758,14 @@ void main() {
|
|
|
749
758
|
"rgb(161, 173, 229)"
|
|
750
759
|
// #A1ADE5 light blue
|
|
751
760
|
];
|
|
752
|
-
function
|
|
761
|
+
function Ht(t) {
|
|
753
762
|
const e = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
754
763
|
if (!e)
|
|
755
764
|
throw new Error(`Invalid color format: ${t}`);
|
|
756
|
-
const [,
|
|
757
|
-
return [parseInt(
|
|
765
|
+
const [, r, n, o] = e;
|
|
766
|
+
return [parseInt(r) / 255, parseInt(n) / 255, parseInt(o) / 255];
|
|
758
767
|
}
|
|
759
|
-
class
|
|
768
|
+
class Lr {
|
|
760
769
|
element;
|
|
761
770
|
canvas;
|
|
762
771
|
options;
|
|
@@ -798,10 +807,10 @@ class xn {
|
|
|
798
807
|
const e = () => {
|
|
799
808
|
if (!this.running || !this.glr) return;
|
|
800
809
|
this.rafId = requestAnimationFrame(e);
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
this.lastTime =
|
|
804
|
-
const o = (
|
|
810
|
+
const r = performance.now();
|
|
811
|
+
if (r - this.lastTime < 1e3 / 32) return;
|
|
812
|
+
this.lastTime = r;
|
|
813
|
+
const o = (r - this.startTime) * 1e-3;
|
|
805
814
|
this.render(o);
|
|
806
815
|
};
|
|
807
816
|
this.rafId = requestAnimationFrame(e);
|
|
@@ -813,15 +822,15 @@ class xn {
|
|
|
813
822
|
dispose() {
|
|
814
823
|
if (this.disposed) return;
|
|
815
824
|
this.disposed = !0, this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
|
|
816
|
-
const { gl: e, vao:
|
|
817
|
-
|
|
825
|
+
const { gl: e, vao: r, positionBuffer: n, uvBuffer: o, program: c } = this.glr;
|
|
826
|
+
r && e.deleteVertexArray(r), n && e.deleteBuffer(n), o && e.deleteBuffer(o), e.deleteProgram(c), this.observer && this.observer.disconnect(), this.canvas.remove();
|
|
818
827
|
}
|
|
819
|
-
resize(e,
|
|
828
|
+
resize(e, r, n) {
|
|
820
829
|
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
821
|
-
if (this.options.width = e, this.options.height =
|
|
822
|
-
const { gl: o, program: c, vao: m, positionBuffer: b, uvBuffer: v, uResolution: R } = this.glr, p =
|
|
823
|
-
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${
|
|
824
|
-
const { positions: l, uvs:
|
|
830
|
+
if (this.options.width = e, this.options.height = r, n && (this.options.ratio = n), !this.running) return;
|
|
831
|
+
const { gl: o, program: c, vao: m, positionBuffer: b, uvBuffer: v, uResolution: R } = this.glr, p = n ?? this.options.ratio ?? window.devicePixelRatio ?? 1, g = Math.max(1, Math.floor(e * p)), x = Math.max(1, Math.floor(r * p));
|
|
832
|
+
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${r}px`, (this.canvas.width !== g || this.canvas.height !== x) && (this.canvas.width = g, this.canvas.height = x), o.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(o, "resize: after viewport setup");
|
|
833
|
+
const { positions: l, uvs: y } = pe(
|
|
825
834
|
this.canvas.width,
|
|
826
835
|
this.canvas.height,
|
|
827
836
|
this.options.borderWidth * p,
|
|
@@ -829,7 +838,7 @@ class xn {
|
|
|
829
838
|
);
|
|
830
839
|
o.bindVertexArray(m), o.bindBuffer(o.ARRAY_BUFFER, b), o.bufferData(o.ARRAY_BUFFER, l, o.STATIC_DRAW);
|
|
831
840
|
const F = o.getAttribLocation(c, "aPosition");
|
|
832
|
-
o.enableVertexAttribArray(F), o.vertexAttribPointer(F, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after position buffer update"), o.bindBuffer(o.ARRAY_BUFFER, v), o.bufferData(o.ARRAY_BUFFER,
|
|
841
|
+
o.enableVertexAttribArray(F), o.vertexAttribPointer(F, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after position buffer update"), o.bindBuffer(o.ARRAY_BUFFER, v), o.bufferData(o.ARRAY_BUFFER, y, o.STATIC_DRAW);
|
|
833
842
|
const d = o.getAttribLocation(c, "aUV");
|
|
834
843
|
o.enableVertexAttribArray(d), o.vertexAttribPointer(d, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after UV buffer update"), o.useProgram(c), o.uniform2f(R, this.canvas.width, this.canvas.height), o.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * p), o.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * p), o.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * p), this.checkGLError(o, "resize: after uniform updates");
|
|
835
844
|
const S = performance.now();
|
|
@@ -843,46 +852,46 @@ class xn {
|
|
|
843
852
|
*/
|
|
844
853
|
autoResize(e) {
|
|
845
854
|
this.observer && this.observer.disconnect(), this.observer = new ResizeObserver(() => {
|
|
846
|
-
const
|
|
847
|
-
this.resize(
|
|
855
|
+
const r = e.getBoundingClientRect();
|
|
856
|
+
this.resize(r.width, r.height);
|
|
848
857
|
}), this.observer.observe(e);
|
|
849
858
|
}
|
|
850
859
|
fadeIn() {
|
|
851
860
|
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
852
|
-
return new Promise((e,
|
|
853
|
-
const
|
|
861
|
+
return new Promise((e, r) => {
|
|
862
|
+
const n = this.canvas.animate(
|
|
854
863
|
[
|
|
855
864
|
{ opacity: 0, transform: "scale(1.2)" },
|
|
856
865
|
{ opacity: 1, transform: "scale(1)" }
|
|
857
866
|
],
|
|
858
867
|
{ duration: 300, easing: "ease-out", fill: "forwards" }
|
|
859
868
|
);
|
|
860
|
-
|
|
869
|
+
n.onfinish = () => e(), n.oncancel = () => r("canceled");
|
|
861
870
|
});
|
|
862
871
|
}
|
|
863
872
|
fadeOut() {
|
|
864
873
|
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
865
|
-
return new Promise((e,
|
|
866
|
-
const
|
|
874
|
+
return new Promise((e, r) => {
|
|
875
|
+
const n = this.canvas.animate(
|
|
867
876
|
[
|
|
868
877
|
{ opacity: 1, transform: "scale(1)" },
|
|
869
878
|
{ opacity: 0, transform: "scale(1.2)" }
|
|
870
879
|
],
|
|
871
880
|
{ duration: 300, easing: "ease-in", fill: "forwards" }
|
|
872
881
|
);
|
|
873
|
-
|
|
882
|
+
n.onfinish = () => e(), n.oncancel = () => r("canceled");
|
|
874
883
|
});
|
|
875
884
|
}
|
|
876
|
-
checkGLError(e,
|
|
877
|
-
let
|
|
878
|
-
if (
|
|
879
|
-
for (console.error(`WebGL Error in ${
|
|
880
|
-
const o = this.getGLErrorName(e,
|
|
881
|
-
console.error(`${o} (0x${
|
|
885
|
+
checkGLError(e, r) {
|
|
886
|
+
let n = e.getError();
|
|
887
|
+
if (n !== e.NO_ERROR)
|
|
888
|
+
for (console.error(`WebGL Error in ${r}`); n !== e.NO_ERROR; ) {
|
|
889
|
+
const o = this.getGLErrorName(e, n);
|
|
890
|
+
console.error(`${o} (0x${n.toString(16)})`), n = e.getError();
|
|
882
891
|
}
|
|
883
892
|
}
|
|
884
|
-
getGLErrorName(e,
|
|
885
|
-
switch (
|
|
893
|
+
getGLErrorName(e, r) {
|
|
894
|
+
switch (r) {
|
|
886
895
|
case e.INVALID_ENUM:
|
|
887
896
|
return "INVALID_ENUM";
|
|
888
897
|
case e.INVALID_VALUE:
|
|
@@ -906,10 +915,10 @@ class xn {
|
|
|
906
915
|
});
|
|
907
916
|
if (!e)
|
|
908
917
|
throw new Error("WebGL2 is required but not available.");
|
|
909
|
-
const
|
|
918
|
+
const r = Yt(e, $t, Xt);
|
|
910
919
|
this.checkGLError(e, "setupGL: after createProgram");
|
|
911
|
-
const
|
|
912
|
-
e.bindVertexArray(
|
|
920
|
+
const n = e.createVertexArray();
|
|
921
|
+
e.bindVertexArray(n), this.checkGLError(e, "setupGL: after VAO creation");
|
|
913
922
|
const o = this.canvas.width || 2, c = this.canvas.height || 2, { positions: m, uvs: b } = pe(
|
|
914
923
|
o,
|
|
915
924
|
c,
|
|
@@ -917,29 +926,29 @@ class xn {
|
|
|
917
926
|
this.options.glowWidth
|
|
918
927
|
), v = e.createBuffer();
|
|
919
928
|
e.bindBuffer(e.ARRAY_BUFFER, v), e.bufferData(e.ARRAY_BUFFER, m, e.STATIC_DRAW);
|
|
920
|
-
const R = e.getAttribLocation(
|
|
929
|
+
const R = e.getAttribLocation(r, "aPosition");
|
|
921
930
|
e.enableVertexAttribArray(R), e.vertexAttribPointer(R, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
|
|
922
931
|
const p = e.createBuffer();
|
|
923
932
|
e.bindBuffer(e.ARRAY_BUFFER, p), e.bufferData(e.ARRAY_BUFFER, b, e.STATIC_DRAW);
|
|
924
|
-
const g = e.getAttribLocation(
|
|
933
|
+
const g = e.getAttribLocation(r, "aUV");
|
|
925
934
|
e.enableVertexAttribArray(g), e.vertexAttribPointer(g, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
|
|
926
|
-
const x = e.getUniformLocation(
|
|
927
|
-
e.useProgram(
|
|
928
|
-
const
|
|
929
|
-
for (let w = 0; w <
|
|
935
|
+
const x = e.getUniformLocation(r, "uResolution"), l = e.getUniformLocation(r, "uTime"), y = e.getUniformLocation(r, "uBorderWidth"), F = e.getUniformLocation(r, "uGlowWidth"), d = e.getUniformLocation(r, "uBorderRadius"), S = e.getUniformLocation(r, "uColors"), C = e.getUniformLocation(r, "uGlowExponent"), U = e.getUniformLocation(r, "uGlowFactor");
|
|
936
|
+
e.useProgram(r), e.uniform1f(y, this.options.borderWidth), e.uniform1f(F, this.options.glowWidth), e.uniform1f(d, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(C, 2), e.uniform1f(U, 1.8)) : (e.uniform1f(C, 1), e.uniform1f(U, 1));
|
|
937
|
+
const T = (this.options.colors || qt).map(Ht);
|
|
938
|
+
for (let w = 0; w < T.length; w++)
|
|
930
939
|
e.uniform3f(
|
|
931
|
-
e.getUniformLocation(
|
|
932
|
-
...
|
|
940
|
+
e.getUniformLocation(r, `uColors[${w}]`),
|
|
941
|
+
...T[w]
|
|
933
942
|
);
|
|
934
943
|
this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
|
|
935
944
|
gl: e,
|
|
936
|
-
program:
|
|
937
|
-
vao:
|
|
945
|
+
program: r,
|
|
946
|
+
vao: n,
|
|
938
947
|
positionBuffer: v,
|
|
939
948
|
uvBuffer: p,
|
|
940
949
|
uResolution: x,
|
|
941
950
|
uTime: l,
|
|
942
|
-
uBorderWidth:
|
|
951
|
+
uBorderWidth: y,
|
|
943
952
|
uGlowWidth: F,
|
|
944
953
|
uBorderRadius: d,
|
|
945
954
|
uColors: S
|
|
@@ -947,75 +956,75 @@ class xn {
|
|
|
947
956
|
}
|
|
948
957
|
render(e) {
|
|
949
958
|
if (!this.glr) return;
|
|
950
|
-
const { gl:
|
|
951
|
-
|
|
959
|
+
const { gl: r, program: n, vao: o, uTime: c } = this.glr;
|
|
960
|
+
r.useProgram(n), r.bindVertexArray(o), r.uniform1f(c, e), r.disable(r.DEPTH_TEST), r.disable(r.CULL_FACE), r.disable(r.BLEND), r.clearColor(0, 0, 0, 0), r.clear(r.COLOR_BUFFER_BIT), r.drawArrays(r.TRIANGLES, 0, 24), this.checkGLError(r, "render: after draw call"), r.bindVertexArray(null);
|
|
952
961
|
}
|
|
953
962
|
}
|
|
954
|
-
const ge = ["lowp", "mediump", "highp"],
|
|
963
|
+
const ge = ["lowp", "mediump", "highp"], jt = `
|
|
955
964
|
void main(void){
|
|
956
965
|
vec4 color = vec4(0.0,0.0,0.0,1.0);
|
|
957
966
|
mainImage( color, gl_FragCoord.xy );
|
|
958
967
|
gl_FragColor = color;
|
|
959
|
-
}`,
|
|
968
|
+
}`, Kt = `void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
|
960
969
|
vec2 uv = fragCoord/iResolution.xy;
|
|
961
970
|
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
|
|
962
971
|
fragColor = vec4(col,1.0);
|
|
963
972
|
}`, we = `attribute vec3 aVertexPosition;
|
|
964
973
|
void main(void) {
|
|
965
974
|
gl_Position = vec4(aVertexPosition, 1.0);
|
|
966
|
-
}`,
|
|
967
|
-
function
|
|
975
|
+
}`, ye = "iTime", Te = "iTimeDelta", be = "iDate", Ee = "iFrame", Ae = "iMouse", Re = "iResolution", Qt = "iChannel", xe = "iChannelResolution", Se = "iDeviceOrientation";
|
|
976
|
+
function Jt(t, e) {
|
|
968
977
|
return t.includes("Matrix") && Array.isArray(e);
|
|
969
978
|
}
|
|
970
|
-
function
|
|
979
|
+
function Zt(t, e) {
|
|
971
980
|
return t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
|
|
972
981
|
}
|
|
973
|
-
function
|
|
982
|
+
function er(t, e) {
|
|
974
983
|
return !t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
|
|
975
984
|
}
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
switch (
|
|
985
|
+
const tr = (t, e, r, n) => {
|
|
986
|
+
if (er(r, n))
|
|
987
|
+
switch (r) {
|
|
979
988
|
case "2f":
|
|
980
|
-
return t.uniform2f(e,
|
|
989
|
+
return t.uniform2f(e, n[0], n[1]);
|
|
981
990
|
case "3f":
|
|
982
|
-
return t.uniform3f(e,
|
|
991
|
+
return t.uniform3f(e, n[0], n[1], n[2]);
|
|
983
992
|
case "4f":
|
|
984
|
-
return t.uniform4f(e,
|
|
993
|
+
return t.uniform4f(e, n[0], n[1], n[2], n[3]);
|
|
985
994
|
case "2i":
|
|
986
|
-
return t.uniform2i(e,
|
|
995
|
+
return t.uniform2i(e, n[0], n[1]);
|
|
987
996
|
case "3i":
|
|
988
|
-
return t.uniform3i(e,
|
|
997
|
+
return t.uniform3i(e, n[0], n[1], n[2]);
|
|
989
998
|
case "4i":
|
|
990
|
-
return t.uniform4i(e,
|
|
999
|
+
return t.uniform4i(e, n[0], n[1], n[2], n[3]);
|
|
991
1000
|
}
|
|
992
|
-
if (typeof
|
|
993
|
-
return
|
|
994
|
-
switch (
|
|
1001
|
+
if (typeof n == "number")
|
|
1002
|
+
return r === "1i" ? t.uniform1i(e, n) : t.uniform1f(e, n);
|
|
1003
|
+
switch (r) {
|
|
995
1004
|
case "1iv":
|
|
996
|
-
return t.uniform1iv(e,
|
|
1005
|
+
return t.uniform1iv(e, n);
|
|
997
1006
|
case "2iv":
|
|
998
|
-
return t.uniform2iv(e,
|
|
1007
|
+
return t.uniform2iv(e, n);
|
|
999
1008
|
case "3iv":
|
|
1000
|
-
return t.uniform3iv(e,
|
|
1009
|
+
return t.uniform3iv(e, n);
|
|
1001
1010
|
case "4iv":
|
|
1002
|
-
return t.uniform4iv(e,
|
|
1011
|
+
return t.uniform4iv(e, n);
|
|
1003
1012
|
case "1fv":
|
|
1004
|
-
return t.uniform1fv(e,
|
|
1013
|
+
return t.uniform1fv(e, n);
|
|
1005
1014
|
case "2fv":
|
|
1006
|
-
return t.uniform2fv(e,
|
|
1015
|
+
return t.uniform2fv(e, n);
|
|
1007
1016
|
case "3fv":
|
|
1008
|
-
return t.uniform3fv(e,
|
|
1017
|
+
return t.uniform3fv(e, n);
|
|
1009
1018
|
case "4fv":
|
|
1010
|
-
return t.uniform4fv(e,
|
|
1019
|
+
return t.uniform4fv(e, n);
|
|
1011
1020
|
case "Matrix2fv":
|
|
1012
|
-
return t.uniformMatrix2fv(e, !1,
|
|
1021
|
+
return t.uniformMatrix2fv(e, !1, n);
|
|
1013
1022
|
case "Matrix3fv":
|
|
1014
|
-
return t.uniformMatrix3fv(e, !1,
|
|
1023
|
+
return t.uniformMatrix3fv(e, !1, n);
|
|
1015
1024
|
case "Matrix4fv":
|
|
1016
|
-
return t.uniformMatrix4fv(e, !1,
|
|
1025
|
+
return t.uniformMatrix4fv(e, !1, n);
|
|
1017
1026
|
}
|
|
1018
|
-
},
|
|
1027
|
+
}, rr = (t) => {
|
|
1019
1028
|
switch (t) {
|
|
1020
1029
|
case "1f":
|
|
1021
1030
|
return "float";
|
|
@@ -1057,13 +1066,13 @@ const en = (t, e, n, r) => {
|
|
|
1057
1066
|
return "mat4";
|
|
1058
1067
|
default:
|
|
1059
1068
|
console.error(
|
|
1060
|
-
|
|
1069
|
+
X(
|
|
1061
1070
|
`The uniform type "${t}" is not valid, please make sure your uniform type is valid`
|
|
1062
1071
|
)
|
|
1063
1072
|
);
|
|
1064
1073
|
}
|
|
1065
|
-
}, ce = 9729, Le = 9728,
|
|
1066
|
-
class
|
|
1074
|
+
}, ce = 9729, Le = 9728, nr = 9987, Ce = 33071, Ie = 10497;
|
|
1075
|
+
class or {
|
|
1067
1076
|
gl;
|
|
1068
1077
|
url;
|
|
1069
1078
|
wrapS;
|
|
@@ -1081,37 +1090,37 @@ class rn {
|
|
|
1081
1090
|
constructor(e) {
|
|
1082
1091
|
this.gl = e;
|
|
1083
1092
|
}
|
|
1084
|
-
updateTexture = (e,
|
|
1093
|
+
updateTexture = (e, r, n) => {
|
|
1085
1094
|
const { gl: o } = this, c = 0, m = o.RGBA, b = o.RGBA, v = o.UNSIGNED_BYTE;
|
|
1086
|
-
o.bindTexture(o.TEXTURE_2D, e), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,
|
|
1095
|
+
o.bindTexture(o.TEXTURE_2D, e), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, n), o.texImage2D(
|
|
1087
1096
|
o.TEXTURE_2D,
|
|
1088
1097
|
c,
|
|
1089
1098
|
m,
|
|
1090
1099
|
b,
|
|
1091
1100
|
v,
|
|
1092
|
-
|
|
1101
|
+
r
|
|
1093
1102
|
);
|
|
1094
1103
|
};
|
|
1095
1104
|
setupVideo = (e) => {
|
|
1096
|
-
const
|
|
1097
|
-
let
|
|
1098
|
-
|
|
1105
|
+
const r = document.createElement("video");
|
|
1106
|
+
let n = !1, o = !1;
|
|
1107
|
+
r.autoplay = !0, r.muted = !0, r.loop = !0, r.crossOrigin = "anonymous";
|
|
1099
1108
|
const c = () => {
|
|
1100
|
-
|
|
1109
|
+
n && o && (this.isLoaded = !0);
|
|
1101
1110
|
};
|
|
1102
|
-
return
|
|
1111
|
+
return r.addEventListener(
|
|
1103
1112
|
"playing",
|
|
1104
1113
|
() => {
|
|
1105
|
-
|
|
1114
|
+
n = !0, this.width = r.videoWidth || 0, this.height = r.videoHeight || 0, c();
|
|
1106
1115
|
},
|
|
1107
1116
|
!0
|
|
1108
|
-
),
|
|
1117
|
+
), r.addEventListener(
|
|
1109
1118
|
"timeupdate",
|
|
1110
1119
|
() => {
|
|
1111
1120
|
o = !0, c();
|
|
1112
1121
|
},
|
|
1113
1122
|
!0
|
|
1114
|
-
),
|
|
1123
|
+
), r.src = e, r;
|
|
1115
1124
|
};
|
|
1116
1125
|
makePowerOf2 = (e) => e instanceof HTMLImageElement || e instanceof HTMLCanvasElement || e instanceof ImageBitmap ? (this.pow2canvas === void 0 && (this.pow2canvas = document.createElement("canvas")), this.pow2canvas.width = 2 ** Math.floor(Math.log(e.width) / Math.LN2), this.pow2canvas.height = 2 ** Math.floor(Math.log(e.height) / Math.LN2), this.pow2canvas.getContext("2d")?.drawImage(
|
|
1117
1126
|
e,
|
|
@@ -1120,101 +1129,101 @@ class rn {
|
|
|
1120
1129
|
this.pow2canvas.width,
|
|
1121
1130
|
this.pow2canvas.height
|
|
1122
1131
|
), console.warn(
|
|
1123
|
-
|
|
1132
|
+
X(
|
|
1124
1133
|
`Image is not power of two ${e.width} x ${e.height}. Resized to ${this.pow2canvas.width} x ${this.pow2canvas.height};`
|
|
1125
1134
|
)
|
|
1126
1135
|
), this.pow2canvas) : e;
|
|
1127
1136
|
load = async (e) => {
|
|
1128
|
-
const { gl:
|
|
1129
|
-
url:
|
|
1137
|
+
const { gl: r } = this, {
|
|
1138
|
+
url: n,
|
|
1130
1139
|
wrapS: o,
|
|
1131
1140
|
wrapT: c,
|
|
1132
1141
|
minFilter: m,
|
|
1133
1142
|
magFilter: b,
|
|
1134
1143
|
flipY: v = -1
|
|
1135
1144
|
} = e;
|
|
1136
|
-
if (!
|
|
1145
|
+
if (!n)
|
|
1137
1146
|
return Promise.reject(
|
|
1138
1147
|
new Error(
|
|
1139
|
-
|
|
1148
|
+
X(
|
|
1140
1149
|
"Missing url, please make sure to pass the url of your texture { url: ... }"
|
|
1141
1150
|
)
|
|
1142
1151
|
)
|
|
1143
1152
|
);
|
|
1144
|
-
const R = /(\.jpg|\.jpeg|\.png|\.gif|\.bmp)$/i.exec(
|
|
1153
|
+
const R = /(\.jpg|\.jpeg|\.png|\.gif|\.bmp)$/i.exec(n), p = /(\.mp4|\.3gp|\.webm|\.ogv)$/i.exec(n);
|
|
1145
1154
|
if (R === null && p === null)
|
|
1146
1155
|
return Promise.reject(
|
|
1147
1156
|
new Error(
|
|
1148
|
-
|
|
1149
|
-
`Please upload a video or an image with a valid format (url: ${
|
|
1157
|
+
X(
|
|
1158
|
+
`Please upload a video or an image with a valid format (url: ${n})`
|
|
1150
1159
|
)
|
|
1151
1160
|
)
|
|
1152
1161
|
);
|
|
1153
|
-
Object.assign(this, { url:
|
|
1154
|
-
const g = 0, x =
|
|
1155
|
-
if (
|
|
1156
|
-
|
|
1162
|
+
Object.assign(this, { url: n, wrapS: o, wrapT: c, minFilter: m, magFilter: b, flipY: v });
|
|
1163
|
+
const g = 0, x = r.RGBA, l = 1, y = 1, F = 0, d = r.RGBA, S = r.UNSIGNED_BYTE, C = new Uint8Array([255, 255, 255, 0]), U = r.createTexture();
|
|
1164
|
+
if (r.bindTexture(r.TEXTURE_2D, U), r.texImage2D(
|
|
1165
|
+
r.TEXTURE_2D,
|
|
1157
1166
|
g,
|
|
1158
1167
|
x,
|
|
1159
1168
|
l,
|
|
1160
|
-
|
|
1169
|
+
y,
|
|
1161
1170
|
F,
|
|
1162
1171
|
d,
|
|
1163
1172
|
S,
|
|
1164
1173
|
C
|
|
1165
1174
|
), p) {
|
|
1166
|
-
const P = this.setupVideo(
|
|
1167
|
-
return
|
|
1175
|
+
const P = this.setupVideo(n);
|
|
1176
|
+
return r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), this._webglTexture = U, this.source = P, this.isVideo = !0, P.play().then(() => this);
|
|
1168
1177
|
}
|
|
1169
|
-
async function
|
|
1178
|
+
async function T() {
|
|
1170
1179
|
return new Promise((P, D) => {
|
|
1171
1180
|
const A = new Image();
|
|
1172
1181
|
A.crossOrigin = "anonymous", A.onload = () => {
|
|
1173
1182
|
P(A);
|
|
1174
1183
|
}, A.onerror = () => {
|
|
1175
|
-
D(new Error(
|
|
1176
|
-
}, A.src =
|
|
1184
|
+
D(new Error(X(`failed loading url: ${n}`)));
|
|
1185
|
+
}, A.src = n ?? "";
|
|
1177
1186
|
});
|
|
1178
1187
|
}
|
|
1179
|
-
let w = await
|
|
1180
|
-
return (e.wrapS !== Ce || e.wrapT !== Ce || e.minFilter !== Le && e.minFilter !== ce) && !I && (w = this.makePowerOf2(w), I = !0),
|
|
1181
|
-
|
|
1188
|
+
let w = await T(), I = (w.width & w.width - 1) === 0 && (w.height & w.height - 1) === 0;
|
|
1189
|
+
return (e.wrapS !== Ce || e.wrapT !== Ce || e.minFilter !== Le && e.minFilter !== ce) && !I && (w = this.makePowerOf2(w), I = !0), r.bindTexture(r.TEXTURE_2D, U), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, v), r.texImage2D(
|
|
1190
|
+
r.TEXTURE_2D,
|
|
1182
1191
|
g,
|
|
1183
1192
|
x,
|
|
1184
1193
|
d,
|
|
1185
1194
|
S,
|
|
1186
1195
|
w
|
|
1187
|
-
), I && e.minFilter !== Le && e.minFilter !== ce &&
|
|
1188
|
-
|
|
1189
|
-
|
|
1196
|
+
), I && e.minFilter !== Le && e.minFilter !== ce && r.generateMipmap(r.TEXTURE_2D), r.texParameteri(
|
|
1197
|
+
r.TEXTURE_2D,
|
|
1198
|
+
r.TEXTURE_WRAP_S,
|
|
1190
1199
|
this.wrapS || Ie
|
|
1191
|
-
),
|
|
1192
|
-
|
|
1193
|
-
|
|
1200
|
+
), r.texParameteri(
|
|
1201
|
+
r.TEXTURE_2D,
|
|
1202
|
+
r.TEXTURE_WRAP_T,
|
|
1194
1203
|
this.wrapT || Ie
|
|
1195
|
-
),
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
this.minFilter ||
|
|
1199
|
-
),
|
|
1200
|
-
|
|
1201
|
-
|
|
1204
|
+
), r.texParameteri(
|
|
1205
|
+
r.TEXTURE_2D,
|
|
1206
|
+
r.TEXTURE_MIN_FILTER,
|
|
1207
|
+
this.minFilter || nr
|
|
1208
|
+
), r.texParameteri(
|
|
1209
|
+
r.TEXTURE_2D,
|
|
1210
|
+
r.TEXTURE_MAG_FILTER,
|
|
1202
1211
|
this.magFilter || ce
|
|
1203
1212
|
), this._webglTexture = U, this.source = w, this.isVideo = !1, this.isLoaded = !0, this.width = w.width || 0, this.height = w.height || 0, this;
|
|
1204
1213
|
};
|
|
1205
1214
|
}
|
|
1206
|
-
const
|
|
1215
|
+
const X = (t) => `react-shaders: ${t}`, _e = (t) => {
|
|
1207
1216
|
if ("changedTouches" in t) {
|
|
1208
1217
|
const e = t.changedTouches[0];
|
|
1209
1218
|
return [e?.clientX ?? 0, e?.clientY ?? 0];
|
|
1210
1219
|
}
|
|
1211
1220
|
return [t.clientX, t.clientY];
|
|
1212
|
-
}, Fe = (t, e,
|
|
1213
|
-
function
|
|
1221
|
+
}, Fe = (t, e, r) => t * (1 - r) + e * r, ir = (t, e, r) => r > 0 ? t.substring(0, r) + e + t.substring(r, t.length) : e + t;
|
|
1222
|
+
function sr({
|
|
1214
1223
|
fs: t,
|
|
1215
1224
|
vs: e = we,
|
|
1216
|
-
textures:
|
|
1217
|
-
uniforms:
|
|
1225
|
+
textures: r = [],
|
|
1226
|
+
uniforms: n,
|
|
1218
1227
|
clearColor: o = [0, 0, 0, 1],
|
|
1219
1228
|
precision: c = "highp",
|
|
1220
1229
|
style: m,
|
|
@@ -1225,9 +1234,9 @@ function sn({
|
|
|
1225
1234
|
onError: g = console.error,
|
|
1226
1235
|
onWarning: x = console.warn
|
|
1227
1236
|
}) {
|
|
1228
|
-
const l = B(null),
|
|
1229
|
-
[Te]: { type: "float", isNeeded: !1, value: 0 },
|
|
1237
|
+
const l = B(null), y = B(null), F = B(null), d = B(null), S = B(void 0), C = B(void 0), U = B(!1), T = B(void 0), w = B(0), I = B([0, 0]), P = B([]), D = B(0), A = B(void 0), f = B({
|
|
1230
1238
|
[ye]: { type: "float", isNeeded: !1, value: 0 },
|
|
1239
|
+
[Te]: { type: "float", isNeeded: !1, value: 0 },
|
|
1231
1240
|
[be]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1232
1241
|
[Ae]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1233
1242
|
[Re]: { type: "vec2", isNeeded: !1, value: [0, 0] },
|
|
@@ -1237,18 +1246,18 @@ function sn({
|
|
|
1237
1246
|
isNeeded: !1,
|
|
1238
1247
|
value: [0, 0, 0, 0]
|
|
1239
1248
|
}
|
|
1240
|
-
}), _ = B(
|
|
1249
|
+
}), _ = B(n), N = (i, a) => {
|
|
1241
1250
|
const s = "width" in i ? i.width ?? 0 : 0, h = "height" in i ? i.height ?? 0 : 0, u = f.current.iChannelResolution;
|
|
1242
1251
|
if (!u) return;
|
|
1243
1252
|
const E = Array.isArray(u.value) ? u.value : u.value = [];
|
|
1244
1253
|
E[a * 3] = s * R, E[a * 3 + 1] = h * R, E[a * 3 + 2] = 0;
|
|
1245
1254
|
}, W = () => {
|
|
1246
|
-
l.current && (
|
|
1255
|
+
l.current && (y.current = l.current.getContext("webgl", b) || l.current.getContext(
|
|
1247
1256
|
"experimental-webgl",
|
|
1248
1257
|
b
|
|
1249
|
-
),
|
|
1258
|
+
), y.current?.getExtension("OES_standard_derivatives"), y.current?.getExtension("EXT_shader_texture_lod"));
|
|
1250
1259
|
}, k = () => {
|
|
1251
|
-
const i =
|
|
1260
|
+
const i = y.current;
|
|
1252
1261
|
F.current = i?.createBuffer() ?? null, i?.bindBuffer(i.ARRAY_BUFFER, F.current);
|
|
1253
1262
|
const a = [
|
|
1254
1263
|
1,
|
|
@@ -1277,13 +1286,13 @@ function sn({
|
|
|
1277
1286
|
window.orientation ?? 0
|
|
1278
1287
|
];
|
|
1279
1288
|
}, z = (i) => {
|
|
1280
|
-
const [a = 0, s = 0] = _e(i), h = a - (
|
|
1289
|
+
const [a = 0, s = 0] = _e(i), h = a - (T.current?.left ?? 0) - window.pageXOffset, u = (T.current?.height ?? 0) - s - (T.current?.top ?? 0) - window.pageYOffset;
|
|
1281
1290
|
U.current = !0;
|
|
1282
1291
|
const E = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
|
|
1283
1292
|
E && (E[2] = h, E[3] = u), I.current[0] = h, I.current[1] = u;
|
|
1284
1293
|
}, M = (i) => {
|
|
1285
|
-
|
|
1286
|
-
const [a = 0, s = 0] = _e(i), h = a - (
|
|
1294
|
+
T.current = l.current?.getBoundingClientRect();
|
|
1295
|
+
const [a = 0, s = 0] = _e(i), h = a - (T.current?.left ?? 0), u = (T.current?.height ?? 0) - s - (T.current?.top ?? 0);
|
|
1287
1296
|
if (v !== 1)
|
|
1288
1297
|
I.current[0] = h, I.current[1] = u;
|
|
1289
1298
|
else {
|
|
@@ -1294,13 +1303,13 @@ function sn({
|
|
|
1294
1303
|
const i = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
|
|
1295
1304
|
i && (i[2] = 0, i[3] = 0);
|
|
1296
1305
|
}, O = () => {
|
|
1297
|
-
const i =
|
|
1306
|
+
const i = y.current;
|
|
1298
1307
|
if (!i) return;
|
|
1299
|
-
|
|
1308
|
+
T.current = l.current?.getBoundingClientRect();
|
|
1300
1309
|
const a = R, s = Math.floor(
|
|
1301
|
-
(
|
|
1310
|
+
(T.current?.width ?? 1) * a
|
|
1302
1311
|
), h = Math.floor(
|
|
1303
|
-
(
|
|
1312
|
+
(T.current?.height ?? 1) * a
|
|
1304
1313
|
);
|
|
1305
1314
|
if (i.canvas.width = s, i.canvas.height = h, f.current.iResolution?.isNeeded && d.current) {
|
|
1306
1315
|
const u = i.getUniformLocation(
|
|
@@ -1310,25 +1319,25 @@ function sn({
|
|
|
1310
1319
|
i.uniform2fv(u, [i.canvas.width, i.canvas.height]);
|
|
1311
1320
|
}
|
|
1312
1321
|
}, j = (i, a) => {
|
|
1313
|
-
const s =
|
|
1322
|
+
const s = y.current;
|
|
1314
1323
|
if (!s) return null;
|
|
1315
1324
|
const h = s.createShader(i);
|
|
1316
1325
|
if (!h) return null;
|
|
1317
1326
|
if (s.shaderSource(h, a), s.compileShader(h), !s.getShaderParameter(h, s.COMPILE_STATUS)) {
|
|
1318
|
-
x?.(
|
|
1327
|
+
x?.(X(`Error compiling the shader:
|
|
1319
1328
|
${a}`));
|
|
1320
1329
|
const u = s.getShaderInfoLog(h);
|
|
1321
|
-
s.deleteShader(h), g?.(
|
|
1330
|
+
s.deleteShader(h), g?.(X(`Shader compiler log: ${u}`));
|
|
1322
1331
|
}
|
|
1323
1332
|
return h;
|
|
1324
1333
|
}, Z = (i, a) => {
|
|
1325
|
-
const s =
|
|
1334
|
+
const s = y.current;
|
|
1326
1335
|
if (!s) return;
|
|
1327
1336
|
const h = j(s.FRAGMENT_SHADER, i), u = j(s.VERTEX_SHADER, a);
|
|
1328
1337
|
if (d.current = s.createProgram(), !(!d.current || !u || !h)) {
|
|
1329
1338
|
if (s.attachShader(d.current, u), s.attachShader(d.current, h), s.linkProgram(d.current), !s.getProgramParameter(d.current, s.LINK_STATUS)) {
|
|
1330
1339
|
g?.(
|
|
1331
|
-
|
|
1340
|
+
X(
|
|
1332
1341
|
`Unable to initialize the shader program: ${s.getProgramInfoLog(
|
|
1333
1342
|
d.current
|
|
1334
1343
|
)}`
|
|
@@ -1342,17 +1351,17 @@ ${a}`));
|
|
|
1342
1351
|
), s.enableVertexAttribArray(S.current);
|
|
1343
1352
|
}
|
|
1344
1353
|
}, $ = () => {
|
|
1345
|
-
if (
|
|
1346
|
-
for (const i of Object.keys(
|
|
1347
|
-
const a =
|
|
1354
|
+
if (n)
|
|
1355
|
+
for (const i of Object.keys(n)) {
|
|
1356
|
+
const a = n[i];
|
|
1348
1357
|
if (!a) continue;
|
|
1349
|
-
const { value: s, type: h } = a, u =
|
|
1358
|
+
const { value: s, type: h } = a, u = rr(h);
|
|
1350
1359
|
if (!u) continue;
|
|
1351
1360
|
const E = {};
|
|
1352
|
-
if (
|
|
1353
|
-
const V = h.length,
|
|
1354
|
-
s.length >
|
|
1355
|
-
} else
|
|
1361
|
+
if (Jt(h, s)) {
|
|
1362
|
+
const V = h.length, Y = Number.parseInt(h.charAt(V - 3)), te = Math.floor(s.length / (Y * Y));
|
|
1363
|
+
s.length > Y * Y && (E.arraySize = `[${te}]`);
|
|
1364
|
+
} else Zt(h, s) && (E.arraySize = `[${Math.floor(s.length / Number.parseInt(h.charAt(0)))}]`);
|
|
1356
1365
|
f.current[i] = {
|
|
1357
1366
|
type: u,
|
|
1358
1367
|
isNeeded: !1,
|
|
@@ -1360,21 +1369,21 @@ ${a}`));
|
|
|
1360
1369
|
...E
|
|
1361
1370
|
};
|
|
1362
1371
|
}
|
|
1363
|
-
},
|
|
1364
|
-
const i =
|
|
1372
|
+
}, re = () => {
|
|
1373
|
+
const i = y.current;
|
|
1365
1374
|
if (i)
|
|
1366
|
-
if (
|
|
1375
|
+
if (r && r.length > 0) {
|
|
1367
1376
|
f.current[`${xe}`] = {
|
|
1368
1377
|
type: "vec3",
|
|
1369
1378
|
isNeeded: !1,
|
|
1370
|
-
arraySize: `[${
|
|
1379
|
+
arraySize: `[${r.length}]`,
|
|
1371
1380
|
value: []
|
|
1372
1381
|
};
|
|
1373
|
-
const a =
|
|
1374
|
-
(s, h) => (f.current[`${
|
|
1382
|
+
const a = r.map(
|
|
1383
|
+
(s, h) => (f.current[`${Qt}${h}`] = {
|
|
1375
1384
|
type: "sampler2D",
|
|
1376
1385
|
isNeeded: !1
|
|
1377
|
-
}, N(s, h), P.current[h] = new
|
|
1386
|
+
}, N(s, h), P.current[h] = new or(i), P.current[h]?.load(s).then((u) => {
|
|
1378
1387
|
N(u, h);
|
|
1379
1388
|
}))
|
|
1380
1389
|
);
|
|
@@ -1384,11 +1393,11 @@ ${a}`));
|
|
|
1384
1393
|
g?.(s), p && p();
|
|
1385
1394
|
});
|
|
1386
1395
|
} else p && p();
|
|
1387
|
-
},
|
|
1396
|
+
}, ne = (i) => {
|
|
1388
1397
|
const a = ge.includes(c ?? "highp"), s = `precision ${a ? c : ge[1]} float;
|
|
1389
1398
|
`;
|
|
1390
1399
|
a || x?.(
|
|
1391
|
-
|
|
1400
|
+
X(
|
|
1392
1401
|
`wrong precision type ${c}, please make sure to pass one of a valid precision lowp, mediump, highp, by default you shader precision will be set to highp.`
|
|
1393
1402
|
)
|
|
1394
1403
|
);
|
|
@@ -1398,16 +1407,16 @@ ${a}`));
|
|
|
1398
1407
|
if (i.includes(E)) {
|
|
1399
1408
|
const V = f.current[E];
|
|
1400
1409
|
if (!V) continue;
|
|
1401
|
-
h =
|
|
1410
|
+
h = ir(
|
|
1402
1411
|
h,
|
|
1403
1412
|
`uniform ${V.type} ${E}${V.arraySize || ""};
|
|
1404
1413
|
`,
|
|
1405
1414
|
h.lastIndexOf(s) + s.length
|
|
1406
1415
|
), V.isNeeded = !0;
|
|
1407
1416
|
}
|
|
1408
|
-
return i.includes("mainImage") && (h = h.concat(
|
|
1417
|
+
return i.includes("mainImage") && (h = h.concat(jt)), h;
|
|
1409
1418
|
}, K = (i) => {
|
|
1410
|
-
const a =
|
|
1419
|
+
const a = y.current;
|
|
1411
1420
|
if (!a || !d.current) return;
|
|
1412
1421
|
const s = D.current ? (i - D.current) / 1e3 : 0;
|
|
1413
1422
|
D.current = i;
|
|
@@ -1422,7 +1431,7 @@ ${a}`));
|
|
|
1422
1431
|
u
|
|
1423
1432
|
);
|
|
1424
1433
|
if (!V) return;
|
|
1425
|
-
|
|
1434
|
+
tr(
|
|
1426
1435
|
a,
|
|
1427
1436
|
V,
|
|
1428
1437
|
E.type,
|
|
@@ -1460,23 +1469,23 @@ ${a}`));
|
|
|
1460
1469
|
if (f.current.iTime?.isNeeded) {
|
|
1461
1470
|
const u = a.getUniformLocation(
|
|
1462
1471
|
d.current,
|
|
1463
|
-
|
|
1472
|
+
ye
|
|
1464
1473
|
);
|
|
1465
1474
|
a.uniform1f(u, w.current += s);
|
|
1466
1475
|
}
|
|
1467
1476
|
if (f.current.iTimeDelta?.isNeeded) {
|
|
1468
1477
|
const u = a.getUniformLocation(
|
|
1469
1478
|
d.current,
|
|
1470
|
-
|
|
1479
|
+
Te
|
|
1471
1480
|
);
|
|
1472
1481
|
a.uniform1f(u, s);
|
|
1473
1482
|
}
|
|
1474
1483
|
if (f.current.iDate?.isNeeded) {
|
|
1475
|
-
const u = /* @__PURE__ */ new Date(), E = u.getMonth() + 1, V = u.getDate(),
|
|
1484
|
+
const u = /* @__PURE__ */ new Date(), E = u.getMonth() + 1, V = u.getDate(), Y = u.getFullYear(), te = u.getHours() * 60 * 60 + u.getMinutes() * 60 + u.getSeconds() + u.getMilliseconds() * 1e-3, ae = a.getUniformLocation(
|
|
1476
1485
|
d.current,
|
|
1477
1486
|
be
|
|
1478
1487
|
);
|
|
1479
|
-
a.uniform4fv(ae, [
|
|
1488
|
+
a.uniform4fv(ae, [Y, E, V, te]);
|
|
1480
1489
|
}
|
|
1481
1490
|
if (f.current.iFrame?.isNeeded) {
|
|
1482
1491
|
const u = a.getUniformLocation(
|
|
@@ -1489,23 +1498,23 @@ ${a}`));
|
|
|
1489
1498
|
for (let u = 0; u < P.current.length; u++) {
|
|
1490
1499
|
const E = P.current[u];
|
|
1491
1500
|
if (!E) return;
|
|
1492
|
-
const { isVideo: V, _webglTexture:
|
|
1493
|
-
if (!ke || !
|
|
1501
|
+
const { isVideo: V, _webglTexture: Y, source: te, flipY: ae, isLoaded: ke } = E;
|
|
1502
|
+
if (!ke || !Y || !te) return;
|
|
1494
1503
|
if (f.current[`iChannel${u}`]?.isNeeded) {
|
|
1495
1504
|
if (!d.current) return;
|
|
1496
1505
|
const We = a.getUniformLocation(
|
|
1497
1506
|
d.current,
|
|
1498
1507
|
`iChannel${u}`
|
|
1499
1508
|
);
|
|
1500
|
-
a.activeTexture(a.TEXTURE0 + u), a.bindTexture(a.TEXTURE_2D,
|
|
1501
|
-
|
|
1509
|
+
a.activeTexture(a.TEXTURE0 + u), a.bindTexture(a.TEXTURE_2D, Y), a.uniform1i(We, u), V && E.updateTexture(
|
|
1510
|
+
Y,
|
|
1502
1511
|
te,
|
|
1503
1512
|
ae
|
|
1504
1513
|
);
|
|
1505
1514
|
}
|
|
1506
1515
|
}
|
|
1507
1516
|
}, Q = (i) => {
|
|
1508
|
-
const a =
|
|
1517
|
+
const a = y.current;
|
|
1509
1518
|
if (!a) return;
|
|
1510
1519
|
a.viewport(0, 0, a.drawingBufferWidth, a.drawingBufferHeight), a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT), a.bindBuffer(a.ARRAY_BUFFER, F.current), a.vertexAttribPointer(
|
|
1511
1520
|
S.current ?? 0,
|
|
@@ -1537,16 +1546,16 @@ ${a}`));
|
|
|
1537
1546
|
), A.current && (A.current.disconnect(), window.removeEventListener("resize", O, i));
|
|
1538
1547
|
};
|
|
1539
1548
|
return ie(() => {
|
|
1540
|
-
_.current =
|
|
1541
|
-
}, [
|
|
1549
|
+
_.current = n;
|
|
1550
|
+
}, [n]), ie(() => {
|
|
1542
1551
|
const i = P.current;
|
|
1543
1552
|
function a() {
|
|
1544
1553
|
W();
|
|
1545
|
-
const s =
|
|
1546
|
-
s && l.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, l.current.width, l.current.height), l.current.height = l.current.clientHeight, l.current.width = l.current.clientWidth, $(),
|
|
1554
|
+
const s = y.current;
|
|
1555
|
+
s && l.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, l.current.width, l.current.height), l.current.height = l.current.clientHeight, l.current.width = l.current.clientWidth, $(), re(), Z(ne(t || Kt), e || we), k(), requestAnimationFrame(Q), ee(), O());
|
|
1547
1556
|
}
|
|
1548
1557
|
return requestAnimationFrame(a), () => {
|
|
1549
|
-
const s =
|
|
1558
|
+
const s = y.current;
|
|
1550
1559
|
if (s) {
|
|
1551
1560
|
if (s.getExtension("WEBGL_lose_context")?.loseContext(), s.useProgram(null), s.deleteProgram(d.current ?? null), i.length > 0)
|
|
1552
1561
|
for (const h of i)
|
|
@@ -1563,7 +1572,7 @@ ${a}`));
|
|
|
1563
1572
|
}
|
|
1564
1573
|
);
|
|
1565
1574
|
}
|
|
1566
|
-
const
|
|
1575
|
+
const ar = `
|
|
1567
1576
|
const float TAU = 6.283185;
|
|
1568
1577
|
|
|
1569
1578
|
// Noise for dithering
|
|
@@ -1730,7 +1739,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
|
1730
1739
|
float alpha = mappedBrightness * clamp(uMix, 1.0, 2.0);
|
|
1731
1740
|
fragColor = vec4(color, alpha);
|
|
1732
1741
|
}
|
|
1733
|
-
}`,
|
|
1742
|
+
}`, cr = 10, ur = 2, lr = 0.5, fr = 0.2, hr = 1.5, G = {
|
|
1734
1743
|
duration: 0.5,
|
|
1735
1744
|
ease: "easeOut"
|
|
1736
1745
|
}, Pe = {
|
|
@@ -1740,22 +1749,22 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
|
1740
1749
|
repeatType: "mirror"
|
|
1741
1750
|
};
|
|
1742
1751
|
function oe(t) {
|
|
1743
|
-
const [e,
|
|
1744
|
-
|
|
1752
|
+
const [e, r] = Ue(t), n = dt(t), o = B(null);
|
|
1753
|
+
yt(n, "change", (m) => r(m));
|
|
1745
1754
|
const c = $e(
|
|
1746
1755
|
(m, b) => {
|
|
1747
|
-
o.current =
|
|
1756
|
+
o.current = zt(n, m, b);
|
|
1748
1757
|
},
|
|
1749
|
-
[
|
|
1758
|
+
[n]
|
|
1750
1759
|
);
|
|
1751
|
-
return { value: e, motionValue:
|
|
1760
|
+
return { value: e, motionValue: n, controls: o, animate: c };
|
|
1752
1761
|
}
|
|
1753
|
-
function
|
|
1754
|
-
const [
|
|
1762
|
+
function dr(t, e) {
|
|
1763
|
+
const [r, n] = Ue(cr), {
|
|
1755
1764
|
value: o,
|
|
1756
1765
|
animate: c,
|
|
1757
1766
|
motionValue: m
|
|
1758
|
-
} = oe(
|
|
1767
|
+
} = oe(fr), { value: b, animate: v } = oe(ur), { value: R, animate: p } = oe(lr), { value: g, animate: x } = oe(hr), l = gt(e, {
|
|
1759
1768
|
fftSize: 512,
|
|
1760
1769
|
smoothingTimeConstant: 0.55
|
|
1761
1770
|
});
|
|
@@ -1764,19 +1773,19 @@ function dn(t, e) {
|
|
|
1764
1773
|
case "idle":
|
|
1765
1774
|
case "failed":
|
|
1766
1775
|
case "disconnected":
|
|
1767
|
-
|
|
1776
|
+
n(10), c(0.2, G), v(1.2, G), p(0.4, G), x(1, G);
|
|
1768
1777
|
return;
|
|
1769
1778
|
case "listening":
|
|
1770
1779
|
case "pre-connect-buffering":
|
|
1771
|
-
|
|
1780
|
+
n(20), c(0.3, { type: "spring", duration: 1, bounce: 0.35 }), v(1, G), p(0.7, G), x([1.5, 2], Pe);
|
|
1772
1781
|
return;
|
|
1773
1782
|
case "thinking":
|
|
1774
1783
|
case "connecting":
|
|
1775
1784
|
case "initializing":
|
|
1776
|
-
|
|
1785
|
+
n(30), c(0.3, G), v(0.5, G), p(1, G), x([0.5, 2.5], Pe);
|
|
1777
1786
|
return;
|
|
1778
1787
|
case "speaking":
|
|
1779
|
-
|
|
1788
|
+
n(70), c(0.3, G), v(0.75, G), p(1.25, G), x(1.5, G);
|
|
1780
1789
|
return;
|
|
1781
1790
|
}
|
|
1782
1791
|
}, [
|
|
@@ -1796,14 +1805,14 @@ function dn(t, e) {
|
|
|
1796
1805
|
p,
|
|
1797
1806
|
x
|
|
1798
1807
|
]), {
|
|
1799
|
-
speed:
|
|
1808
|
+
speed: r,
|
|
1800
1809
|
scale: o,
|
|
1801
1810
|
amplitude: b,
|
|
1802
1811
|
frequency: R,
|
|
1803
1812
|
brightness: g
|
|
1804
1813
|
};
|
|
1805
1814
|
}
|
|
1806
|
-
const
|
|
1815
|
+
const mr = pt({
|
|
1807
1816
|
base: "aspect-square",
|
|
1808
1817
|
variants: {
|
|
1809
1818
|
size: {
|
|
@@ -1818,20 +1827,20 @@ const mn = pt({
|
|
|
1818
1827
|
size: "lg"
|
|
1819
1828
|
}
|
|
1820
1829
|
});
|
|
1821
|
-
function
|
|
1830
|
+
function pr(t) {
|
|
1822
1831
|
const e = t.match(
|
|
1823
1832
|
/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
1824
1833
|
);
|
|
1825
1834
|
if (e) {
|
|
1826
|
-
const [,
|
|
1827
|
-
return [
|
|
1835
|
+
const [, r, n, o] = e;
|
|
1836
|
+
return [r, n, o].map((m = "00") => parseInt(m, 16) / 255);
|
|
1828
1837
|
}
|
|
1829
1838
|
}
|
|
1830
1839
|
function Ge({
|
|
1831
1840
|
shape: t = 1,
|
|
1832
1841
|
speed: e = 1,
|
|
1833
|
-
amplitude:
|
|
1834
|
-
frequency:
|
|
1842
|
+
amplitude: r = 0.5,
|
|
1843
|
+
frequency: n = 0.5,
|
|
1835
1844
|
scale: o = 0.2,
|
|
1836
1845
|
blur: c = 1,
|
|
1837
1846
|
color: m = "#FF355E",
|
|
@@ -1842,11 +1851,11 @@ function Ge({
|
|
|
1842
1851
|
className: g,
|
|
1843
1852
|
...x
|
|
1844
1853
|
}) {
|
|
1845
|
-
const l = qe(() =>
|
|
1854
|
+
const l = qe(() => pr(m), [m]);
|
|
1846
1855
|
return /* @__PURE__ */ q("div", { ref: p, className: g, ...x, children: /* @__PURE__ */ q(
|
|
1847
|
-
|
|
1856
|
+
sr,
|
|
1848
1857
|
{
|
|
1849
|
-
fs:
|
|
1858
|
+
fs: ar,
|
|
1850
1859
|
devicePixelRatio: globalThis.devicePixelRatio ?? 1,
|
|
1851
1860
|
uniforms: {
|
|
1852
1861
|
// Aurora wave speed
|
|
@@ -1858,9 +1867,9 @@ function Ge({
|
|
|
1858
1867
|
// Shape type: 1=circle, 2=line
|
|
1859
1868
|
uShape: { type: "1f", value: t },
|
|
1860
1869
|
// Wave frequency and complexity
|
|
1861
|
-
uFrequency: { type: "1f", value:
|
|
1870
|
+
uFrequency: { type: "1f", value: n },
|
|
1862
1871
|
// Turbulence amplitude
|
|
1863
|
-
uAmplitude: { type: "1f", value:
|
|
1872
|
+
uAmplitude: { type: "1f", value: r },
|
|
1864
1873
|
// Light intensity (bloom)
|
|
1865
1874
|
uBloom: { type: "1f", value: 0 },
|
|
1866
1875
|
// Brightness of the aurora (0-1)
|
|
@@ -1878,36 +1887,36 @@ function Ge({
|
|
|
1878
1887
|
// Color
|
|
1879
1888
|
uColor: { type: "3fv", value: l ?? [0, 0.7, 1] }
|
|
1880
1889
|
},
|
|
1881
|
-
onError: (
|
|
1882
|
-
console.error("Shader error:",
|
|
1890
|
+
onError: (y) => {
|
|
1891
|
+
console.error("Shader error:", y);
|
|
1883
1892
|
},
|
|
1884
|
-
onWarning: (
|
|
1885
|
-
console.warn("Shader warning:",
|
|
1893
|
+
onWarning: (y) => {
|
|
1894
|
+
console.warn("Shader warning:", y);
|
|
1886
1895
|
},
|
|
1887
1896
|
style: { width: "100%", height: "100%" }
|
|
1888
1897
|
}
|
|
1889
1898
|
) });
|
|
1890
1899
|
}
|
|
1891
1900
|
Ge.displayName = "AuraShader";
|
|
1892
|
-
function
|
|
1901
|
+
function Cr({
|
|
1893
1902
|
size: t = "lg",
|
|
1894
1903
|
state: e,
|
|
1895
|
-
color:
|
|
1896
|
-
colorShift:
|
|
1904
|
+
color: r,
|
|
1905
|
+
colorShift: n = 0.05,
|
|
1897
1906
|
audioTrack: o,
|
|
1898
1907
|
themeMode: c,
|
|
1899
1908
|
className: m,
|
|
1900
1909
|
ref: b,
|
|
1901
1910
|
...v
|
|
1902
1911
|
}) {
|
|
1903
|
-
const { speed: R, scale: p, amplitude: g, frequency: x, brightness: l } =
|
|
1912
|
+
const { speed: R, scale: p, amplitude: g, frequency: x, brightness: l } = dr(e, o);
|
|
1904
1913
|
return /* @__PURE__ */ q(
|
|
1905
1914
|
Ge,
|
|
1906
1915
|
{
|
|
1907
1916
|
ref: b,
|
|
1908
1917
|
blur: 0.2,
|
|
1909
|
-
color:
|
|
1910
|
-
colorShift:
|
|
1918
|
+
color: r,
|
|
1919
|
+
colorShift: n,
|
|
1911
1920
|
speed: R,
|
|
1912
1921
|
scale: p,
|
|
1913
1922
|
themeMode: c,
|
|
@@ -1915,7 +1924,7 @@ function Sn({
|
|
|
1915
1924
|
frequency: x,
|
|
1916
1925
|
brightness: l,
|
|
1917
1926
|
className: mt(
|
|
1918
|
-
|
|
1927
|
+
mr({ size: t }),
|
|
1919
1928
|
"overflow-hidden rounded-full",
|
|
1920
1929
|
m
|
|
1921
1930
|
),
|
|
@@ -1923,11 +1932,13 @@ function Sn({
|
|
|
1923
1932
|
}
|
|
1924
1933
|
);
|
|
1925
1934
|
}
|
|
1926
|
-
const
|
|
1935
|
+
const vr = wt;
|
|
1936
|
+
vr.displayName = "F0ChatReportCard";
|
|
1937
|
+
const Ir = ({
|
|
1927
1938
|
text: t,
|
|
1928
1939
|
confirmationText: e,
|
|
1929
|
-
onConfirm:
|
|
1930
|
-
cancelText:
|
|
1940
|
+
onConfirm: r,
|
|
1941
|
+
cancelText: n,
|
|
1931
1942
|
onCancel: o
|
|
1932
1943
|
}) => /* @__PURE__ */ le("div", { className: "flex flex-col gap-2", children: [
|
|
1933
1944
|
t && /* @__PURE__ */ q("p", { children: t }),
|
|
@@ -1939,7 +1950,7 @@ const Ln = ({
|
|
|
1939
1950
|
variant: "outline",
|
|
1940
1951
|
size: "sm",
|
|
1941
1952
|
icon: vt,
|
|
1942
|
-
onClick:
|
|
1953
|
+
onClick: r,
|
|
1943
1954
|
label: e
|
|
1944
1955
|
}
|
|
1945
1956
|
),
|
|
@@ -1950,18 +1961,19 @@ const Ln = ({
|
|
|
1950
1961
|
variant: "ghost",
|
|
1951
1962
|
size: "sm",
|
|
1952
1963
|
onClick: o,
|
|
1953
|
-
label:
|
|
1964
|
+
label: n
|
|
1954
1965
|
}
|
|
1955
1966
|
)
|
|
1956
1967
|
] })
|
|
1957
1968
|
] });
|
|
1958
1969
|
export {
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1970
|
+
xr as A,
|
|
1971
|
+
Lr as F,
|
|
1972
|
+
Rr as a,
|
|
1973
|
+
Ar as b,
|
|
1974
|
+
Cr as c,
|
|
1975
|
+
vr as d,
|
|
1976
|
+
Ir as e,
|
|
1977
|
+
Er as o,
|
|
1978
|
+
Sr as u
|
|
1967
1979
|
};
|