@factorialco/f0-react 1.438.3 → 1.444.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-Cv0j7lo_.js → F0AiChat-RHHqqqMC.js} +142837 -126169
- package/dist/F0AiChat.css +1 -1
- package/dist/ai.d.ts +597 -7
- package/dist/ai.js +12 -10
- package/dist/experimental.d.ts +104 -3
- package/dist/experimental.js +3581 -3861
- package/dist/f0.css +1 -0
- package/dist/f0.d.ts +379 -37
- package/dist/f0.js +14479 -10522
- package/dist/i18n-provider-defaults.d.ts +17 -0
- package/dist/i18n-provider-defaults.js +19 -2
- package/dist/index-D_fn_du2.js +44284 -0
- package/dist/index.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types-99qPm9SM.js +2354 -0
- package/icons/app/Basket.d.ts +4 -0
- package/icons/app/Basket.d.ts.map +1 -0
- package/icons/app/Basket.js +5 -0
- package/icons/app/Bookmark.d.ts.map +1 -1
- package/icons/app/Bookmark.js +1 -1
- package/icons/app/BookmarkFilled.d.ts +4 -0
- package/icons/app/BookmarkFilled.d.ts.map +1 -0
- package/icons/app/BookmarkFilled.js +5 -0
- package/icons/app/ChartFunnel.d.ts +4 -0
- package/icons/app/ChartFunnel.d.ts.map +1 -0
- package/icons/app/ChartFunnel.js +5 -0
- package/icons/app/ChartHorizontalBars.d.ts +4 -0
- package/icons/app/ChartHorizontalBars.d.ts.map +1 -0
- package/icons/app/ChartHorizontalBars.js +5 -0
- package/icons/app/ChartLine.d.ts.map +1 -1
- package/icons/app/ChartLine.js +2 -2
- package/icons/app/ChartPie.d.ts.map +1 -1
- package/icons/app/ChartPie.js +2 -2
- package/icons/app/ChartVerticalBars.d.ts +4 -0
- package/icons/app/ChartVerticalBars.d.ts.map +1 -0
- package/icons/app/ChartVerticalBars.js +5 -0
- package/icons/app/UserProtected.d.ts +4 -0
- package/icons/app/UserProtected.d.ts.map +1 -0
- package/icons/app/UserProtected.js +5 -0
- package/icons/app/Watch.d.ts.map +1 -1
- package/icons/app/Watch.js +1 -1
- package/icons/app/index.d.ts +15 -9
- package/icons/app/index.d.ts.map +1 -1
- package/icons/app/index.js +15 -9
- package/package.json +3 -2
- package/dist/F0HILActionConfirmation-DDhZML5m.js +0 -1912
- package/dist/index-CqiKdYjB.js +0 -63101
|
@@ -0,0 +1,2354 @@
|
|
|
1
|
+
import { defaultTranslations as rt } from "./i18n-provider-defaults.js";
|
|
2
|
+
import { jsx as h, jsxs as M, Fragment as Ge } from "react/jsx-runtime";
|
|
3
|
+
import { useInsertionEffect as nt, forwardRef as me, createContext as ot, useContext as it, useRef as D, useEffect as ue, useState as de, useCallback as at, useMemo as st, useId as ct, createElement as lt } from "react";
|
|
4
|
+
import { r as ut, l as dt, m as ft, n as ht, o as ke, p as mt, q as pt, s as vt, t as gt, v as wt, w as We, x as bt, V as yt, y as Tt, z as xt, A as At, S as Et, H as Rt, B as fe, D as Ct, E as St, G as Lt, J as It, K as Ft, L as X, M as ie, N as we, O as _t, u as Nt, P as ze, Q as Pt, R as he, T as Ut, U as Mt, W as Bt, X as Ot, Y as Vt, Z as Dt, _ as Gt, $ as kt, a0 as Wt, a1 as zt, a2 as Xt, a3 as Yt, a4 as $t, a5 as oe } from "./F0AiChat-RHHqqqMC.js";
|
|
5
|
+
import { useTrackVolume as qt } from "@livekit/components-react";
|
|
6
|
+
function Ht(t, e, r) {
|
|
7
|
+
nt(() => t.on(e, r), [t, e, r]);
|
|
8
|
+
}
|
|
9
|
+
function ge(t) {
|
|
10
|
+
return typeof t == "object" && !Array.isArray(t);
|
|
11
|
+
}
|
|
12
|
+
function Xe(t, e, r, n) {
|
|
13
|
+
return typeof t == "string" && ge(e) ? ut(t, r, n) : t instanceof NodeList ? Array.from(t) : Array.isArray(t) ? t : [t];
|
|
14
|
+
}
|
|
15
|
+
function Kt(t, e, r) {
|
|
16
|
+
return t * (e + 1);
|
|
17
|
+
}
|
|
18
|
+
function be(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;
|
|
20
|
+
}
|
|
21
|
+
const jt = (t, e, r) => {
|
|
22
|
+
const n = e - t;
|
|
23
|
+
return ((r - t) % n + n) % n + t;
|
|
24
|
+
};
|
|
25
|
+
function Ye(t, e) {
|
|
26
|
+
return dt(t) ? t[jt(0, t.length, e)] : t;
|
|
27
|
+
}
|
|
28
|
+
function Zt(t, e, r) {
|
|
29
|
+
for (let n = 0; n < t.length; n++) {
|
|
30
|
+
const o = t[n];
|
|
31
|
+
o.at > e && o.at < r && (ht(t, o), n--);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function Qt(t, e, r, n, o, i) {
|
|
35
|
+
Zt(t, o, i);
|
|
36
|
+
for (let l = 0; l < e.length; l++)
|
|
37
|
+
t.push({
|
|
38
|
+
value: e[l],
|
|
39
|
+
at: ft(o, i, n[l]),
|
|
40
|
+
easing: Ye(r, l)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function Jt(t, e) {
|
|
44
|
+
for (let r = 0; r < t.length; r++)
|
|
45
|
+
t[r] = t[r] / (e + 1);
|
|
46
|
+
}
|
|
47
|
+
function er(t, e) {
|
|
48
|
+
return t.at === e.at ? t.value === null ? 1 : e.value === null ? -1 : 0 : t.at - e.at;
|
|
49
|
+
}
|
|
50
|
+
const tr = "easeInOut", rr = 20;
|
|
51
|
+
function nr(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
52
|
+
const i = e.duration || 0.3, l = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), b = {}, A = /* @__PURE__ */ new Map();
|
|
53
|
+
let v = 0, w = 0, R = 0;
|
|
54
|
+
for (let u = 0; u < t.length; u++) {
|
|
55
|
+
const y = t[u];
|
|
56
|
+
if (typeof y == "string") {
|
|
57
|
+
A.set(y, w);
|
|
58
|
+
continue;
|
|
59
|
+
} else if (!Array.isArray(y)) {
|
|
60
|
+
A.set(y.name, be(w, y.at, v, A));
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
let [F, f, S = {}] = y;
|
|
64
|
+
S.at !== void 0 && (w = be(w, S.at, v, A));
|
|
65
|
+
let I = 0;
|
|
66
|
+
const U = (g, x, _, P = 0, G = 0) => {
|
|
67
|
+
const C = or(g), { delay: m = 0, times: N = mt(C), type: V = "keyframes", repeat: Y, repeatType: z, repeatDelay: j = 0, ...$ } = x;
|
|
68
|
+
let { ease: B = e.ease || "easeOut", duration: L } = x;
|
|
69
|
+
const O = typeof m == "function" ? m(P, G) : m, Z = C.length, te = gt(V) ? V : o?.[V];
|
|
70
|
+
if (Z <= 2 && te) {
|
|
71
|
+
let Q = 100;
|
|
72
|
+
if (Z === 2 && sr(C)) {
|
|
73
|
+
const ee = C[1] - C[0];
|
|
74
|
+
Q = Math.abs(ee);
|
|
75
|
+
}
|
|
76
|
+
const J = { ...$ };
|
|
77
|
+
L !== void 0 && (J.duration = wt(L));
|
|
78
|
+
const re = pt(J, Q, te);
|
|
79
|
+
B = re.ease, L = re.duration;
|
|
80
|
+
}
|
|
81
|
+
L ?? (L = i);
|
|
82
|
+
const K = w + O;
|
|
83
|
+
N.length === 1 && N[0] === 0 && (N[1] = 1);
|
|
84
|
+
const ae = N.length - C.length;
|
|
85
|
+
if (ae > 0 && vt(N, ae), C.length === 1 && C.unshift(null), Y) {
|
|
86
|
+
We(Y < rr, "Repeat count too high, must be less than 20"), L = Kt(L, Y);
|
|
87
|
+
const Q = [...C], J = [...N];
|
|
88
|
+
B = Array.isArray(B) ? [...B] : [B];
|
|
89
|
+
const re = [...B];
|
|
90
|
+
for (let ee = 0; ee < Y; ee++) {
|
|
91
|
+
C.push(...Q);
|
|
92
|
+
for (let a = 0; a < Q.length; a++)
|
|
93
|
+
N.push(J[a] + (ee + 1)), B.push(a === 0 ? "linear" : Ye(re, a - 1));
|
|
94
|
+
}
|
|
95
|
+
Jt(N, Y);
|
|
96
|
+
}
|
|
97
|
+
const se = K + L;
|
|
98
|
+
Qt(_, C, B, N, K, se), I = Math.max(O + L, I), R = Math.max(se, R);
|
|
99
|
+
};
|
|
100
|
+
if (ke(F)) {
|
|
101
|
+
const g = ye(F, T);
|
|
102
|
+
U(f, S, Te("default", g));
|
|
103
|
+
} else {
|
|
104
|
+
const g = Xe(F, f, n, b), x = g.length;
|
|
105
|
+
for (let _ = 0; _ < x; _++) {
|
|
106
|
+
f = f, S = S;
|
|
107
|
+
const P = g[_], G = ye(P, T);
|
|
108
|
+
for (const C in f)
|
|
109
|
+
U(f[C], ir(S, C), Te(C, G), _, x);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
v = w, w += I;
|
|
113
|
+
}
|
|
114
|
+
return T.forEach((u, y) => {
|
|
115
|
+
for (const F in u) {
|
|
116
|
+
const f = u[F];
|
|
117
|
+
f.sort(er);
|
|
118
|
+
const S = [], I = [], U = [];
|
|
119
|
+
for (let x = 0; x < f.length; x++) {
|
|
120
|
+
const { at: _, value: P, easing: G } = f[x];
|
|
121
|
+
S.push(P), I.push(bt(0, R, _)), U.push(G || "easeOut");
|
|
122
|
+
}
|
|
123
|
+
I[0] !== 0 && (I.unshift(0), S.unshift(S[0]), U.unshift(tr)), I[I.length - 1] !== 1 && (I.push(1), S.push(null)), l.has(y) || l.set(y, {
|
|
124
|
+
keyframes: {},
|
|
125
|
+
transition: {}
|
|
126
|
+
});
|
|
127
|
+
const g = l.get(y);
|
|
128
|
+
g.keyframes[F] = S, g.transition[F] = {
|
|
129
|
+
...e,
|
|
130
|
+
duration: R,
|
|
131
|
+
ease: U,
|
|
132
|
+
times: I,
|
|
133
|
+
...r
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}), l;
|
|
137
|
+
}
|
|
138
|
+
function ye(t, e) {
|
|
139
|
+
return !e.has(t) && e.set(t, {}), e.get(t);
|
|
140
|
+
}
|
|
141
|
+
function Te(t, e) {
|
|
142
|
+
return e[t] || (e[t] = []), e[t];
|
|
143
|
+
}
|
|
144
|
+
function or(t) {
|
|
145
|
+
return Array.isArray(t) ? t : [t];
|
|
146
|
+
}
|
|
147
|
+
function ir(t, e) {
|
|
148
|
+
return t && t[e] ? {
|
|
149
|
+
...t,
|
|
150
|
+
...t[e]
|
|
151
|
+
} : { ...t };
|
|
152
|
+
}
|
|
153
|
+
const ar = (t) => typeof t == "number", sr = (t) => t.every(ar);
|
|
154
|
+
function cr(t, e) {
|
|
155
|
+
return t in e;
|
|
156
|
+
}
|
|
157
|
+
class lr extends yt {
|
|
158
|
+
constructor() {
|
|
159
|
+
super(...arguments), this.type = "object";
|
|
160
|
+
}
|
|
161
|
+
readValueFromInstance(e, r) {
|
|
162
|
+
if (cr(r, e)) {
|
|
163
|
+
const n = e[r];
|
|
164
|
+
if (typeof n == "string" || typeof n == "number")
|
|
165
|
+
return n;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
getBaseTargetFromProps() {
|
|
169
|
+
}
|
|
170
|
+
removeValueFromRenderState(e, r) {
|
|
171
|
+
delete r.output[e];
|
|
172
|
+
}
|
|
173
|
+
measureInstanceViewportBox() {
|
|
174
|
+
return Tt();
|
|
175
|
+
}
|
|
176
|
+
build(e, r) {
|
|
177
|
+
Object.assign(e.output, r);
|
|
178
|
+
}
|
|
179
|
+
renderInstance(e, { output: r }) {
|
|
180
|
+
Object.assign(e, r);
|
|
181
|
+
}
|
|
182
|
+
sortInstanceNodePosition() {
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function ur(t) {
|
|
187
|
+
const e = {
|
|
188
|
+
presenceContext: null,
|
|
189
|
+
props: {},
|
|
190
|
+
visualState: {
|
|
191
|
+
renderState: {
|
|
192
|
+
transform: {},
|
|
193
|
+
transformOrigin: {},
|
|
194
|
+
style: {},
|
|
195
|
+
vars: {},
|
|
196
|
+
attrs: {}
|
|
197
|
+
},
|
|
198
|
+
latestValues: {}
|
|
199
|
+
}
|
|
200
|
+
}, r = xt(t) && !At(t) ? new Et(e) : new Rt(e);
|
|
201
|
+
r.mount(t), fe.set(t, r);
|
|
202
|
+
}
|
|
203
|
+
function dr(t) {
|
|
204
|
+
const e = {
|
|
205
|
+
presenceContext: null,
|
|
206
|
+
props: {},
|
|
207
|
+
visualState: {
|
|
208
|
+
renderState: {
|
|
209
|
+
output: {}
|
|
210
|
+
},
|
|
211
|
+
latestValues: {}
|
|
212
|
+
}
|
|
213
|
+
}, r = new lr(e);
|
|
214
|
+
r.mount(t), fe.set(t, r);
|
|
215
|
+
}
|
|
216
|
+
function fr(t, e) {
|
|
217
|
+
return ke(t) || typeof t == "number" || typeof t == "string" && !ge(e);
|
|
218
|
+
}
|
|
219
|
+
function $e(t, e, r, n) {
|
|
220
|
+
const o = [];
|
|
221
|
+
if (fr(t, e))
|
|
222
|
+
o.push(Ct(t, ge(e) && e.default || e, r && (r.default || r)));
|
|
223
|
+
else {
|
|
224
|
+
const i = Xe(t, e, n), l = i.length;
|
|
225
|
+
We(!!l, "No valid elements provided.");
|
|
226
|
+
for (let T = 0; T < l; T++) {
|
|
227
|
+
const b = i[T], A = b instanceof Element ? ur : dr;
|
|
228
|
+
fe.has(b) || A(b);
|
|
229
|
+
const v = fe.get(b), w = { ...r };
|
|
230
|
+
"delay" in w && typeof w.delay == "function" && (w.delay = w.delay(T, l)), o.push(...St(v, { ...e, transition: w }, {}));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return o;
|
|
234
|
+
}
|
|
235
|
+
function hr(t, e, r) {
|
|
236
|
+
const n = [];
|
|
237
|
+
return nr(t, e, r, { spring: Lt }).forEach(({ keyframes: i, transition: l }, T) => {
|
|
238
|
+
n.push(...$e(T, i, l));
|
|
239
|
+
}), n;
|
|
240
|
+
}
|
|
241
|
+
class mr {
|
|
242
|
+
constructor(e) {
|
|
243
|
+
this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
|
|
244
|
+
}
|
|
245
|
+
get finished() {
|
|
246
|
+
return Promise.all(this.animations.map((e) => e.finished));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* TODO: Filter out cancelled or stopped animations before returning
|
|
250
|
+
*/
|
|
251
|
+
getAll(e) {
|
|
252
|
+
return this.animations[0][e];
|
|
253
|
+
}
|
|
254
|
+
setAll(e, r) {
|
|
255
|
+
for (let n = 0; n < this.animations.length; n++)
|
|
256
|
+
this.animations[n][e] = r;
|
|
257
|
+
}
|
|
258
|
+
attachTimeline(e) {
|
|
259
|
+
const r = this.animations.map((n) => n.attachTimeline(e));
|
|
260
|
+
return () => {
|
|
261
|
+
r.forEach((n, o) => {
|
|
262
|
+
n && n(), this.animations[o].stop();
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
get time() {
|
|
267
|
+
return this.getAll("time");
|
|
268
|
+
}
|
|
269
|
+
set time(e) {
|
|
270
|
+
this.setAll("time", e);
|
|
271
|
+
}
|
|
272
|
+
get speed() {
|
|
273
|
+
return this.getAll("speed");
|
|
274
|
+
}
|
|
275
|
+
set speed(e) {
|
|
276
|
+
this.setAll("speed", e);
|
|
277
|
+
}
|
|
278
|
+
get state() {
|
|
279
|
+
return this.getAll("state");
|
|
280
|
+
}
|
|
281
|
+
get startTime() {
|
|
282
|
+
return this.getAll("startTime");
|
|
283
|
+
}
|
|
284
|
+
get duration() {
|
|
285
|
+
let e = 0;
|
|
286
|
+
for (let r = 0; r < this.animations.length; r++)
|
|
287
|
+
e = Math.max(e, this.animations[r].duration);
|
|
288
|
+
return e;
|
|
289
|
+
}
|
|
290
|
+
runAll(e) {
|
|
291
|
+
this.animations.forEach((r) => r[e]());
|
|
292
|
+
}
|
|
293
|
+
play() {
|
|
294
|
+
this.runAll("play");
|
|
295
|
+
}
|
|
296
|
+
pause() {
|
|
297
|
+
this.runAll("pause");
|
|
298
|
+
}
|
|
299
|
+
cancel() {
|
|
300
|
+
this.runAll("cancel");
|
|
301
|
+
}
|
|
302
|
+
complete() {
|
|
303
|
+
this.runAll("complete");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
class pr extends mr {
|
|
307
|
+
then(e, r) {
|
|
308
|
+
return this.finished.finally(e).then(() => {
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function vr(t) {
|
|
313
|
+
return Array.isArray(t) && t.some(Array.isArray);
|
|
314
|
+
}
|
|
315
|
+
function gr(t) {
|
|
316
|
+
function e(r, n, o) {
|
|
317
|
+
let i = [];
|
|
318
|
+
return vr(r) ? i = hr(r, n, t) : i = $e(r, n, o, t), new pr(i);
|
|
319
|
+
}
|
|
320
|
+
return e;
|
|
321
|
+
}
|
|
322
|
+
const wr = gr(), br = (t, e) => /* @__PURE__ */ h(
|
|
323
|
+
"svg",
|
|
324
|
+
{
|
|
325
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
326
|
+
fill: "none",
|
|
327
|
+
viewBox: "0 0 24 24",
|
|
328
|
+
ref: e,
|
|
329
|
+
...t,
|
|
330
|
+
children: /* @__PURE__ */ h(
|
|
331
|
+
"path",
|
|
332
|
+
{
|
|
333
|
+
fill: "currentColor",
|
|
334
|
+
d: "M11.9912 16C13.452 16.0001 14.8895 16.4311 16.1289 17.2705C16.6275 17.6086 16.6225 18.3843 16.1221 18.7188C14.8843 19.5444 13.4491 19.9999 11.9912 20C10.4905 19.9999 9.08362 19.5285 7.88184 18.7305C7.37377 18.3931 7.37263 17.6066 7.88086 17.2695C9.11404 16.4517 10.5409 16.0001 11.9912 16ZM5.27051 7.87109C5.60858 7.37248 6.38428 7.37747 6.71875 7.87793C7.54437 9.11572 7.9999 10.5509 8 12.0088C7.99994 13.5095 7.52845 14.9164 6.73047 16.1182C6.39307 16.6262 5.60663 16.6274 5.26953 16.1191C4.45167 14.886 4.00006 13.4591 4 12.0088C4.0001 10.548 4.43107 9.1105 5.27051 7.87109ZM17.2705 7.87109C17.6086 7.37248 18.3843 7.37747 18.7188 7.87793C19.5444 9.11572 19.9999 10.5509 20 12.0088C19.9999 13.5095 19.5285 14.9164 18.7305 16.1182C18.3931 16.6262 17.6066 16.6274 17.2695 16.1191C16.4517 14.886 16.0001 13.4591 16 12.0088C16.0001 10.548 16.4311 9.1105 17.2705 7.87109ZM11.9912 4C13.452 4.0001 14.8895 4.43107 16.1289 5.27051C16.6275 5.60858 16.6225 6.38428 16.1221 6.71875C14.8843 7.54437 13.4491 7.9999 11.9912 8C10.4905 7.99994 9.08362 7.52845 7.88184 6.73047C7.37377 6.39307 7.37263 5.60663 7.88086 5.26953C9.11404 4.45167 10.5409 4.00006 11.9912 4Z",
|
|
335
|
+
vectorEffect: "non-scaling-stroke"
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
), yr = me(br), Tr = [
|
|
340
|
+
"append",
|
|
341
|
+
"className",
|
|
342
|
+
"pressed",
|
|
343
|
+
"compact",
|
|
344
|
+
"noTitle",
|
|
345
|
+
"noAutoTooltip",
|
|
346
|
+
"style",
|
|
347
|
+
"variant",
|
|
348
|
+
"loading",
|
|
349
|
+
"emoji"
|
|
350
|
+
], qe = me((t, e) => {
|
|
351
|
+
const r = Tr.reduce((n, o) => {
|
|
352
|
+
const { [o]: i, ...l } = n;
|
|
353
|
+
return l;
|
|
354
|
+
}, t);
|
|
355
|
+
return /* @__PURE__ */ h(
|
|
356
|
+
It,
|
|
357
|
+
{
|
|
358
|
+
...r,
|
|
359
|
+
variant: "ai",
|
|
360
|
+
ref: e,
|
|
361
|
+
iconRotate: t.icon == yr
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
qe.displayName = "AIButton";
|
|
366
|
+
const fn = ["xs", "sm", "md", "lg"], hn = [
|
|
367
|
+
"inProgress",
|
|
368
|
+
"executing",
|
|
369
|
+
"completed"
|
|
370
|
+
], mn = {
|
|
371
|
+
ai: rt.ai
|
|
372
|
+
}, He = ot(null);
|
|
373
|
+
function pn({
|
|
374
|
+
children: t,
|
|
375
|
+
translations: e
|
|
376
|
+
}) {
|
|
377
|
+
return /* @__PURE__ */ h(He.Provider, { value: e, children: t });
|
|
378
|
+
}
|
|
379
|
+
function vn() {
|
|
380
|
+
const t = it(He);
|
|
381
|
+
if (t === null)
|
|
382
|
+
throw new Error(
|
|
383
|
+
"useAiChatTranslations must be used within an AiChatTranslationsProvider"
|
|
384
|
+
);
|
|
385
|
+
return t;
|
|
386
|
+
}
|
|
387
|
+
function xe(t, e, r, n) {
|
|
388
|
+
const o = Math.max(1, Math.min(t, e)), i = Math.min(r, 20), T = Math.min(i + n, o), b = Math.min(T, Math.floor(t / 2)), A = Math.min(T, Math.floor(e / 2)), v = (K) => K / t * 2 - 1, w = (K) => K / e * 2 - 1, R = 0, u = t, y = 0, F = e, f = b, S = t - b, I = A, U = e - A, g = v(R), x = v(u), _ = w(y), P = w(F), G = v(f), C = v(S), m = w(I), N = w(U), V = 0, Y = 0, z = 1, j = 1, $ = b / t, B = 1 - b / t, L = A / e, O = 1 - A / e, Z = new Float32Array([
|
|
389
|
+
// Top strip
|
|
390
|
+
g,
|
|
391
|
+
_,
|
|
392
|
+
x,
|
|
393
|
+
_,
|
|
394
|
+
g,
|
|
395
|
+
m,
|
|
396
|
+
g,
|
|
397
|
+
m,
|
|
398
|
+
x,
|
|
399
|
+
_,
|
|
400
|
+
x,
|
|
401
|
+
m,
|
|
402
|
+
// Bottom strip
|
|
403
|
+
g,
|
|
404
|
+
N,
|
|
405
|
+
x,
|
|
406
|
+
N,
|
|
407
|
+
g,
|
|
408
|
+
P,
|
|
409
|
+
g,
|
|
410
|
+
P,
|
|
411
|
+
x,
|
|
412
|
+
N,
|
|
413
|
+
x,
|
|
414
|
+
P,
|
|
415
|
+
// Left strip
|
|
416
|
+
g,
|
|
417
|
+
m,
|
|
418
|
+
G,
|
|
419
|
+
m,
|
|
420
|
+
g,
|
|
421
|
+
N,
|
|
422
|
+
g,
|
|
423
|
+
N,
|
|
424
|
+
G,
|
|
425
|
+
m,
|
|
426
|
+
G,
|
|
427
|
+
N,
|
|
428
|
+
// Right strip
|
|
429
|
+
C,
|
|
430
|
+
m,
|
|
431
|
+
x,
|
|
432
|
+
m,
|
|
433
|
+
C,
|
|
434
|
+
N,
|
|
435
|
+
C,
|
|
436
|
+
N,
|
|
437
|
+
x,
|
|
438
|
+
m,
|
|
439
|
+
x,
|
|
440
|
+
N
|
|
441
|
+
]), te = new Float32Array([
|
|
442
|
+
// Top strip
|
|
443
|
+
V,
|
|
444
|
+
Y,
|
|
445
|
+
z,
|
|
446
|
+
Y,
|
|
447
|
+
V,
|
|
448
|
+
L,
|
|
449
|
+
V,
|
|
450
|
+
L,
|
|
451
|
+
z,
|
|
452
|
+
Y,
|
|
453
|
+
z,
|
|
454
|
+
L,
|
|
455
|
+
// Bottom strip
|
|
456
|
+
V,
|
|
457
|
+
O,
|
|
458
|
+
z,
|
|
459
|
+
O,
|
|
460
|
+
V,
|
|
461
|
+
j,
|
|
462
|
+
V,
|
|
463
|
+
j,
|
|
464
|
+
z,
|
|
465
|
+
O,
|
|
466
|
+
z,
|
|
467
|
+
j,
|
|
468
|
+
// Left strip
|
|
469
|
+
V,
|
|
470
|
+
L,
|
|
471
|
+
$,
|
|
472
|
+
L,
|
|
473
|
+
V,
|
|
474
|
+
O,
|
|
475
|
+
V,
|
|
476
|
+
O,
|
|
477
|
+
$,
|
|
478
|
+
L,
|
|
479
|
+
$,
|
|
480
|
+
O,
|
|
481
|
+
// Right strip
|
|
482
|
+
B,
|
|
483
|
+
L,
|
|
484
|
+
z,
|
|
485
|
+
L,
|
|
486
|
+
B,
|
|
487
|
+
O,
|
|
488
|
+
B,
|
|
489
|
+
O,
|
|
490
|
+
z,
|
|
491
|
+
L,
|
|
492
|
+
z,
|
|
493
|
+
O
|
|
494
|
+
]);
|
|
495
|
+
return { positions: Z, uvs: te };
|
|
496
|
+
}
|
|
497
|
+
function Ae(t, e, r) {
|
|
498
|
+
const n = t.createShader(e);
|
|
499
|
+
if (!n) throw new Error("Failed to create shader");
|
|
500
|
+
if (t.shaderSource(n, r), t.compileShader(n), !t.getShaderParameter(n, t.COMPILE_STATUS)) {
|
|
501
|
+
const o = t.getShaderInfoLog(n) || "Unknown shader error";
|
|
502
|
+
throw t.deleteShader(n), new Error(o);
|
|
503
|
+
}
|
|
504
|
+
return n;
|
|
505
|
+
}
|
|
506
|
+
function xr(t, e, r) {
|
|
507
|
+
const n = Ae(t, t.VERTEX_SHADER, e), o = Ae(t, t.FRAGMENT_SHADER, r), i = t.createProgram();
|
|
508
|
+
if (!i) throw new Error("Failed to create program");
|
|
509
|
+
if (t.attachShader(i, n), t.attachShader(i, o), t.linkProgram(i), !t.getProgramParameter(i, t.LINK_STATUS)) {
|
|
510
|
+
const l = t.getProgramInfoLog(i) || "Unknown link error";
|
|
511
|
+
throw t.deleteProgram(i), t.deleteShader(n), t.deleteShader(o), new Error(l);
|
|
512
|
+
}
|
|
513
|
+
return t.deleteShader(n), t.deleteShader(o), i;
|
|
514
|
+
}
|
|
515
|
+
const Ar = `#version 300 es
|
|
516
|
+
precision lowp float;
|
|
517
|
+
|
|
518
|
+
in vec2 vUV;
|
|
519
|
+
out vec4 outColor;
|
|
520
|
+
|
|
521
|
+
uniform vec2 uResolution;
|
|
522
|
+
uniform float uTime;
|
|
523
|
+
uniform float uBorderWidth;
|
|
524
|
+
uniform float uGlowWidth;
|
|
525
|
+
uniform float uBorderRadius;
|
|
526
|
+
uniform vec3 uColors[4];
|
|
527
|
+
|
|
528
|
+
// dark/light mode
|
|
529
|
+
uniform float uGlowExponent;
|
|
530
|
+
uniform float uGlowFactor;
|
|
531
|
+
|
|
532
|
+
const float PI = 3.14159265359;
|
|
533
|
+
const float TWO_PI = 2.0 * PI;
|
|
534
|
+
const float HALF_PI = 0.5 * PI;
|
|
535
|
+
|
|
536
|
+
// Light source parameters (constants)
|
|
537
|
+
const vec4 startPositions = vec4(0.0, PI, HALF_PI, 1.5 * PI);
|
|
538
|
+
const vec4 speeds = vec4(-1.9, -1.9, -1.5, 2.1);
|
|
539
|
+
const vec4 innerRadius = vec4(PI * 0.8, PI * 0.7, PI * 0.3, PI * 0.1);
|
|
540
|
+
const vec4 outerRadius = vec4(PI * 1.2, PI * 0.9, PI * 0.6, PI * 0.4);
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @brief Generates a random float value based on the input 2D coordinates.
|
|
544
|
+
* @param st The input 2D coordinates.
|
|
545
|
+
* @return float A random float value.
|
|
546
|
+
*/
|
|
547
|
+
float random(vec2 st) {
|
|
548
|
+
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
vec2 random2(vec2 st) {
|
|
552
|
+
return vec2(random(st), random(st + 1.0));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Derivative-based Anti-aliasing
|
|
557
|
+
*/
|
|
558
|
+
float aaStep(float edge, float d) {
|
|
559
|
+
// Calculate the width of the anti-aliasing transition
|
|
560
|
+
// This is the distance the value changes over one pixel.
|
|
561
|
+
float width = fwidth(d);
|
|
562
|
+
return smoothstep(edge - width * 0.5, edge + width * 0.5, d);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* @brief Provides an anti-aliased version of fract().
|
|
567
|
+
* @param x The input value.
|
|
568
|
+
* @return float The anti-aliased fractional part of x.
|
|
569
|
+
*/
|
|
570
|
+
float aaFract(float x) {
|
|
571
|
+
float f = fract(x);
|
|
572
|
+
float w = fwidth(x); // Get the width of the transition band for one pixel.
|
|
573
|
+
|
|
574
|
+
// Use smoothstep to fade the line out as it approaches the 1.0 boundary.
|
|
575
|
+
// The fade happens over a distance equal to the pixel width 'w'.
|
|
576
|
+
float smooth_f = f * (1.0 - smoothstep(1.0 - w, 1.0, f));
|
|
577
|
+
|
|
578
|
+
return smooth_f;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @name sdRoundedBox
|
|
583
|
+
* @description Calculates the signed distance from a point to a rounded rectangle.
|
|
584
|
+
* @param {vec2} p - The point coordinates.
|
|
585
|
+
* @param {vec2} b - Half the size of the rectangle (half width and half height).
|
|
586
|
+
* @param {float} r - The corner radius.
|
|
587
|
+
* @returns {float} - Signed distance to the surface of the rounded rectangle.
|
|
588
|
+
*/
|
|
589
|
+
float sdRoundedBox(in vec2 p, in vec2 b, in float r) {
|
|
590
|
+
vec2 q = abs(p) - b + r;
|
|
591
|
+
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* @brief Calculates the smooth inner glow intensity for a rectangle.
|
|
596
|
+
* @param p The current pixel coordinate, centered at (0,0).
|
|
597
|
+
* @param b The half-dimensions of the rectangle.
|
|
598
|
+
* @param radius The radius of the glow/blur.
|
|
599
|
+
* @return float The glow intensity, from 0.0 to 1.0.
|
|
600
|
+
*/
|
|
601
|
+
float getInnerGlow(vec2 p, vec2 b, float radius) {
|
|
602
|
+
// Check if the pixel is outside the rectangle.
|
|
603
|
+
// vec2 d_out = abs(p) - b;
|
|
604
|
+
// if (max(d_out.x, d_out.y) > 0.0) {
|
|
605
|
+
// return 0.0;
|
|
606
|
+
// }
|
|
607
|
+
|
|
608
|
+
// Calculate the distance to the nearest vertical and horizontal edges (positive inwards).
|
|
609
|
+
float dist_x = b.x - abs(p.x);
|
|
610
|
+
float dist_y = b.y - abs(p.y);
|
|
611
|
+
|
|
612
|
+
// Calculate the horizontal and vertical glow intensities independently.
|
|
613
|
+
float glow_x = smoothstep(radius, 0.0, dist_x);
|
|
614
|
+
float glow_y = smoothstep(radius, 0.0, dist_y);
|
|
615
|
+
|
|
616
|
+
// Combine the two directional glows using a screen blend mode: 1.0 - (1.0 - a) * (1.0 - b).
|
|
617
|
+
return 1.0 - (1.0 - glow_x) * (1.0 - glow_y);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
float getVignette(vec2 uv) {
|
|
621
|
+
vec2 vignetteUv = uv;
|
|
622
|
+
vignetteUv = vignetteUv * (1.0 - vignetteUv);
|
|
623
|
+
float vignette = vignetteUv.x * vignetteUv.y * 25.0; // multiply with sth for intensity
|
|
624
|
+
vignette = pow(vignette, 0.16); // change pow for modifying the extend of the vignette
|
|
625
|
+
// vignette = smoothstep(0.0, 0.7, vignette); // smoothstep to avoid hard edges
|
|
626
|
+
vignette = 1.0 - vignette;
|
|
627
|
+
|
|
628
|
+
return vignette;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Convert UV coordinates to angle (0 to 2π) around the border
|
|
633
|
+
*/
|
|
634
|
+
float uvToAngle(vec2 uv) {
|
|
635
|
+
vec2 center = vec2(0.5);
|
|
636
|
+
vec2 dir = uv - center;
|
|
637
|
+
return atan(dir.y, dir.x) + PI;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Get current light center position (angle) based on start position, speed and time
|
|
642
|
+
*/
|
|
643
|
+
// float getLightCenter(float startPos, float speed, float time) {
|
|
644
|
+
// return mod(startPos + speed * time, TWO_PI);
|
|
645
|
+
// }
|
|
646
|
+
|
|
647
|
+
void main() {
|
|
648
|
+
vec2 uv = vUV;
|
|
649
|
+
vec2 pos = uv * uResolution;
|
|
650
|
+
vec2 centeredPos = pos - uResolution * 0.5;
|
|
651
|
+
vec2 size = uResolution - uBorderWidth;
|
|
652
|
+
vec2 halfSize = size * 0.5;
|
|
653
|
+
|
|
654
|
+
// Calculate the signed distance from the rounded rectangle
|
|
655
|
+
float dBorderBox = sdRoundedBox(centeredPos, halfSize, uBorderRadius);
|
|
656
|
+
float border = aaStep(0.0, dBorderBox);
|
|
657
|
+
|
|
658
|
+
// This will create a gradient mask to safely fade out from borders to inner edges.
|
|
659
|
+
float glow = getInnerGlow(centeredPos, halfSize, uGlowWidth);
|
|
660
|
+
// glow = smoothstep(0.0, 0.5, glow);
|
|
661
|
+
// glow = aaFract(glow * 10.0);
|
|
662
|
+
|
|
663
|
+
float vignette = getVignette(uv);
|
|
664
|
+
glow *= vignette;
|
|
665
|
+
|
|
666
|
+
float posAngle = uvToAngle(uv);
|
|
667
|
+
|
|
668
|
+
// vec4 lightCenter = vec4(
|
|
669
|
+
// getLightCenter(startPositions.x, speeds.x, uTime),
|
|
670
|
+
// getLightCenter(startPositions.y, speeds.y, uTime),
|
|
671
|
+
// getLightCenter(startPositions.z, speeds.z, uTime),
|
|
672
|
+
// getLightCenter(startPositions.w, speeds.w, uTime)
|
|
673
|
+
// );
|
|
674
|
+
vec4 lightCenter = mod(startPositions + speeds * uTime, TWO_PI);
|
|
675
|
+
|
|
676
|
+
vec4 angleDist = abs(posAngle - lightCenter);
|
|
677
|
+
|
|
678
|
+
// Calculate shortest angular distance (considering wrap-around)
|
|
679
|
+
vec4 disToLight = min(angleDist, TWO_PI - angleDist) / TWO_PI;
|
|
680
|
+
|
|
681
|
+
float intensityBorder[4];
|
|
682
|
+
intensityBorder[0] = 1.0;
|
|
683
|
+
intensityBorder[1] = smoothstep(0.4, 0.0, disToLight.y);
|
|
684
|
+
intensityBorder[2] = smoothstep(0.4, 0.0, disToLight.z);
|
|
685
|
+
intensityBorder[3] = smoothstep(0.2, 0.0, disToLight.w) * 0.5;
|
|
686
|
+
|
|
687
|
+
// mix these 4 colors with distance
|
|
688
|
+
vec3 borderColor = vec3(0.0);
|
|
689
|
+
for(int i = 0; i < 4; i++) {
|
|
690
|
+
borderColor = mix(borderColor, uColors[i], intensityBorder[i]);
|
|
691
|
+
}
|
|
692
|
+
borderColor *= 1.1;
|
|
693
|
+
|
|
694
|
+
borderColor = clamp(borderColor, 0.0, 1.0);
|
|
695
|
+
|
|
696
|
+
float intensityGlow[4];
|
|
697
|
+
intensityGlow[0] = smoothstep(0.9, 0.0, disToLight.x);
|
|
698
|
+
intensityGlow[1] = smoothstep(0.7, 0.0, disToLight.y);
|
|
699
|
+
intensityGlow[2] = smoothstep(0.4, 0.0, disToLight.z);
|
|
700
|
+
intensityGlow[3] = smoothstep(0.1, 0.0, disToLight.w) * 0.7;
|
|
701
|
+
|
|
702
|
+
// timely breathing effect
|
|
703
|
+
vec4 breath = smoothstep(0.0, 1.0, sin(uTime * 1.0 + startPositions * PI) * 0.2 + 0.8);
|
|
704
|
+
|
|
705
|
+
vec3 glowColor = vec3(0.0);
|
|
706
|
+
glowColor += uColors[0] * intensityGlow[0] * breath.x;
|
|
707
|
+
glowColor += uColors[1] * intensityGlow[1] * breath.y;
|
|
708
|
+
glowColor += uColors[2] * intensityGlow[2] * breath.z;
|
|
709
|
+
glowColor += uColors[3] * intensityGlow[3] * breath.w * glow; // fade it a little bit
|
|
710
|
+
|
|
711
|
+
glow = pow(glow, uGlowExponent);
|
|
712
|
+
glow *= random(pos + uTime) * 0.1 + 1.0;
|
|
713
|
+
glowColor *= glow * uGlowFactor;
|
|
714
|
+
glowColor = clamp(glowColor, 0.0, 1.0);
|
|
715
|
+
|
|
716
|
+
vec3 color = mix(glowColor, borderColor + glowColor * 0.2, border);
|
|
717
|
+
|
|
718
|
+
float alpha = mix(glow, 1.0, border);
|
|
719
|
+
|
|
720
|
+
outColor = vec4(color, alpha);
|
|
721
|
+
}
|
|
722
|
+
`, Er = `#version 300 es
|
|
723
|
+
|
|
724
|
+
in vec2 aPosition;
|
|
725
|
+
in vec2 aUV;
|
|
726
|
+
out vec2 vUV;
|
|
727
|
+
void main() {
|
|
728
|
+
vUV = aUV;
|
|
729
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
730
|
+
}
|
|
731
|
+
`, Rr = [
|
|
732
|
+
"rgb(229, 25, 67)",
|
|
733
|
+
// #E51943 red
|
|
734
|
+
"rgb(229, 86, 25)",
|
|
735
|
+
// #E55619 orange
|
|
736
|
+
"rgb(229, 25, 67)",
|
|
737
|
+
// #E51943 red
|
|
738
|
+
"rgb(161, 173, 229)"
|
|
739
|
+
// #A1ADE5 light blue
|
|
740
|
+
];
|
|
741
|
+
function Cr(t) {
|
|
742
|
+
const e = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
743
|
+
if (!e)
|
|
744
|
+
throw new Error(`Invalid color format: ${t}`);
|
|
745
|
+
const [, r, n, o] = e;
|
|
746
|
+
return [parseInt(r) / 255, parseInt(n) / 255, parseInt(o) / 255];
|
|
747
|
+
}
|
|
748
|
+
class gn {
|
|
749
|
+
element;
|
|
750
|
+
canvas;
|
|
751
|
+
options;
|
|
752
|
+
running = !1;
|
|
753
|
+
disposed = !1;
|
|
754
|
+
startTime = 0;
|
|
755
|
+
lastTime = 0;
|
|
756
|
+
rafId = null;
|
|
757
|
+
glr;
|
|
758
|
+
observer;
|
|
759
|
+
constructor(e = {}) {
|
|
760
|
+
this.options = {
|
|
761
|
+
width: e.width ?? 600,
|
|
762
|
+
height: e.height ?? 600,
|
|
763
|
+
ratio: e.ratio ?? window.devicePixelRatio ?? 1,
|
|
764
|
+
borderWidth: e.borderWidth ?? 8,
|
|
765
|
+
glowWidth: e.glowWidth ?? 200,
|
|
766
|
+
borderRadius: e.borderRadius ?? 8,
|
|
767
|
+
mode: e.mode ?? "light",
|
|
768
|
+
...e
|
|
769
|
+
}, this.canvas = document.createElement("canvas"), this.options.classNames && (this.canvas.className = this.options.classNames), this.options.styles && Object.assign(this.canvas.style, this.options.styles), this.canvas.style.display = "block", this.canvas.style.transformOrigin = "center", this.canvas.style.pointerEvents = "none", this.element = this.canvas, this.setupGL();
|
|
770
|
+
}
|
|
771
|
+
start() {
|
|
772
|
+
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
773
|
+
if (this.running) return;
|
|
774
|
+
if (!this.glr) {
|
|
775
|
+
console.error("WebGL resources are not initialized.");
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
this.running = !0, this.startTime = performance.now(), this.resize(
|
|
779
|
+
this.options.width ?? 600,
|
|
780
|
+
this.options.height ?? 600,
|
|
781
|
+
this.options.ratio
|
|
782
|
+
), this.glr.gl.viewport(0, 0, this.canvas.width, this.canvas.height), this.glr.gl.useProgram(this.glr.program), this.glr.gl.uniform2f(
|
|
783
|
+
this.glr.uResolution,
|
|
784
|
+
this.canvas.width,
|
|
785
|
+
this.canvas.height
|
|
786
|
+
), this.checkGLError(this.glr.gl, "start: after initial setup");
|
|
787
|
+
const e = () => {
|
|
788
|
+
if (!this.running || !this.glr) return;
|
|
789
|
+
this.rafId = requestAnimationFrame(e);
|
|
790
|
+
const r = performance.now();
|
|
791
|
+
if (r - this.lastTime < 1e3 / 32) return;
|
|
792
|
+
this.lastTime = r;
|
|
793
|
+
const o = (r - this.startTime) * 1e-3;
|
|
794
|
+
this.render(o);
|
|
795
|
+
};
|
|
796
|
+
this.rafId = requestAnimationFrame(e);
|
|
797
|
+
}
|
|
798
|
+
pause() {
|
|
799
|
+
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
800
|
+
this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
|
|
801
|
+
}
|
|
802
|
+
dispose() {
|
|
803
|
+
if (this.disposed) return;
|
|
804
|
+
this.disposed = !0, this.running = !1, this.rafId !== null && cancelAnimationFrame(this.rafId);
|
|
805
|
+
const { gl: e, vao: r, positionBuffer: n, uvBuffer: o, program: i } = this.glr;
|
|
806
|
+
r && e.deleteVertexArray(r), n && e.deleteBuffer(n), o && e.deleteBuffer(o), e.deleteProgram(i), this.observer && this.observer.disconnect(), this.canvas.remove();
|
|
807
|
+
}
|
|
808
|
+
resize(e, r, n) {
|
|
809
|
+
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
810
|
+
if (this.options.width = e, this.options.height = r, n && (this.options.ratio = n), !this.running) return;
|
|
811
|
+
const { gl: o, program: i, vao: l, positionBuffer: T, uvBuffer: b, uResolution: A } = this.glr, v = n ?? this.options.ratio ?? window.devicePixelRatio ?? 1, w = Math.max(1, Math.floor(e * v)), R = Math.max(1, Math.floor(r * v));
|
|
812
|
+
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${r}px`, (this.canvas.width !== w || this.canvas.height !== R) && (this.canvas.width = w, this.canvas.height = R), o.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(o, "resize: after viewport setup");
|
|
813
|
+
const { positions: u, uvs: y } = xe(
|
|
814
|
+
this.canvas.width,
|
|
815
|
+
this.canvas.height,
|
|
816
|
+
this.options.borderWidth * v,
|
|
817
|
+
this.options.glowWidth * v
|
|
818
|
+
);
|
|
819
|
+
o.bindVertexArray(l), o.bindBuffer(o.ARRAY_BUFFER, T), o.bufferData(o.ARRAY_BUFFER, u, o.STATIC_DRAW);
|
|
820
|
+
const F = o.getAttribLocation(i, "aPosition");
|
|
821
|
+
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, b), o.bufferData(o.ARRAY_BUFFER, y, o.STATIC_DRAW);
|
|
822
|
+
const f = o.getAttribLocation(i, "aUV");
|
|
823
|
+
o.enableVertexAttribArray(f), o.vertexAttribPointer(f, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after UV buffer update"), o.useProgram(i), o.uniform2f(A, this.canvas.width, this.canvas.height), o.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * v), o.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * v), o.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * v), this.checkGLError(o, "resize: after uniform updates");
|
|
824
|
+
const S = performance.now();
|
|
825
|
+
this.lastTime = S;
|
|
826
|
+
const I = (S - this.startTime) * 1e-3;
|
|
827
|
+
this.render(I);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Automatically resizes the canvas to match the dimensions of the given element.
|
|
831
|
+
* @note using ResizeObserver
|
|
832
|
+
*/
|
|
833
|
+
autoResize(e) {
|
|
834
|
+
this.observer && this.observer.disconnect(), this.observer = new ResizeObserver(() => {
|
|
835
|
+
const r = e.getBoundingClientRect();
|
|
836
|
+
this.resize(r.width, r.height);
|
|
837
|
+
}), this.observer.observe(e);
|
|
838
|
+
}
|
|
839
|
+
fadeIn() {
|
|
840
|
+
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
841
|
+
return new Promise((e, r) => {
|
|
842
|
+
const n = this.canvas.animate(
|
|
843
|
+
[
|
|
844
|
+
{ opacity: 0, transform: "scale(1.2)" },
|
|
845
|
+
{ opacity: 1, transform: "scale(1)" }
|
|
846
|
+
],
|
|
847
|
+
{ duration: 300, easing: "ease-out", fill: "forwards" }
|
|
848
|
+
);
|
|
849
|
+
n.onfinish = () => e(), n.oncancel = () => r("canceled");
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
fadeOut() {
|
|
853
|
+
if (this.disposed) throw new Error("Mask instance has been disposed.");
|
|
854
|
+
return new Promise((e, r) => {
|
|
855
|
+
const n = this.canvas.animate(
|
|
856
|
+
[
|
|
857
|
+
{ opacity: 1, transform: "scale(1)" },
|
|
858
|
+
{ opacity: 0, transform: "scale(1.2)" }
|
|
859
|
+
],
|
|
860
|
+
{ duration: 300, easing: "ease-in", fill: "forwards" }
|
|
861
|
+
);
|
|
862
|
+
n.onfinish = () => e(), n.oncancel = () => r("canceled");
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
checkGLError(e, r) {
|
|
866
|
+
let n = e.getError();
|
|
867
|
+
if (n !== e.NO_ERROR)
|
|
868
|
+
for (console.error(`WebGL Error in ${r}`); n !== e.NO_ERROR; ) {
|
|
869
|
+
const o = this.getGLErrorName(e, n);
|
|
870
|
+
console.error(`${o} (0x${n.toString(16)})`), n = e.getError();
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
getGLErrorName(e, r) {
|
|
874
|
+
switch (r) {
|
|
875
|
+
case e.INVALID_ENUM:
|
|
876
|
+
return "INVALID_ENUM";
|
|
877
|
+
case e.INVALID_VALUE:
|
|
878
|
+
return "INVALID_VALUE";
|
|
879
|
+
case e.INVALID_OPERATION:
|
|
880
|
+
return "INVALID_OPERATION";
|
|
881
|
+
case e.INVALID_FRAMEBUFFER_OPERATION:
|
|
882
|
+
return "INVALID_FRAMEBUFFER_OPERATION";
|
|
883
|
+
case e.OUT_OF_MEMORY:
|
|
884
|
+
return "OUT_OF_MEMORY";
|
|
885
|
+
case e.CONTEXT_LOST_WEBGL:
|
|
886
|
+
return "CONTEXT_LOST_WEBGL";
|
|
887
|
+
default:
|
|
888
|
+
return "UNKNOWN_ERROR";
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
setupGL() {
|
|
892
|
+
const e = this.canvas.getContext("webgl2", {
|
|
893
|
+
antialias: !1,
|
|
894
|
+
alpha: !0
|
|
895
|
+
});
|
|
896
|
+
if (!e)
|
|
897
|
+
throw new Error("WebGL2 is required but not available.");
|
|
898
|
+
const r = xr(e, Er, Ar);
|
|
899
|
+
this.checkGLError(e, "setupGL: after createProgram");
|
|
900
|
+
const n = e.createVertexArray();
|
|
901
|
+
e.bindVertexArray(n), this.checkGLError(e, "setupGL: after VAO creation");
|
|
902
|
+
const o = this.canvas.width || 2, i = this.canvas.height || 2, { positions: l, uvs: T } = xe(
|
|
903
|
+
o,
|
|
904
|
+
i,
|
|
905
|
+
this.options.borderWidth,
|
|
906
|
+
this.options.glowWidth
|
|
907
|
+
), b = e.createBuffer();
|
|
908
|
+
e.bindBuffer(e.ARRAY_BUFFER, b), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
|
|
909
|
+
const A = e.getAttribLocation(r, "aPosition");
|
|
910
|
+
e.enableVertexAttribArray(A), e.vertexAttribPointer(A, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
|
|
911
|
+
const v = e.createBuffer();
|
|
912
|
+
e.bindBuffer(e.ARRAY_BUFFER, v), e.bufferData(e.ARRAY_BUFFER, T, e.STATIC_DRAW);
|
|
913
|
+
const w = e.getAttribLocation(r, "aUV");
|
|
914
|
+
e.enableVertexAttribArray(w), e.vertexAttribPointer(w, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
|
|
915
|
+
const R = e.getUniformLocation(r, "uResolution"), u = e.getUniformLocation(r, "uTime"), y = e.getUniformLocation(r, "uBorderWidth"), F = e.getUniformLocation(r, "uGlowWidth"), f = e.getUniformLocation(r, "uBorderRadius"), S = e.getUniformLocation(r, "uColors"), I = e.getUniformLocation(r, "uGlowExponent"), U = e.getUniformLocation(r, "uGlowFactor");
|
|
916
|
+
e.useProgram(r), e.uniform1f(y, this.options.borderWidth), e.uniform1f(F, this.options.glowWidth), e.uniform1f(f, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(I, 2), e.uniform1f(U, 1.8)) : (e.uniform1f(I, 1), e.uniform1f(U, 1));
|
|
917
|
+
const g = (this.options.colors || Rr).map(Cr);
|
|
918
|
+
for (let x = 0; x < g.length; x++)
|
|
919
|
+
e.uniform3f(
|
|
920
|
+
e.getUniformLocation(r, `uColors[${x}]`),
|
|
921
|
+
...g[x]
|
|
922
|
+
);
|
|
923
|
+
this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
|
|
924
|
+
gl: e,
|
|
925
|
+
program: r,
|
|
926
|
+
vao: n,
|
|
927
|
+
positionBuffer: b,
|
|
928
|
+
uvBuffer: v,
|
|
929
|
+
uResolution: R,
|
|
930
|
+
uTime: u,
|
|
931
|
+
uBorderWidth: y,
|
|
932
|
+
uGlowWidth: F,
|
|
933
|
+
uBorderRadius: f,
|
|
934
|
+
uColors: S
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
render(e) {
|
|
938
|
+
if (!this.glr) return;
|
|
939
|
+
const { gl: r, program: n, vao: o, uTime: i } = this.glr;
|
|
940
|
+
r.useProgram(n), r.bindVertexArray(o), r.uniform1f(i, 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);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const Ee = ["lowp", "mediump", "highp"], Sr = `
|
|
944
|
+
void main(void){
|
|
945
|
+
vec4 color = vec4(0.0,0.0,0.0,1.0);
|
|
946
|
+
mainImage( color, gl_FragCoord.xy );
|
|
947
|
+
gl_FragColor = color;
|
|
948
|
+
}`, Lr = `void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
|
949
|
+
vec2 uv = fragCoord/iResolution.xy;
|
|
950
|
+
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
|
|
951
|
+
fragColor = vec4(col,1.0);
|
|
952
|
+
}`, Re = `attribute vec3 aVertexPosition;
|
|
953
|
+
void main(void) {
|
|
954
|
+
gl_Position = vec4(aVertexPosition, 1.0);
|
|
955
|
+
}`, Ce = "iTime", Se = "iTimeDelta", Le = "iDate", Ie = "iFrame", Fe = "iMouse", _e = "iResolution", Ir = "iChannel", Ne = "iChannelResolution", Pe = "iDeviceOrientation";
|
|
956
|
+
function Fr(t, e) {
|
|
957
|
+
return t.includes("Matrix") && Array.isArray(e);
|
|
958
|
+
}
|
|
959
|
+
function _r(t, e) {
|
|
960
|
+
return t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
|
|
961
|
+
}
|
|
962
|
+
function Nr(t, e) {
|
|
963
|
+
return !t.includes("v") && Array.isArray(e) && e.length > Number.parseInt(t.charAt(0));
|
|
964
|
+
}
|
|
965
|
+
const Pr = (t, e, r, n) => {
|
|
966
|
+
if (Nr(r, n))
|
|
967
|
+
switch (r) {
|
|
968
|
+
case "2f":
|
|
969
|
+
return t.uniform2f(e, n[0], n[1]);
|
|
970
|
+
case "3f":
|
|
971
|
+
return t.uniform3f(e, n[0], n[1], n[2]);
|
|
972
|
+
case "4f":
|
|
973
|
+
return t.uniform4f(e, n[0], n[1], n[2], n[3]);
|
|
974
|
+
case "2i":
|
|
975
|
+
return t.uniform2i(e, n[0], n[1]);
|
|
976
|
+
case "3i":
|
|
977
|
+
return t.uniform3i(e, n[0], n[1], n[2]);
|
|
978
|
+
case "4i":
|
|
979
|
+
return t.uniform4i(e, n[0], n[1], n[2], n[3]);
|
|
980
|
+
}
|
|
981
|
+
if (typeof n == "number")
|
|
982
|
+
return r === "1i" ? t.uniform1i(e, n) : t.uniform1f(e, n);
|
|
983
|
+
switch (r) {
|
|
984
|
+
case "1iv":
|
|
985
|
+
return t.uniform1iv(e, n);
|
|
986
|
+
case "2iv":
|
|
987
|
+
return t.uniform2iv(e, n);
|
|
988
|
+
case "3iv":
|
|
989
|
+
return t.uniform3iv(e, n);
|
|
990
|
+
case "4iv":
|
|
991
|
+
return t.uniform4iv(e, n);
|
|
992
|
+
case "1fv":
|
|
993
|
+
return t.uniform1fv(e, n);
|
|
994
|
+
case "2fv":
|
|
995
|
+
return t.uniform2fv(e, n);
|
|
996
|
+
case "3fv":
|
|
997
|
+
return t.uniform3fv(e, n);
|
|
998
|
+
case "4fv":
|
|
999
|
+
return t.uniform4fv(e, n);
|
|
1000
|
+
case "Matrix2fv":
|
|
1001
|
+
return t.uniformMatrix2fv(e, !1, n);
|
|
1002
|
+
case "Matrix3fv":
|
|
1003
|
+
return t.uniformMatrix3fv(e, !1, n);
|
|
1004
|
+
case "Matrix4fv":
|
|
1005
|
+
return t.uniformMatrix4fv(e, !1, n);
|
|
1006
|
+
}
|
|
1007
|
+
}, Ur = (t) => {
|
|
1008
|
+
switch (t) {
|
|
1009
|
+
case "1f":
|
|
1010
|
+
return "float";
|
|
1011
|
+
case "2f":
|
|
1012
|
+
return "vec2";
|
|
1013
|
+
case "3f":
|
|
1014
|
+
return "vec3";
|
|
1015
|
+
case "4f":
|
|
1016
|
+
return "vec4";
|
|
1017
|
+
case "1i":
|
|
1018
|
+
return "int";
|
|
1019
|
+
case "2i":
|
|
1020
|
+
return "ivec2";
|
|
1021
|
+
case "3i":
|
|
1022
|
+
return "ivec3";
|
|
1023
|
+
case "4i":
|
|
1024
|
+
return "ivec4";
|
|
1025
|
+
case "1iv":
|
|
1026
|
+
return "int";
|
|
1027
|
+
case "2iv":
|
|
1028
|
+
return "ivec2";
|
|
1029
|
+
case "3iv":
|
|
1030
|
+
return "ivec3";
|
|
1031
|
+
case "4iv":
|
|
1032
|
+
return "ivec4";
|
|
1033
|
+
case "1fv":
|
|
1034
|
+
return "float";
|
|
1035
|
+
case "2fv":
|
|
1036
|
+
return "vec2";
|
|
1037
|
+
case "3fv":
|
|
1038
|
+
return "vec3";
|
|
1039
|
+
case "4fv":
|
|
1040
|
+
return "vec4";
|
|
1041
|
+
case "Matrix2fv":
|
|
1042
|
+
return "mat2";
|
|
1043
|
+
case "Matrix3fv":
|
|
1044
|
+
return "mat3";
|
|
1045
|
+
case "Matrix4fv":
|
|
1046
|
+
return "mat4";
|
|
1047
|
+
default:
|
|
1048
|
+
console.error(
|
|
1049
|
+
H(
|
|
1050
|
+
`The uniform type "${t}" is not valid, please make sure your uniform type is valid`
|
|
1051
|
+
)
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
}, ve = 9729, Ue = 9728, Mr = 9987, Me = 33071, Be = 10497;
|
|
1055
|
+
class Br {
|
|
1056
|
+
gl;
|
|
1057
|
+
url;
|
|
1058
|
+
wrapS;
|
|
1059
|
+
wrapT;
|
|
1060
|
+
minFilter;
|
|
1061
|
+
magFilter;
|
|
1062
|
+
source;
|
|
1063
|
+
pow2canvas;
|
|
1064
|
+
isLoaded = !1;
|
|
1065
|
+
isVideo = !1;
|
|
1066
|
+
flipY = -1;
|
|
1067
|
+
width = 0;
|
|
1068
|
+
height = 0;
|
|
1069
|
+
_webglTexture = null;
|
|
1070
|
+
constructor(e) {
|
|
1071
|
+
this.gl = e;
|
|
1072
|
+
}
|
|
1073
|
+
updateTexture = (e, r, n) => {
|
|
1074
|
+
const { gl: o } = this, i = 0, l = o.RGBA, T = o.RGBA, b = o.UNSIGNED_BYTE;
|
|
1075
|
+
o.bindTexture(o.TEXTURE_2D, e), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, n), o.texImage2D(
|
|
1076
|
+
o.TEXTURE_2D,
|
|
1077
|
+
i,
|
|
1078
|
+
l,
|
|
1079
|
+
T,
|
|
1080
|
+
b,
|
|
1081
|
+
r
|
|
1082
|
+
);
|
|
1083
|
+
};
|
|
1084
|
+
setupVideo = (e) => {
|
|
1085
|
+
const r = document.createElement("video");
|
|
1086
|
+
let n = !1, o = !1;
|
|
1087
|
+
r.autoplay = !0, r.muted = !0, r.loop = !0, r.crossOrigin = "anonymous";
|
|
1088
|
+
const i = () => {
|
|
1089
|
+
n && o && (this.isLoaded = !0);
|
|
1090
|
+
};
|
|
1091
|
+
return r.addEventListener(
|
|
1092
|
+
"playing",
|
|
1093
|
+
() => {
|
|
1094
|
+
n = !0, this.width = r.videoWidth || 0, this.height = r.videoHeight || 0, i();
|
|
1095
|
+
},
|
|
1096
|
+
!0
|
|
1097
|
+
), r.addEventListener(
|
|
1098
|
+
"timeupdate",
|
|
1099
|
+
() => {
|
|
1100
|
+
o = !0, i();
|
|
1101
|
+
},
|
|
1102
|
+
!0
|
|
1103
|
+
), r.src = e, r;
|
|
1104
|
+
};
|
|
1105
|
+
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(
|
|
1106
|
+
e,
|
|
1107
|
+
0,
|
|
1108
|
+
0,
|
|
1109
|
+
this.pow2canvas.width,
|
|
1110
|
+
this.pow2canvas.height
|
|
1111
|
+
), console.warn(
|
|
1112
|
+
H(
|
|
1113
|
+
`Image is not power of two ${e.width} x ${e.height}. Resized to ${this.pow2canvas.width} x ${this.pow2canvas.height};`
|
|
1114
|
+
)
|
|
1115
|
+
), this.pow2canvas) : e;
|
|
1116
|
+
load = async (e) => {
|
|
1117
|
+
const { gl: r } = this, {
|
|
1118
|
+
url: n,
|
|
1119
|
+
wrapS: o,
|
|
1120
|
+
wrapT: i,
|
|
1121
|
+
minFilter: l,
|
|
1122
|
+
magFilter: T,
|
|
1123
|
+
flipY: b = -1
|
|
1124
|
+
} = e;
|
|
1125
|
+
if (!n)
|
|
1126
|
+
return Promise.reject(
|
|
1127
|
+
new Error(
|
|
1128
|
+
H(
|
|
1129
|
+
"Missing url, please make sure to pass the url of your texture { url: ... }"
|
|
1130
|
+
)
|
|
1131
|
+
)
|
|
1132
|
+
);
|
|
1133
|
+
const A = /(\.jpg|\.jpeg|\.png|\.gif|\.bmp)$/i.exec(n), v = /(\.mp4|\.3gp|\.webm|\.ogv)$/i.exec(n);
|
|
1134
|
+
if (A === null && v === null)
|
|
1135
|
+
return Promise.reject(
|
|
1136
|
+
new Error(
|
|
1137
|
+
H(
|
|
1138
|
+
`Please upload a video or an image with a valid format (url: ${n})`
|
|
1139
|
+
)
|
|
1140
|
+
)
|
|
1141
|
+
);
|
|
1142
|
+
Object.assign(this, { url: n, wrapS: o, wrapT: i, minFilter: l, magFilter: T, flipY: b });
|
|
1143
|
+
const w = 0, R = r.RGBA, u = 1, y = 1, F = 0, f = r.RGBA, S = r.UNSIGNED_BYTE, I = new Uint8Array([255, 255, 255, 0]), U = r.createTexture();
|
|
1144
|
+
if (r.bindTexture(r.TEXTURE_2D, U), r.texImage2D(
|
|
1145
|
+
r.TEXTURE_2D,
|
|
1146
|
+
w,
|
|
1147
|
+
R,
|
|
1148
|
+
u,
|
|
1149
|
+
y,
|
|
1150
|
+
F,
|
|
1151
|
+
f,
|
|
1152
|
+
S,
|
|
1153
|
+
I
|
|
1154
|
+
), v) {
|
|
1155
|
+
const P = this.setupVideo(n);
|
|
1156
|
+
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);
|
|
1157
|
+
}
|
|
1158
|
+
async function g() {
|
|
1159
|
+
return new Promise((P, G) => {
|
|
1160
|
+
const C = new Image();
|
|
1161
|
+
C.crossOrigin = "anonymous", C.onload = () => {
|
|
1162
|
+
P(C);
|
|
1163
|
+
}, C.onerror = () => {
|
|
1164
|
+
G(new Error(H(`failed loading url: ${n}`)));
|
|
1165
|
+
}, C.src = n ?? "";
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
let x = await g(), _ = (x.width & x.width - 1) === 0 && (x.height & x.height - 1) === 0;
|
|
1169
|
+
return (e.wrapS !== Me || e.wrapT !== Me || e.minFilter !== Ue && e.minFilter !== ve) && !_ && (x = this.makePowerOf2(x), _ = !0), r.bindTexture(r.TEXTURE_2D, U), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, b), r.texImage2D(
|
|
1170
|
+
r.TEXTURE_2D,
|
|
1171
|
+
w,
|
|
1172
|
+
R,
|
|
1173
|
+
f,
|
|
1174
|
+
S,
|
|
1175
|
+
x
|
|
1176
|
+
), _ && e.minFilter !== Ue && e.minFilter !== ve && r.generateMipmap(r.TEXTURE_2D), r.texParameteri(
|
|
1177
|
+
r.TEXTURE_2D,
|
|
1178
|
+
r.TEXTURE_WRAP_S,
|
|
1179
|
+
this.wrapS || Be
|
|
1180
|
+
), r.texParameteri(
|
|
1181
|
+
r.TEXTURE_2D,
|
|
1182
|
+
r.TEXTURE_WRAP_T,
|
|
1183
|
+
this.wrapT || Be
|
|
1184
|
+
), r.texParameteri(
|
|
1185
|
+
r.TEXTURE_2D,
|
|
1186
|
+
r.TEXTURE_MIN_FILTER,
|
|
1187
|
+
this.minFilter || Mr
|
|
1188
|
+
), r.texParameteri(
|
|
1189
|
+
r.TEXTURE_2D,
|
|
1190
|
+
r.TEXTURE_MAG_FILTER,
|
|
1191
|
+
this.magFilter || ve
|
|
1192
|
+
), this._webglTexture = U, this.source = x, this.isVideo = !1, this.isLoaded = !0, this.width = x.width || 0, this.height = x.height || 0, this;
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
const H = (t) => `react-shaders: ${t}`, Oe = (t) => {
|
|
1196
|
+
if ("changedTouches" in t) {
|
|
1197
|
+
const e = t.changedTouches[0];
|
|
1198
|
+
return [e?.clientX ?? 0, e?.clientY ?? 0];
|
|
1199
|
+
}
|
|
1200
|
+
return [t.clientX, t.clientY];
|
|
1201
|
+
}, Ve = (t, e, r) => t * (1 - r) + e * r, Or = (t, e, r) => r > 0 ? t.substring(0, r) + e + t.substring(r, t.length) : e + t;
|
|
1202
|
+
function Vr({
|
|
1203
|
+
fs: t,
|
|
1204
|
+
vs: e = Re,
|
|
1205
|
+
textures: r = [],
|
|
1206
|
+
uniforms: n,
|
|
1207
|
+
clearColor: o = [0, 0, 0, 1],
|
|
1208
|
+
precision: i = "highp",
|
|
1209
|
+
style: l,
|
|
1210
|
+
contextAttributes: T = {},
|
|
1211
|
+
lerp: b = 1,
|
|
1212
|
+
devicePixelRatio: A = 1,
|
|
1213
|
+
onDoneLoadingTextures: v,
|
|
1214
|
+
onError: w = console.error,
|
|
1215
|
+
onWarning: R = console.warn
|
|
1216
|
+
}) {
|
|
1217
|
+
const u = D(null), y = D(null), F = D(null), f = D(null), S = D(void 0), I = D(void 0), U = D(!1), g = D(void 0), x = D(0), _ = D([0, 0]), P = D([]), G = D(0), C = D(void 0), m = D({
|
|
1218
|
+
[Ce]: { type: "float", isNeeded: !1, value: 0 },
|
|
1219
|
+
[Se]: { type: "float", isNeeded: !1, value: 0 },
|
|
1220
|
+
[Le]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1221
|
+
[Fe]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1222
|
+
[_e]: { type: "vec2", isNeeded: !1, value: [0, 0] },
|
|
1223
|
+
[Ie]: { type: "int", isNeeded: !1, value: 0 },
|
|
1224
|
+
[Pe]: {
|
|
1225
|
+
type: "vec4",
|
|
1226
|
+
isNeeded: !1,
|
|
1227
|
+
value: [0, 0, 0, 0]
|
|
1228
|
+
}
|
|
1229
|
+
}), N = D(n), V = (a, c) => {
|
|
1230
|
+
const s = "width" in a ? a.width ?? 0 : 0, p = "height" in a ? a.height ?? 0 : 0, d = m.current.iChannelResolution;
|
|
1231
|
+
if (!d) return;
|
|
1232
|
+
const E = Array.isArray(d.value) ? d.value : d.value = [];
|
|
1233
|
+
E[c * 3] = s * A, E[c * 3 + 1] = p * A, E[c * 3 + 2] = 0;
|
|
1234
|
+
}, Y = () => {
|
|
1235
|
+
u.current && (y.current = u.current.getContext("webgl", T) || u.current.getContext(
|
|
1236
|
+
"experimental-webgl",
|
|
1237
|
+
T
|
|
1238
|
+
), y.current?.getExtension("OES_standard_derivatives"), y.current?.getExtension("EXT_shader_texture_lod"));
|
|
1239
|
+
}, z = () => {
|
|
1240
|
+
const a = y.current;
|
|
1241
|
+
F.current = a?.createBuffer() ?? null, a?.bindBuffer(a.ARRAY_BUFFER, F.current);
|
|
1242
|
+
const c = [
|
|
1243
|
+
1,
|
|
1244
|
+
1,
|
|
1245
|
+
0,
|
|
1246
|
+
-1,
|
|
1247
|
+
1,
|
|
1248
|
+
0,
|
|
1249
|
+
1,
|
|
1250
|
+
-1,
|
|
1251
|
+
0,
|
|
1252
|
+
-1,
|
|
1253
|
+
-1,
|
|
1254
|
+
0
|
|
1255
|
+
];
|
|
1256
|
+
a?.bufferData(a.ARRAY_BUFFER, new Float32Array(c), a.STATIC_DRAW);
|
|
1257
|
+
}, j = ({
|
|
1258
|
+
alpha: a,
|
|
1259
|
+
beta: c,
|
|
1260
|
+
gamma: s
|
|
1261
|
+
}) => {
|
|
1262
|
+
m.current.iDeviceOrientation.value = [
|
|
1263
|
+
a ?? 0,
|
|
1264
|
+
c ?? 0,
|
|
1265
|
+
s ?? 0,
|
|
1266
|
+
window.orientation ?? 0
|
|
1267
|
+
];
|
|
1268
|
+
}, $ = (a) => {
|
|
1269
|
+
const [c = 0, s = 0] = Oe(a), p = c - (g.current?.left ?? 0) - window.pageXOffset, d = (g.current?.height ?? 0) - s - (g.current?.top ?? 0) - window.pageYOffset;
|
|
1270
|
+
U.current = !0;
|
|
1271
|
+
const E = Array.isArray(m.current.iMouse?.value) ? m.current.iMouse.value : void 0;
|
|
1272
|
+
E && (E[2] = p, E[3] = d), _.current[0] = p, _.current[1] = d;
|
|
1273
|
+
}, B = (a) => {
|
|
1274
|
+
g.current = u.current?.getBoundingClientRect();
|
|
1275
|
+
const [c = 0, s = 0] = Oe(a), p = c - (g.current?.left ?? 0), d = (g.current?.height ?? 0) - s - (g.current?.top ?? 0);
|
|
1276
|
+
if (b !== 1)
|
|
1277
|
+
_.current[0] = p, _.current[1] = d;
|
|
1278
|
+
else {
|
|
1279
|
+
const E = Array.isArray(m.current.iMouse?.value) ? m.current.iMouse.value : void 0;
|
|
1280
|
+
E && (E[0] = p, E[1] = d);
|
|
1281
|
+
}
|
|
1282
|
+
}, L = () => {
|
|
1283
|
+
const a = Array.isArray(m.current.iMouse?.value) ? m.current.iMouse.value : void 0;
|
|
1284
|
+
a && (a[2] = 0, a[3] = 0);
|
|
1285
|
+
}, O = () => {
|
|
1286
|
+
const a = y.current;
|
|
1287
|
+
if (!a) return;
|
|
1288
|
+
g.current = u.current?.getBoundingClientRect();
|
|
1289
|
+
const c = A, s = Math.floor(
|
|
1290
|
+
(g.current?.width ?? 1) * c
|
|
1291
|
+
), p = Math.floor(
|
|
1292
|
+
(g.current?.height ?? 1) * c
|
|
1293
|
+
);
|
|
1294
|
+
if (a.canvas.width = s, a.canvas.height = p, m.current.iResolution?.isNeeded && f.current) {
|
|
1295
|
+
const d = a.getUniformLocation(
|
|
1296
|
+
f.current,
|
|
1297
|
+
_e
|
|
1298
|
+
);
|
|
1299
|
+
a.uniform2fv(d, [a.canvas.width, a.canvas.height]);
|
|
1300
|
+
}
|
|
1301
|
+
}, Z = (a, c) => {
|
|
1302
|
+
const s = y.current;
|
|
1303
|
+
if (!s) return null;
|
|
1304
|
+
const p = s.createShader(a);
|
|
1305
|
+
if (!p) return null;
|
|
1306
|
+
if (s.shaderSource(p, c), s.compileShader(p), !s.getShaderParameter(p, s.COMPILE_STATUS)) {
|
|
1307
|
+
R?.(H(`Error compiling the shader:
|
|
1308
|
+
${c}`));
|
|
1309
|
+
const d = s.getShaderInfoLog(p);
|
|
1310
|
+
s.deleteShader(p), w?.(H(`Shader compiler log: ${d}`));
|
|
1311
|
+
}
|
|
1312
|
+
return p;
|
|
1313
|
+
}, te = (a, c) => {
|
|
1314
|
+
const s = y.current;
|
|
1315
|
+
if (!s) return;
|
|
1316
|
+
const p = Z(s.FRAGMENT_SHADER, a), d = Z(s.VERTEX_SHADER, c);
|
|
1317
|
+
if (f.current = s.createProgram(), !(!f.current || !d || !p)) {
|
|
1318
|
+
if (s.attachShader(f.current, d), s.attachShader(f.current, p), s.linkProgram(f.current), !s.getProgramParameter(f.current, s.LINK_STATUS)) {
|
|
1319
|
+
w?.(
|
|
1320
|
+
H(
|
|
1321
|
+
`Unable to initialize the shader program: ${s.getProgramInfoLog(
|
|
1322
|
+
f.current
|
|
1323
|
+
)}`
|
|
1324
|
+
)
|
|
1325
|
+
);
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
s.useProgram(f.current), S.current = s.getAttribLocation(
|
|
1329
|
+
f.current,
|
|
1330
|
+
"aVertexPosition"
|
|
1331
|
+
), s.enableVertexAttribArray(S.current);
|
|
1332
|
+
}
|
|
1333
|
+
}, K = () => {
|
|
1334
|
+
if (n)
|
|
1335
|
+
for (const a of Object.keys(n)) {
|
|
1336
|
+
const c = n[a];
|
|
1337
|
+
if (!c) continue;
|
|
1338
|
+
const { value: s, type: p } = c, d = Ur(p);
|
|
1339
|
+
if (!d) continue;
|
|
1340
|
+
const E = {};
|
|
1341
|
+
if (Fr(p, s)) {
|
|
1342
|
+
const k = p.length, q = Number.parseInt(p.charAt(k - 3)), ne = Math.floor(s.length / (q * q));
|
|
1343
|
+
s.length > q * q && (E.arraySize = `[${ne}]`);
|
|
1344
|
+
} else _r(p, s) && (E.arraySize = `[${Math.floor(s.length / Number.parseInt(p.charAt(0)))}]`);
|
|
1345
|
+
m.current[a] = {
|
|
1346
|
+
type: d,
|
|
1347
|
+
isNeeded: !1,
|
|
1348
|
+
value: s,
|
|
1349
|
+
...E
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
}, ae = () => {
|
|
1353
|
+
const a = y.current;
|
|
1354
|
+
if (a)
|
|
1355
|
+
if (r && r.length > 0) {
|
|
1356
|
+
m.current[`${Ne}`] = {
|
|
1357
|
+
type: "vec3",
|
|
1358
|
+
isNeeded: !1,
|
|
1359
|
+
arraySize: `[${r.length}]`,
|
|
1360
|
+
value: []
|
|
1361
|
+
};
|
|
1362
|
+
const c = r.map(
|
|
1363
|
+
(s, p) => (m.current[`${Ir}${p}`] = {
|
|
1364
|
+
type: "sampler2D",
|
|
1365
|
+
isNeeded: !1
|
|
1366
|
+
}, V(s, p), P.current[p] = new Br(a), P.current[p]?.load(s).then((d) => {
|
|
1367
|
+
V(d, p);
|
|
1368
|
+
}))
|
|
1369
|
+
);
|
|
1370
|
+
Promise.all(c).then(() => {
|
|
1371
|
+
v && v();
|
|
1372
|
+
}).catch((s) => {
|
|
1373
|
+
w?.(s), v && v();
|
|
1374
|
+
});
|
|
1375
|
+
} else v && v();
|
|
1376
|
+
}, se = (a) => {
|
|
1377
|
+
const c = Ee.includes(i ?? "highp"), s = `precision ${c ? i : Ee[1]} float;
|
|
1378
|
+
`;
|
|
1379
|
+
c || R?.(
|
|
1380
|
+
H(
|
|
1381
|
+
`wrong precision type ${i}, please make sure to pass one of a valid precision lowp, mediump, highp, by default you shader precision will be set to highp.`
|
|
1382
|
+
)
|
|
1383
|
+
);
|
|
1384
|
+
let p = s.concat(`#define DPR ${A.toFixed(1)}
|
|
1385
|
+
`).concat(a.replace(/texture\(/g, "texture2D("));
|
|
1386
|
+
for (const E of Object.keys(m.current))
|
|
1387
|
+
if (a.includes(E)) {
|
|
1388
|
+
const k = m.current[E];
|
|
1389
|
+
if (!k) continue;
|
|
1390
|
+
p = Or(
|
|
1391
|
+
p,
|
|
1392
|
+
`uniform ${k.type} ${E}${k.arraySize || ""};
|
|
1393
|
+
`,
|
|
1394
|
+
p.lastIndexOf(s) + s.length
|
|
1395
|
+
), k.isNeeded = !0;
|
|
1396
|
+
}
|
|
1397
|
+
return a.includes("mainImage") && (p = p.concat(Sr)), p;
|
|
1398
|
+
}, Q = (a) => {
|
|
1399
|
+
const c = y.current;
|
|
1400
|
+
if (!c || !f.current) return;
|
|
1401
|
+
const s = G.current ? (a - G.current) / 1e3 : 0;
|
|
1402
|
+
G.current = a;
|
|
1403
|
+
const p = N.current;
|
|
1404
|
+
if (p)
|
|
1405
|
+
for (const d of Object.keys(p)) {
|
|
1406
|
+
const E = p[d];
|
|
1407
|
+
if (E && m.current[d]?.isNeeded) {
|
|
1408
|
+
if (!f.current) return;
|
|
1409
|
+
const k = c.getUniformLocation(
|
|
1410
|
+
f.current,
|
|
1411
|
+
d
|
|
1412
|
+
);
|
|
1413
|
+
if (!k) return;
|
|
1414
|
+
Pr(
|
|
1415
|
+
c,
|
|
1416
|
+
k,
|
|
1417
|
+
E.type,
|
|
1418
|
+
E.value
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
if (m.current.iMouse?.isNeeded) {
|
|
1423
|
+
const d = c.getUniformLocation(
|
|
1424
|
+
f.current,
|
|
1425
|
+
Fe
|
|
1426
|
+
);
|
|
1427
|
+
c.uniform4fv(d, m.current.iMouse.value);
|
|
1428
|
+
}
|
|
1429
|
+
if (m.current.iChannelResolution?.isNeeded) {
|
|
1430
|
+
const d = c.getUniformLocation(
|
|
1431
|
+
f.current,
|
|
1432
|
+
Ne
|
|
1433
|
+
);
|
|
1434
|
+
c.uniform3fv(
|
|
1435
|
+
d,
|
|
1436
|
+
m.current.iChannelResolution.value
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
if (m.current.iDeviceOrientation?.isNeeded) {
|
|
1440
|
+
const d = c.getUniformLocation(
|
|
1441
|
+
f.current,
|
|
1442
|
+
Pe
|
|
1443
|
+
);
|
|
1444
|
+
c.uniform4fv(
|
|
1445
|
+
d,
|
|
1446
|
+
m.current.iDeviceOrientation.value
|
|
1447
|
+
);
|
|
1448
|
+
}
|
|
1449
|
+
if (m.current.iTime?.isNeeded) {
|
|
1450
|
+
const d = c.getUniformLocation(
|
|
1451
|
+
f.current,
|
|
1452
|
+
Ce
|
|
1453
|
+
);
|
|
1454
|
+
c.uniform1f(d, x.current += s);
|
|
1455
|
+
}
|
|
1456
|
+
if (m.current.iTimeDelta?.isNeeded) {
|
|
1457
|
+
const d = c.getUniformLocation(
|
|
1458
|
+
f.current,
|
|
1459
|
+
Se
|
|
1460
|
+
);
|
|
1461
|
+
c.uniform1f(d, s);
|
|
1462
|
+
}
|
|
1463
|
+
if (m.current.iDate?.isNeeded) {
|
|
1464
|
+
const d = /* @__PURE__ */ new Date(), E = d.getMonth() + 1, k = d.getDate(), q = d.getFullYear(), ne = d.getHours() * 60 * 60 + d.getMinutes() * 60 + d.getSeconds() + d.getMilliseconds() * 1e-3, pe = c.getUniformLocation(
|
|
1465
|
+
f.current,
|
|
1466
|
+
Le
|
|
1467
|
+
);
|
|
1468
|
+
c.uniform4fv(pe, [q, E, k, ne]);
|
|
1469
|
+
}
|
|
1470
|
+
if (m.current.iFrame?.isNeeded) {
|
|
1471
|
+
const d = c.getUniformLocation(
|
|
1472
|
+
f.current,
|
|
1473
|
+
Ie
|
|
1474
|
+
), E = m.current.iFrame.value;
|
|
1475
|
+
c.uniform1i(d, E), m.current.iFrame.value = E + 1;
|
|
1476
|
+
}
|
|
1477
|
+
if (P.current.length > 0)
|
|
1478
|
+
for (let d = 0; d < P.current.length; d++) {
|
|
1479
|
+
const E = P.current[d];
|
|
1480
|
+
if (!E) return;
|
|
1481
|
+
const { isVideo: k, _webglTexture: q, source: ne, flipY: pe, isLoaded: et } = E;
|
|
1482
|
+
if (!et || !q || !ne) return;
|
|
1483
|
+
if (m.current[`iChannel${d}`]?.isNeeded) {
|
|
1484
|
+
if (!f.current) return;
|
|
1485
|
+
const tt = c.getUniformLocation(
|
|
1486
|
+
f.current,
|
|
1487
|
+
`iChannel${d}`
|
|
1488
|
+
);
|
|
1489
|
+
c.activeTexture(c.TEXTURE0 + d), c.bindTexture(c.TEXTURE_2D, q), c.uniform1i(tt, d), k && E.updateTexture(
|
|
1490
|
+
q,
|
|
1491
|
+
ne,
|
|
1492
|
+
pe
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}, J = (a) => {
|
|
1497
|
+
const c = y.current;
|
|
1498
|
+
if (!c) return;
|
|
1499
|
+
c.viewport(0, 0, c.drawingBufferWidth, c.drawingBufferHeight), c.clear(c.COLOR_BUFFER_BIT | c.DEPTH_BUFFER_BIT), c.bindBuffer(c.ARRAY_BUFFER, F.current), c.vertexAttribPointer(
|
|
1500
|
+
S.current ?? 0,
|
|
1501
|
+
3,
|
|
1502
|
+
c.FLOAT,
|
|
1503
|
+
!1,
|
|
1504
|
+
0,
|
|
1505
|
+
0
|
|
1506
|
+
), Q(a), c.drawArrays(c.TRIANGLE_STRIP, 0, 4);
|
|
1507
|
+
const s = m.current.iMouse?.value;
|
|
1508
|
+
if (m.current.iMouse?.isNeeded && b !== 1 && Array.isArray(s)) {
|
|
1509
|
+
const p = s[0] ?? 0, d = s[1] ?? 0;
|
|
1510
|
+
s[0] = Ve(p, _.current[0] ?? 0, b), s[1] = Ve(d, _.current[1] ?? 0, b);
|
|
1511
|
+
}
|
|
1512
|
+
I.current = requestAnimationFrame(J);
|
|
1513
|
+
}, re = () => {
|
|
1514
|
+
const a = { passive: !0 };
|
|
1515
|
+
m.current.iMouse?.isNeeded && u.current && (u.current.addEventListener("mousemove", B, a), u.current.addEventListener("mouseout", L, a), u.current.addEventListener("mouseup", L, a), u.current.addEventListener("mousedown", $, a), u.current.addEventListener("touchmove", B, a), u.current.addEventListener("touchend", L, a), u.current.addEventListener("touchstart", $, a)), m.current.iDeviceOrientation?.isNeeded && window.addEventListener(
|
|
1516
|
+
"deviceorientation",
|
|
1517
|
+
j,
|
|
1518
|
+
a
|
|
1519
|
+
), u.current && (C.current = new ResizeObserver(O), C.current.observe(u.current), window.addEventListener("resize", O, a));
|
|
1520
|
+
}, ee = () => {
|
|
1521
|
+
const a = { passive: !0 };
|
|
1522
|
+
m.current.iMouse?.isNeeded && u.current && (u.current.removeEventListener("mousemove", B, a), u.current.removeEventListener("mouseout", L, a), u.current.removeEventListener("mouseup", L, a), u.current.removeEventListener("mousedown", $, a), u.current.removeEventListener("touchmove", B, a), u.current.removeEventListener("touchend", L, a), u.current.removeEventListener("touchstart", $, a)), m.current.iDeviceOrientation?.isNeeded && window.removeEventListener(
|
|
1523
|
+
"deviceorientation",
|
|
1524
|
+
j,
|
|
1525
|
+
a
|
|
1526
|
+
), C.current && (C.current.disconnect(), window.removeEventListener("resize", O, a));
|
|
1527
|
+
};
|
|
1528
|
+
return ue(() => {
|
|
1529
|
+
N.current = n;
|
|
1530
|
+
}, [n]), ue(() => {
|
|
1531
|
+
const a = P.current;
|
|
1532
|
+
function c() {
|
|
1533
|
+
Y();
|
|
1534
|
+
const s = y.current;
|
|
1535
|
+
s && u.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, u.current.width, u.current.height), u.current.height = u.current.clientHeight, u.current.width = u.current.clientWidth, K(), ae(), te(se(t || Lr), e || Re), z(), requestAnimationFrame(J), re(), O());
|
|
1536
|
+
}
|
|
1537
|
+
return requestAnimationFrame(c), () => {
|
|
1538
|
+
const s = y.current;
|
|
1539
|
+
if (s) {
|
|
1540
|
+
if (s.getExtension("WEBGL_lose_context")?.loseContext(), s.useProgram(null), s.deleteProgram(f.current ?? null), a.length > 0)
|
|
1541
|
+
for (const p of a)
|
|
1542
|
+
s.deleteTexture(p._webglTexture);
|
|
1543
|
+
f.current = null;
|
|
1544
|
+
}
|
|
1545
|
+
ee(), cancelAnimationFrame(I.current ?? 0);
|
|
1546
|
+
};
|
|
1547
|
+
}, []), /* @__PURE__ */ h(
|
|
1548
|
+
"canvas",
|
|
1549
|
+
{
|
|
1550
|
+
ref: u,
|
|
1551
|
+
style: { height: "100%", width: "100%", ...l }
|
|
1552
|
+
}
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
const Dr = `
|
|
1556
|
+
const float TAU = 6.283185;
|
|
1557
|
+
|
|
1558
|
+
// Noise for dithering
|
|
1559
|
+
vec2 randFibo(vec2 p) {
|
|
1560
|
+
p = fract(p * vec2(443.897, 441.423));
|
|
1561
|
+
p += dot(p, p.yx + 19.19);
|
|
1562
|
+
return fract((p.xx + p.yx) * p.xy);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// Tonemap
|
|
1566
|
+
vec3 Tonemap(vec3 x) {
|
|
1567
|
+
x *= 4.0;
|
|
1568
|
+
return x / (1.0 + x);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// Luma for alpha
|
|
1572
|
+
float luma(vec3 color) {
|
|
1573
|
+
return dot(color, vec3(0.299, 0.587, 0.114));
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// RGB to HSV
|
|
1577
|
+
vec3 rgb2hsv(vec3 c) {
|
|
1578
|
+
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
1579
|
+
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
|
1580
|
+
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
|
1581
|
+
float d = q.x - min(q.w, q.y);
|
|
1582
|
+
float e = 1.0e-10;
|
|
1583
|
+
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// HSV to RGB
|
|
1587
|
+
vec3 hsv2rgb(vec3 c) {
|
|
1588
|
+
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
1589
|
+
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
1590
|
+
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// SDF shapes
|
|
1594
|
+
float sdCircle(vec2 st, float r) {
|
|
1595
|
+
return length(st) - r;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
float sdLine(vec2 p, float r) {
|
|
1599
|
+
float halfLen = r * 2.0;
|
|
1600
|
+
vec2 a = vec2(-halfLen, 0.0);
|
|
1601
|
+
vec2 b = vec2(halfLen, 0.0);
|
|
1602
|
+
vec2 pa = p - a;
|
|
1603
|
+
vec2 ba = b - a;
|
|
1604
|
+
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
|
|
1605
|
+
return length(pa - ba * h);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
float getSdf(vec2 st) {
|
|
1609
|
+
if(uShape == 1.0) return sdCircle(st, uScale);
|
|
1610
|
+
else if(uShape == 2.0) return sdLine(st, uScale);
|
|
1611
|
+
return sdCircle(st, uScale); // Default
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
vec2 turb(vec2 pos, float t, float it) {
|
|
1615
|
+
// Initial rotation matrix for swirl direction
|
|
1616
|
+
mat2 rotation = mat2(0.6, -0.25, 0.25, 0.9);
|
|
1617
|
+
// Secondary rotation applied each iteration (approx 53 degree rotation)
|
|
1618
|
+
mat2 layerRotation = mat2(0.6, -0.8, 0.8, 0.6);
|
|
1619
|
+
|
|
1620
|
+
float frequency = mix(2.0, 15.0, uFrequency);
|
|
1621
|
+
float amplitude = uAmplitude;
|
|
1622
|
+
float frequencyGrowth = 1.4;
|
|
1623
|
+
float animTime = t * 0.1 * uSpeed;
|
|
1624
|
+
|
|
1625
|
+
const int LAYERS = 4;
|
|
1626
|
+
for(int i = 0; i < LAYERS; i++) {
|
|
1627
|
+
// Calculate wave displacement for this layer
|
|
1628
|
+
vec2 rotatedPos = pos * rotation;
|
|
1629
|
+
vec2 wave = sin(frequency * rotatedPos + float(i) * animTime + it);
|
|
1630
|
+
|
|
1631
|
+
// Apply displacement along rotation direction
|
|
1632
|
+
pos += (amplitude / frequency) * rotation[0] * wave;
|
|
1633
|
+
|
|
1634
|
+
// Evolve parameters for next layer
|
|
1635
|
+
rotation *= layerRotation;
|
|
1636
|
+
amplitude *= mix(1.0, max(wave.x, wave.y), uVariance);
|
|
1637
|
+
frequency *= frequencyGrowth;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
return pos;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const float ITERATIONS = 36.0;
|
|
1644
|
+
|
|
1645
|
+
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
1646
|
+
vec2 uv = fragCoord / iResolution.xy;
|
|
1647
|
+
|
|
1648
|
+
vec3 pp = vec3(0.0);
|
|
1649
|
+
vec3 bloom = vec3(0.0);
|
|
1650
|
+
float t = iTime * 0.5;
|
|
1651
|
+
vec2 pos = uv - 0.5;
|
|
1652
|
+
|
|
1653
|
+
vec2 prevPos = turb(pos, t, 0.0 - 1.0 / ITERATIONS);
|
|
1654
|
+
float spacing = mix(1.0, TAU, uSpacing);
|
|
1655
|
+
|
|
1656
|
+
for(float i = 1.0; i < ITERATIONS + 1.0; i++) {
|
|
1657
|
+
float iter = i / ITERATIONS;
|
|
1658
|
+
vec2 st = turb(pos, t, iter * spacing);
|
|
1659
|
+
float d = abs(getSdf(st));
|
|
1660
|
+
float pd = distance(st, prevPos);
|
|
1661
|
+
prevPos = st;
|
|
1662
|
+
float dynamicBlur = exp2(pd * 2.0 * 1.4426950408889634) - 1.0;
|
|
1663
|
+
float ds = smoothstep(0.0, uBlur * 0.05 + max(dynamicBlur * uSmoothing, 0.001), d);
|
|
1664
|
+
|
|
1665
|
+
// Shift color based on iteration using uColorScale
|
|
1666
|
+
vec3 color = uColor;
|
|
1667
|
+
if(uColorShift > 0.01) {
|
|
1668
|
+
vec3 hsv = rgb2hsv(color);
|
|
1669
|
+
// Shift hue by iteration
|
|
1670
|
+
hsv.x = fract(hsv.x + (1.0 - iter) * uColorShift * 0.3);
|
|
1671
|
+
color = hsv2rgb(hsv);
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
float invd = 1.0 / max(d + dynamicBlur, 0.001);
|
|
1675
|
+
pp += (ds - 1.0) * color;
|
|
1676
|
+
bloom += clamp(invd, 0.0, 250.0) * color;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
pp *= 1.0 / ITERATIONS;
|
|
1680
|
+
|
|
1681
|
+
vec3 color;
|
|
1682
|
+
|
|
1683
|
+
// Dark mode (default)
|
|
1684
|
+
if(uMode < 0.5) {
|
|
1685
|
+
// use bloom effect
|
|
1686
|
+
bloom = bloom / (bloom + 2e4);
|
|
1687
|
+
color = (-pp + bloom * 3.0 * uBloom) * 1.2;
|
|
1688
|
+
color += (randFibo(fragCoord).x - 0.5) / 255.0;
|
|
1689
|
+
color = Tonemap(color);
|
|
1690
|
+
float alpha = luma(color) * uMix;
|
|
1691
|
+
fragColor = vec4(color * uMix, alpha);
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
// Light mode
|
|
1695
|
+
else {
|
|
1696
|
+
// no bloom effect
|
|
1697
|
+
color = -pp;
|
|
1698
|
+
color += (randFibo(fragCoord).x - 0.5) / 255.0;
|
|
1699
|
+
|
|
1700
|
+
// Preserve hue by tone mapping brightness only
|
|
1701
|
+
float brightness = length(color);
|
|
1702
|
+
vec3 direction = brightness > 0.0 ? color / brightness : color;
|
|
1703
|
+
|
|
1704
|
+
// Reinhard on brightness
|
|
1705
|
+
float factor = 2.0;
|
|
1706
|
+
float mappedBrightness = (brightness * factor) / (1.0 + brightness * factor);
|
|
1707
|
+
color = direction * mappedBrightness;
|
|
1708
|
+
|
|
1709
|
+
// Boost saturation to compensate for white background bleed-through
|
|
1710
|
+
// When alpha < 1.0, white bleeds through making colors look desaturated
|
|
1711
|
+
// So we increase saturation to maintain vibrant appearance
|
|
1712
|
+
float gray = dot(color, vec3(0.2, 0.5, 0.1));
|
|
1713
|
+
float saturationBoost = 3.0;
|
|
1714
|
+
color = mix(vec3(gray), color, saturationBoost);
|
|
1715
|
+
|
|
1716
|
+
// Clamp between 0-1
|
|
1717
|
+
color = clamp(color, 0.0, 1.0);
|
|
1718
|
+
|
|
1719
|
+
float alpha = mappedBrightness * clamp(uMix, 1.0, 2.0);
|
|
1720
|
+
fragColor = vec4(color, alpha);
|
|
1721
|
+
}
|
|
1722
|
+
}`, Gr = 10, kr = 2, Wr = 0.5, zr = 0.2, Xr = 1.5, W = {
|
|
1723
|
+
duration: 0.5,
|
|
1724
|
+
ease: "easeOut"
|
|
1725
|
+
}, De = {
|
|
1726
|
+
duration: 0.35,
|
|
1727
|
+
ease: "easeOut",
|
|
1728
|
+
repeat: 1 / 0,
|
|
1729
|
+
repeatType: "mirror"
|
|
1730
|
+
};
|
|
1731
|
+
function ce(t) {
|
|
1732
|
+
const [e, r] = de(t), n = Ft(t), o = D(null);
|
|
1733
|
+
Ht(n, "change", (l) => r(l));
|
|
1734
|
+
const i = at(
|
|
1735
|
+
(l, T) => {
|
|
1736
|
+
o.current = wr(n, l, T);
|
|
1737
|
+
},
|
|
1738
|
+
[n]
|
|
1739
|
+
);
|
|
1740
|
+
return { value: e, motionValue: n, controls: o, animate: i };
|
|
1741
|
+
}
|
|
1742
|
+
function Yr(t, e) {
|
|
1743
|
+
const [r, n] = de(Gr), {
|
|
1744
|
+
value: o,
|
|
1745
|
+
animate: i,
|
|
1746
|
+
motionValue: l
|
|
1747
|
+
} = ce(zr), { value: T, animate: b } = ce(kr), { value: A, animate: v } = ce(Wr), { value: w, animate: R } = ce(Xr), u = qt(e, {
|
|
1748
|
+
fftSize: 512,
|
|
1749
|
+
smoothingTimeConstant: 0.55
|
|
1750
|
+
});
|
|
1751
|
+
return ue(() => {
|
|
1752
|
+
switch (t) {
|
|
1753
|
+
case "idle":
|
|
1754
|
+
case "failed":
|
|
1755
|
+
case "disconnected":
|
|
1756
|
+
n(10), i(0.2, W), b(1.2, W), v(0.4, W), R(1, W);
|
|
1757
|
+
return;
|
|
1758
|
+
case "listening":
|
|
1759
|
+
case "pre-connect-buffering":
|
|
1760
|
+
n(20), i(0.3, { type: "spring", duration: 1, bounce: 0.35 }), b(1, W), v(0.7, W), R([1.5, 2], De);
|
|
1761
|
+
return;
|
|
1762
|
+
case "thinking":
|
|
1763
|
+
case "connecting":
|
|
1764
|
+
case "initializing":
|
|
1765
|
+
n(30), i(0.3, W), b(0.5, W), v(1, W), R([0.5, 2.5], De);
|
|
1766
|
+
return;
|
|
1767
|
+
case "speaking":
|
|
1768
|
+
n(70), i(0.3, W), b(0.75, W), v(1.25, W), R(1.5, W);
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
}, [
|
|
1772
|
+
t,
|
|
1773
|
+
i,
|
|
1774
|
+
b,
|
|
1775
|
+
v,
|
|
1776
|
+
R
|
|
1777
|
+
]), ue(() => {
|
|
1778
|
+
t === "speaking" && u > 0 && !l.isAnimating() && i(0.2 + 0.2 * u, { duration: 0 });
|
|
1779
|
+
}, [
|
|
1780
|
+
t,
|
|
1781
|
+
u,
|
|
1782
|
+
l,
|
|
1783
|
+
i,
|
|
1784
|
+
b,
|
|
1785
|
+
v,
|
|
1786
|
+
R
|
|
1787
|
+
]), {
|
|
1788
|
+
speed: r,
|
|
1789
|
+
scale: o,
|
|
1790
|
+
amplitude: T,
|
|
1791
|
+
frequency: A,
|
|
1792
|
+
brightness: w
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
const $r = ie({
|
|
1796
|
+
base: "aspect-square",
|
|
1797
|
+
variants: {
|
|
1798
|
+
size: {
|
|
1799
|
+
icon: "h-[24px]",
|
|
1800
|
+
sm: "h-[56px]",
|
|
1801
|
+
md: "h-[112px]",
|
|
1802
|
+
lg: "h-[224px]",
|
|
1803
|
+
xl: "h-[448px]"
|
|
1804
|
+
}
|
|
1805
|
+
},
|
|
1806
|
+
defaultVariants: {
|
|
1807
|
+
size: "lg"
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
function qr(t) {
|
|
1811
|
+
const e = t.match(
|
|
1812
|
+
/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
1813
|
+
);
|
|
1814
|
+
if (e) {
|
|
1815
|
+
const [, r, n, o] = e;
|
|
1816
|
+
return [r, n, o].map((l = "00") => parseInt(l, 16) / 255);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
function Ke({
|
|
1820
|
+
shape: t = 1,
|
|
1821
|
+
speed: e = 1,
|
|
1822
|
+
amplitude: r = 0.5,
|
|
1823
|
+
frequency: n = 0.5,
|
|
1824
|
+
scale: o = 0.2,
|
|
1825
|
+
blur: i = 1,
|
|
1826
|
+
color: l = "#FF355E",
|
|
1827
|
+
colorShift: T = 1,
|
|
1828
|
+
brightness: b = 1,
|
|
1829
|
+
themeMode: A = typeof window < "u" && document.documentElement.classList.contains("dark") ? "dark" : "light",
|
|
1830
|
+
ref: v,
|
|
1831
|
+
className: w,
|
|
1832
|
+
...R
|
|
1833
|
+
}) {
|
|
1834
|
+
const u = st(() => qr(l), [l]);
|
|
1835
|
+
return /* @__PURE__ */ h("div", { ref: v, className: w, ...R, children: /* @__PURE__ */ h(
|
|
1836
|
+
Vr,
|
|
1837
|
+
{
|
|
1838
|
+
fs: Dr,
|
|
1839
|
+
devicePixelRatio: globalThis.devicePixelRatio ?? 1,
|
|
1840
|
+
uniforms: {
|
|
1841
|
+
// Aurora wave speed
|
|
1842
|
+
uSpeed: { type: "1f", value: e },
|
|
1843
|
+
// Edge blur/softness
|
|
1844
|
+
uBlur: { type: "1f", value: i },
|
|
1845
|
+
// Shape scale
|
|
1846
|
+
uScale: { type: "1f", value: o },
|
|
1847
|
+
// Shape type: 1=circle, 2=line
|
|
1848
|
+
uShape: { type: "1f", value: t },
|
|
1849
|
+
// Wave frequency and complexity
|
|
1850
|
+
uFrequency: { type: "1f", value: n },
|
|
1851
|
+
// Turbulence amplitude
|
|
1852
|
+
uAmplitude: { type: "1f", value: r },
|
|
1853
|
+
// Light intensity (bloom)
|
|
1854
|
+
uBloom: { type: "1f", value: 0 },
|
|
1855
|
+
// Brightness of the aurora (0-1)
|
|
1856
|
+
uMix: { type: "1f", value: b },
|
|
1857
|
+
// Color variation across layers (0-1)
|
|
1858
|
+
uSpacing: { type: "1f", value: 0.5 },
|
|
1859
|
+
// Color palette offset - shifts colors along the gradient (0-1)
|
|
1860
|
+
uColorShift: { type: "1f", value: T },
|
|
1861
|
+
// Color variation across layers (0-1)
|
|
1862
|
+
uVariance: { type: "1f", value: 0.1 },
|
|
1863
|
+
// Smoothing of the aurora (0-1)
|
|
1864
|
+
uSmoothing: { type: "1f", value: 1 },
|
|
1865
|
+
// Display mode: 0=dark background, 1=light background
|
|
1866
|
+
uMode: { type: "1f", value: A === "light" ? 1 : 0 },
|
|
1867
|
+
// Color
|
|
1868
|
+
uColor: { type: "3fv", value: u ?? [0, 0.7, 1] }
|
|
1869
|
+
},
|
|
1870
|
+
onError: (y) => {
|
|
1871
|
+
console.error("Shader error:", y);
|
|
1872
|
+
},
|
|
1873
|
+
onWarning: (y) => {
|
|
1874
|
+
console.warn("Shader warning:", y);
|
|
1875
|
+
},
|
|
1876
|
+
style: { width: "100%", height: "100%" }
|
|
1877
|
+
}
|
|
1878
|
+
) });
|
|
1879
|
+
}
|
|
1880
|
+
Ke.displayName = "AuraShader";
|
|
1881
|
+
function wn({
|
|
1882
|
+
size: t = "lg",
|
|
1883
|
+
state: e,
|
|
1884
|
+
color: r,
|
|
1885
|
+
colorShift: n = 0.05,
|
|
1886
|
+
audioTrack: o,
|
|
1887
|
+
themeMode: i,
|
|
1888
|
+
className: l,
|
|
1889
|
+
ref: T,
|
|
1890
|
+
...b
|
|
1891
|
+
}) {
|
|
1892
|
+
const { speed: A, scale: v, amplitude: w, frequency: R, brightness: u } = Yr(e, o);
|
|
1893
|
+
return /* @__PURE__ */ h(
|
|
1894
|
+
Ke,
|
|
1895
|
+
{
|
|
1896
|
+
ref: T,
|
|
1897
|
+
blur: 0.2,
|
|
1898
|
+
color: r,
|
|
1899
|
+
colorShift: n,
|
|
1900
|
+
speed: A,
|
|
1901
|
+
scale: v,
|
|
1902
|
+
themeMode: i,
|
|
1903
|
+
amplitude: w,
|
|
1904
|
+
frequency: R,
|
|
1905
|
+
brightness: u,
|
|
1906
|
+
className: X(
|
|
1907
|
+
$r({ size: t }),
|
|
1908
|
+
"overflow-hidden rounded-full",
|
|
1909
|
+
l
|
|
1910
|
+
),
|
|
1911
|
+
...b
|
|
1912
|
+
}
|
|
1913
|
+
);
|
|
1914
|
+
}
|
|
1915
|
+
const bn = ({
|
|
1916
|
+
text: t,
|
|
1917
|
+
confirmationText: e,
|
|
1918
|
+
onConfirm: r,
|
|
1919
|
+
cancelText: n,
|
|
1920
|
+
onCancel: o
|
|
1921
|
+
}) => /* @__PURE__ */ M("div", { className: "flex flex-col gap-2", children: [
|
|
1922
|
+
t && /* @__PURE__ */ h("p", { children: t }),
|
|
1923
|
+
/* @__PURE__ */ M("div", { className: "flex gap-2", children: [
|
|
1924
|
+
/* @__PURE__ */ h(
|
|
1925
|
+
we,
|
|
1926
|
+
{
|
|
1927
|
+
type: "button",
|
|
1928
|
+
variant: "outline",
|
|
1929
|
+
size: "sm",
|
|
1930
|
+
icon: _t,
|
|
1931
|
+
onClick: r,
|
|
1932
|
+
label: e
|
|
1933
|
+
}
|
|
1934
|
+
),
|
|
1935
|
+
/* @__PURE__ */ h(
|
|
1936
|
+
we,
|
|
1937
|
+
{
|
|
1938
|
+
type: "button",
|
|
1939
|
+
variant: "ghost",
|
|
1940
|
+
size: "sm",
|
|
1941
|
+
onClick: o,
|
|
1942
|
+
label: n
|
|
1943
|
+
}
|
|
1944
|
+
)
|
|
1945
|
+
] })
|
|
1946
|
+
] }), Hr = ie({
|
|
1947
|
+
base: [
|
|
1948
|
+
"relative flex flex-col rounded-2xl bg-f1-background",
|
|
1949
|
+
"border border-solid border-f1-border-secondary",
|
|
1950
|
+
"shadow transition-shadow duration-200",
|
|
1951
|
+
"w-[217px] h-[200px] p-4 gap-2"
|
|
1952
|
+
],
|
|
1953
|
+
variants: {
|
|
1954
|
+
selected: {
|
|
1955
|
+
true: "shadow-none",
|
|
1956
|
+
false: "hover:shadow-md"
|
|
1957
|
+
}
|
|
1958
|
+
},
|
|
1959
|
+
defaultVariants: {
|
|
1960
|
+
selected: !1
|
|
1961
|
+
}
|
|
1962
|
+
}), je = ie({
|
|
1963
|
+
base: "text-lg font-semibold text-f1-foreground line-clamp-3"
|
|
1964
|
+
}), Kr = ie({
|
|
1965
|
+
base: "text-sm text-f1-foreground-secondary leading-normal"
|
|
1966
|
+
}), le = ie({
|
|
1967
|
+
base: "text-sm font-medium text-f1-foreground leading-normal"
|
|
1968
|
+
}), jr = ({
|
|
1969
|
+
description: t,
|
|
1970
|
+
isRevealed: e,
|
|
1971
|
+
onAskOne: r
|
|
1972
|
+
}) => {
|
|
1973
|
+
const n = Nt(), o = ze();
|
|
1974
|
+
return /* @__PURE__ */ M(Ge, { children: [
|
|
1975
|
+
t && /* @__PURE__ */ h("span", { className: X(Kr(), "truncate"), children: t }),
|
|
1976
|
+
/* @__PURE__ */ h(Pt, { children: r && e && /* @__PURE__ */ h(
|
|
1977
|
+
he.div,
|
|
1978
|
+
{
|
|
1979
|
+
className: "absolute bottom-4 left-4 z-10",
|
|
1980
|
+
initial: { opacity: 0 },
|
|
1981
|
+
animate: { opacity: 1 },
|
|
1982
|
+
exit: { opacity: 0 },
|
|
1983
|
+
transition: {
|
|
1984
|
+
duration: o ? 0 : 0.2,
|
|
1985
|
+
ease: [0.33, 1, 0.68, 1]
|
|
1986
|
+
},
|
|
1987
|
+
children: /* @__PURE__ */ h(
|
|
1988
|
+
qe,
|
|
1989
|
+
{
|
|
1990
|
+
size: "md",
|
|
1991
|
+
label: n.ai.ask,
|
|
1992
|
+
onClick: (i) => {
|
|
1993
|
+
i.stopPropagation(), r();
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
)
|
|
1997
|
+
}
|
|
1998
|
+
) })
|
|
1999
|
+
] });
|
|
2000
|
+
}, Zr = /* @__PURE__ */ new Set([
|
|
2001
|
+
"person",
|
|
2002
|
+
"people",
|
|
2003
|
+
"team",
|
|
2004
|
+
"company",
|
|
2005
|
+
"alert",
|
|
2006
|
+
"balance"
|
|
2007
|
+
]), Qr = ({ balance: t }) => /* @__PURE__ */ h(
|
|
2008
|
+
Dt,
|
|
2009
|
+
{
|
|
2010
|
+
amount: t.amount,
|
|
2011
|
+
percentage: t.percentage ?? void 0,
|
|
2012
|
+
invertStatus: t.invertStatus,
|
|
2013
|
+
hint: t.hint
|
|
2014
|
+
}
|
|
2015
|
+
), Jr = (t) => {
|
|
2016
|
+
const {
|
|
2017
|
+
heading: e,
|
|
2018
|
+
label: r,
|
|
2019
|
+
content: n,
|
|
2020
|
+
shouldFadeContent: o = !1,
|
|
2021
|
+
fadeTransition: i
|
|
2022
|
+
} = t;
|
|
2023
|
+
return /* @__PURE__ */ M("div", { className: "flex flex-1 flex-col gap-2", children: [
|
|
2024
|
+
/* @__PURE__ */ h("span", { className: X(je()), children: e }),
|
|
2025
|
+
/* @__PURE__ */ M(
|
|
2026
|
+
he.div,
|
|
2027
|
+
{
|
|
2028
|
+
className: "flex flex-1 flex-col justify-end gap-2",
|
|
2029
|
+
animate: { opacity: o ? 0 : 1 },
|
|
2030
|
+
transition: i,
|
|
2031
|
+
children: [
|
|
2032
|
+
n === "person" && /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
|
|
2033
|
+
/* @__PURE__ */ h(
|
|
2034
|
+
Ut,
|
|
2035
|
+
{
|
|
2036
|
+
firstName: t.avatar.firstName,
|
|
2037
|
+
lastName: t.avatar.lastName,
|
|
2038
|
+
src: t.avatar.src,
|
|
2039
|
+
size: "xs"
|
|
2040
|
+
}
|
|
2041
|
+
),
|
|
2042
|
+
r && /* @__PURE__ */ h("span", { className: X(le()), children: r })
|
|
2043
|
+
] }),
|
|
2044
|
+
n === "people" && /* @__PURE__ */ h(
|
|
2045
|
+
Mt,
|
|
2046
|
+
{
|
|
2047
|
+
type: "person",
|
|
2048
|
+
avatars: t.avatars,
|
|
2049
|
+
size: "md",
|
|
2050
|
+
max: 3
|
|
2051
|
+
}
|
|
2052
|
+
),
|
|
2053
|
+
n === "team" && /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
|
|
2054
|
+
/* @__PURE__ */ h(
|
|
2055
|
+
Bt,
|
|
2056
|
+
{
|
|
2057
|
+
name: t.avatar.name,
|
|
2058
|
+
src: t.avatar.src,
|
|
2059
|
+
size: "xs"
|
|
2060
|
+
}
|
|
2061
|
+
),
|
|
2062
|
+
r && /* @__PURE__ */ h("span", { className: X(le()), children: r })
|
|
2063
|
+
] }),
|
|
2064
|
+
n === "company" && /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
|
|
2065
|
+
/* @__PURE__ */ h(
|
|
2066
|
+
Ot,
|
|
2067
|
+
{
|
|
2068
|
+
name: t.avatar.name,
|
|
2069
|
+
src: t.avatar.src,
|
|
2070
|
+
size: "xs"
|
|
2071
|
+
}
|
|
2072
|
+
),
|
|
2073
|
+
r && /* @__PURE__ */ h("span", { className: X(le()), children: r })
|
|
2074
|
+
] }),
|
|
2075
|
+
n === "alert" && /* @__PURE__ */ h(Vt, { text: t.alertLabel, level: t.level }),
|
|
2076
|
+
n === "balance" && /* @__PURE__ */ h(Qr, { balance: t.balance })
|
|
2077
|
+
]
|
|
2078
|
+
}
|
|
2079
|
+
),
|
|
2080
|
+
r && !Zr.has(n) && /* @__PURE__ */ h(
|
|
2081
|
+
he.span,
|
|
2082
|
+
{
|
|
2083
|
+
className: X(le()),
|
|
2084
|
+
animate: { opacity: o ? 0 : 1 },
|
|
2085
|
+
transition: i,
|
|
2086
|
+
children: r
|
|
2087
|
+
}
|
|
2088
|
+
)
|
|
2089
|
+
] });
|
|
2090
|
+
}, Ze = {
|
|
2091
|
+
positive: {
|
|
2092
|
+
stroke: "hsl(var(--positive-50))",
|
|
2093
|
+
fill: "hsl(var(--positive-50))",
|
|
2094
|
+
border: "border-f1-border-positive-bold"
|
|
2095
|
+
},
|
|
2096
|
+
negative: {
|
|
2097
|
+
stroke: "hsl(var(--critical-50))",
|
|
2098
|
+
fill: "hsl(var(--critical-50))",
|
|
2099
|
+
border: "border-f1-border-critical-bold"
|
|
2100
|
+
},
|
|
2101
|
+
neutral: {
|
|
2102
|
+
stroke: "hsl(var(--neutral-50))",
|
|
2103
|
+
fill: "hsl(var(--neutral-50))",
|
|
2104
|
+
border: "border-f1-border"
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
function en(t, e) {
|
|
2108
|
+
const r = t[0]?.value ?? 0, n = t[t.length - 1]?.value ?? 0, o = Math.sign(n - r), i = e ? o * -1 : o;
|
|
2109
|
+
return i > 0 ? "positive" : i < 0 ? "negative" : "neutral";
|
|
2110
|
+
}
|
|
2111
|
+
const tn = ({
|
|
2112
|
+
cx: t,
|
|
2113
|
+
cy: e,
|
|
2114
|
+
index: r,
|
|
2115
|
+
dataLength: n,
|
|
2116
|
+
color: o
|
|
2117
|
+
}) => r !== n - 1 || t == null || e == null ? null : /* @__PURE__ */ h("circle", { cx: t, cy: e, r: 2, fill: o, stroke: "none" }), rn = ({
|
|
2118
|
+
label: t,
|
|
2119
|
+
direction: e
|
|
2120
|
+
}) => {
|
|
2121
|
+
const r = Ze[e];
|
|
2122
|
+
return /* @__PURE__ */ h(
|
|
2123
|
+
"span",
|
|
2124
|
+
{
|
|
2125
|
+
className: X(
|
|
2126
|
+
"absolute right-0 inline-flex items-center rounded-full border border-solid bg-f1-background px-1.5 py-px text-xs font-medium shadow",
|
|
2127
|
+
e === "negative" ? "bottom-0 translate-y-full" : "top-0 -translate-y-full",
|
|
2128
|
+
r.border,
|
|
2129
|
+
{
|
|
2130
|
+
positive: "text-f1-foreground-positive",
|
|
2131
|
+
negative: "text-f1-foreground-critical",
|
|
2132
|
+
neutral: "text-f1-foreground-secondary"
|
|
2133
|
+
}[e]
|
|
2134
|
+
),
|
|
2135
|
+
"data-testid": "sparkline-balance",
|
|
2136
|
+
children: t
|
|
2137
|
+
}
|
|
2138
|
+
);
|
|
2139
|
+
}, nn = ({
|
|
2140
|
+
data: t,
|
|
2141
|
+
label: e,
|
|
2142
|
+
invertStatus: r
|
|
2143
|
+
}) => {
|
|
2144
|
+
const o = `sparkline-gradient-${ct().replace(/:/g, "")}`, i = en(t, r), l = Ze[i];
|
|
2145
|
+
return /* @__PURE__ */ h("div", { className: "flex flex-1 flex-col", children: /* @__PURE__ */ M(
|
|
2146
|
+
"div",
|
|
2147
|
+
{
|
|
2148
|
+
className: "relative w-full flex-1",
|
|
2149
|
+
role: "img",
|
|
2150
|
+
"aria-label": `Sparkline chart showing ${i} trend`,
|
|
2151
|
+
children: [
|
|
2152
|
+
/* @__PURE__ */ h(Gt, { width: "100%", height: "100%", children: /* @__PURE__ */ M(
|
|
2153
|
+
kt,
|
|
2154
|
+
{
|
|
2155
|
+
data: t,
|
|
2156
|
+
margin: { top: 4, right: 4, bottom: 0, left: 0 },
|
|
2157
|
+
children: [
|
|
2158
|
+
/* @__PURE__ */ h("defs", { children: /* @__PURE__ */ M("linearGradient", { id: o, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2159
|
+
/* @__PURE__ */ h("stop", { offset: "5%", stopColor: l.fill, stopOpacity: 0.3 }),
|
|
2160
|
+
/* @__PURE__ */ h("stop", { offset: "95%", stopColor: l.fill, stopOpacity: 0.02 })
|
|
2161
|
+
] }) }),
|
|
2162
|
+
/* @__PURE__ */ h(Wt, { hide: !0, domain: ["dataMin - 1", "dataMax + 1"] }),
|
|
2163
|
+
/* @__PURE__ */ h(
|
|
2164
|
+
zt,
|
|
2165
|
+
{
|
|
2166
|
+
type: "linear",
|
|
2167
|
+
dataKey: "value",
|
|
2168
|
+
stroke: l.stroke,
|
|
2169
|
+
strokeWidth: 1.5,
|
|
2170
|
+
fill: `url(#${o})`,
|
|
2171
|
+
fillOpacity: 1,
|
|
2172
|
+
isAnimationActive: !1,
|
|
2173
|
+
dot: (T) => /* @__PURE__ */ lt(
|
|
2174
|
+
tn,
|
|
2175
|
+
{
|
|
2176
|
+
...T,
|
|
2177
|
+
key: T.index,
|
|
2178
|
+
dataLength: t.length,
|
|
2179
|
+
color: l.stroke
|
|
2180
|
+
}
|
|
2181
|
+
),
|
|
2182
|
+
activeDot: !1
|
|
2183
|
+
}
|
|
2184
|
+
)
|
|
2185
|
+
]
|
|
2186
|
+
}
|
|
2187
|
+
) }),
|
|
2188
|
+
/* @__PURE__ */ h(rn, { label: e, direction: i })
|
|
2189
|
+
]
|
|
2190
|
+
}
|
|
2191
|
+
) });
|
|
2192
|
+
}, Qe = me(
|
|
2193
|
+
(t, e) => {
|
|
2194
|
+
const {
|
|
2195
|
+
description: r,
|
|
2196
|
+
heading: n,
|
|
2197
|
+
label: o,
|
|
2198
|
+
selected: i = !1,
|
|
2199
|
+
onClick: l,
|
|
2200
|
+
onAskOne: T,
|
|
2201
|
+
className: b,
|
|
2202
|
+
...A
|
|
2203
|
+
} = t, [v, w] = de(!1), [R, u] = de(!1), y = v || R, F = ze(), f = y && !!T, S = {
|
|
2204
|
+
duration: F ? 0 : 0.2,
|
|
2205
|
+
ease: [0.33, 1, 0.68, 1]
|
|
2206
|
+
}, I = () => {
|
|
2207
|
+
l?.();
|
|
2208
|
+
}, U = (g) => {
|
|
2209
|
+
g.currentTarget === g.target && (g.key === "Enter" || g.key === " ") && (g.preventDefault(), l?.());
|
|
2210
|
+
};
|
|
2211
|
+
return /* @__PURE__ */ M("div", { className: "relative", children: [
|
|
2212
|
+
i && /* @__PURE__ */ M(Ge, { children: [
|
|
2213
|
+
/* @__PURE__ */ h(
|
|
2214
|
+
"div",
|
|
2215
|
+
{
|
|
2216
|
+
"data-testid": "selected-border",
|
|
2217
|
+
className: X(
|
|
2218
|
+
"absolute -inset-px rounded-2xl",
|
|
2219
|
+
"[--gradient-angle:0deg]",
|
|
2220
|
+
"bg-[conic-gradient(from_var(--gradient-angle),hsla(229,57%,76%,0.7),hsla(348,80%,50%,0.7),hsla(348,80%,50%,0.7),hsla(18,80%,50%,0.7),hsla(229,57%,76%,0.7),hsla(229,57%,76%,0.7))]",
|
|
2221
|
+
"animate-rotate-gradient"
|
|
2222
|
+
)
|
|
2223
|
+
}
|
|
2224
|
+
),
|
|
2225
|
+
/* @__PURE__ */ h(
|
|
2226
|
+
"div",
|
|
2227
|
+
{
|
|
2228
|
+
"aria-hidden": !0,
|
|
2229
|
+
className: X(
|
|
2230
|
+
"pointer-events-none absolute -inset-px rounded-2xl",
|
|
2231
|
+
"[--gradient-angle:0deg]",
|
|
2232
|
+
"bg-[conic-gradient(from_var(--gradient-angle),hsla(229,57%,76%,0.7),hsla(348,80%,50%,0.7),hsla(348,80%,50%,0.7),hsla(18,80%,50%,0.7),hsla(229,57%,76%,0.7),hsla(229,57%,76%,0.7))]",
|
|
2233
|
+
"animate-rotate-gradient opacity-80 blur-sm"
|
|
2234
|
+
)
|
|
2235
|
+
}
|
|
2236
|
+
)
|
|
2237
|
+
] }),
|
|
2238
|
+
/* @__PURE__ */ M(
|
|
2239
|
+
"div",
|
|
2240
|
+
{
|
|
2241
|
+
ref: e,
|
|
2242
|
+
role: l ? "button" : void 0,
|
|
2243
|
+
tabIndex: l ? 0 : void 0,
|
|
2244
|
+
className: X(
|
|
2245
|
+
Hr({ selected: i }),
|
|
2246
|
+
i && "relative border-transparent",
|
|
2247
|
+
l && "cursor-pointer select-none",
|
|
2248
|
+
l && Xt(),
|
|
2249
|
+
b
|
|
2250
|
+
),
|
|
2251
|
+
onClick: l ? I : void 0,
|
|
2252
|
+
onKeyDown: l ? U : void 0,
|
|
2253
|
+
onMouseEnter: () => w(!0),
|
|
2254
|
+
onMouseLeave: () => w(!1),
|
|
2255
|
+
onFocus: () => u(!0),
|
|
2256
|
+
onBlur: () => u(!1),
|
|
2257
|
+
children: [
|
|
2258
|
+
/* @__PURE__ */ h(
|
|
2259
|
+
jr,
|
|
2260
|
+
{
|
|
2261
|
+
description: r,
|
|
2262
|
+
isRevealed: y,
|
|
2263
|
+
onAskOne: T
|
|
2264
|
+
}
|
|
2265
|
+
),
|
|
2266
|
+
A.content === "sparkline" ? /* @__PURE__ */ M("div", { className: "flex flex-1 flex-col gap-2", children: [
|
|
2267
|
+
/* @__PURE__ */ h("span", { className: X(je()), children: n }),
|
|
2268
|
+
/* @__PURE__ */ h(
|
|
2269
|
+
he.div,
|
|
2270
|
+
{
|
|
2271
|
+
className: "-ml-4 flex flex-1 flex-col",
|
|
2272
|
+
animate: { opacity: f ? 0 : 1 },
|
|
2273
|
+
transition: S,
|
|
2274
|
+
children: /* @__PURE__ */ h(
|
|
2275
|
+
nn,
|
|
2276
|
+
{
|
|
2277
|
+
data: A.data,
|
|
2278
|
+
label: o ?? "",
|
|
2279
|
+
invertStatus: A.invertStatus
|
|
2280
|
+
}
|
|
2281
|
+
)
|
|
2282
|
+
}
|
|
2283
|
+
)
|
|
2284
|
+
] }) : /* @__PURE__ */ h(
|
|
2285
|
+
Jr,
|
|
2286
|
+
{
|
|
2287
|
+
heading: n,
|
|
2288
|
+
label: o,
|
|
2289
|
+
shouldFadeContent: f,
|
|
2290
|
+
fadeTransition: S,
|
|
2291
|
+
...A
|
|
2292
|
+
}
|
|
2293
|
+
)
|
|
2294
|
+
]
|
|
2295
|
+
}
|
|
2296
|
+
)
|
|
2297
|
+
] });
|
|
2298
|
+
}
|
|
2299
|
+
);
|
|
2300
|
+
Qe.displayName = "F0AiInsightCardInternal";
|
|
2301
|
+
const on = ["className"], Je = me((t, e) => {
|
|
2302
|
+
const r = on.reduce((n, o) => {
|
|
2303
|
+
const { [o]: i, ...l } = n;
|
|
2304
|
+
return l;
|
|
2305
|
+
}, t);
|
|
2306
|
+
return /* @__PURE__ */ h(Qe, { ref: e, ...r });
|
|
2307
|
+
});
|
|
2308
|
+
Je.displayName = "F0AiInsightCard";
|
|
2309
|
+
const an = () => /* @__PURE__ */ M(
|
|
2310
|
+
"div",
|
|
2311
|
+
{
|
|
2312
|
+
className: "flex w-[217px] h-[200px] flex-col gap-2 rounded-2xl border border-solid border-f1-border-secondary bg-f1-background p-4",
|
|
2313
|
+
"aria-busy": "true",
|
|
2314
|
+
"aria-live": "polite",
|
|
2315
|
+
children: [
|
|
2316
|
+
/* @__PURE__ */ h(oe, { className: "h-3 w-3/4 rounded" }),
|
|
2317
|
+
/* @__PURE__ */ M("div", { className: "flex flex-1 flex-col justify-end gap-2", children: [
|
|
2318
|
+
/* @__PURE__ */ M("div", { className: "flex flex-col gap-1.5", children: [
|
|
2319
|
+
/* @__PURE__ */ h(oe, { className: "h-5 w-full rounded" }),
|
|
2320
|
+
/* @__PURE__ */ h(oe, { className: "h-5 w-2/3 rounded" })
|
|
2321
|
+
] }),
|
|
2322
|
+
/* @__PURE__ */ M("div", { className: "flex items-center gap-1.5", children: [
|
|
2323
|
+
/* @__PURE__ */ h(oe, { className: "h-5 w-5 rounded-full" }),
|
|
2324
|
+
/* @__PURE__ */ h(oe, { className: "h-3 w-20 rounded" })
|
|
2325
|
+
] })
|
|
2326
|
+
] })
|
|
2327
|
+
]
|
|
2328
|
+
}
|
|
2329
|
+
), yn = Yt(
|
|
2330
|
+
$t(Je, an)
|
|
2331
|
+
), Tn = [
|
|
2332
|
+
"text",
|
|
2333
|
+
"person",
|
|
2334
|
+
"people",
|
|
2335
|
+
"team",
|
|
2336
|
+
"company",
|
|
2337
|
+
"alert",
|
|
2338
|
+
"balance",
|
|
2339
|
+
"sparkline"
|
|
2340
|
+
];
|
|
2341
|
+
export {
|
|
2342
|
+
pn as A,
|
|
2343
|
+
gn as F,
|
|
2344
|
+
mn as a,
|
|
2345
|
+
hn as b,
|
|
2346
|
+
wn as c,
|
|
2347
|
+
bn as d,
|
|
2348
|
+
yn as e,
|
|
2349
|
+
Tn as f,
|
|
2350
|
+
qe as g,
|
|
2351
|
+
yr as h,
|
|
2352
|
+
fn as o,
|
|
2353
|
+
vn as u
|
|
2354
|
+
};
|