@tsogtoodev/shingen-metal 1.0.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/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/index.cjs.js +421 -0
- package/dist/index.d.ts +321 -0
- package/dist/index.es.js +1605 -0
- package/package.json +60 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1605 @@
|
|
|
1
|
+
import { defineComponent as gt, ref as Y, computed as ue, watch as z, onMounted as Qe, nextTick as Ce, onBeforeUnmount as Je, openBlock as xt, createElementBlock as vt, normalizeStyle as ke, unref as bt, createElementVNode as te, renderSlot as wt, toValue as yt } from "vue";
|
|
2
|
+
function _t(e) {
|
|
3
|
+
let t = e.replace("#", "");
|
|
4
|
+
return t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]), [parseInt(t.slice(0, 2), 16) / 255, parseInt(t.slice(2, 4), 16) / 255, parseInt(t.slice(4, 6), 16) / 255];
|
|
5
|
+
}
|
|
6
|
+
function Mt(e, t, a) {
|
|
7
|
+
e /= 255, t /= 255, a /= 255;
|
|
8
|
+
const n = Math.max(e, t, a), o = Math.min(e, t, a), r = n - o;
|
|
9
|
+
let s = 0;
|
|
10
|
+
const c = n === 0 ? 0 : r / n;
|
|
11
|
+
return r !== 0 && (n === e ? s = ((t - a) / r + 6) % 6 : n === t ? s = (a - e) / r + 2 : s = (e - t) / r + 4, s /= 6), [s, c, n];
|
|
12
|
+
}
|
|
13
|
+
function St(e, t, a) {
|
|
14
|
+
const n = Math.floor(e * 6), o = e * 6 - n, r = a * (1 - t), s = a * (1 - o * t), c = a * (1 - (1 - o) * t);
|
|
15
|
+
let l = 0, d = 0, f = 0;
|
|
16
|
+
switch (n % 6) {
|
|
17
|
+
case 0:
|
|
18
|
+
l = a, d = c, f = r;
|
|
19
|
+
break;
|
|
20
|
+
case 1:
|
|
21
|
+
l = s, d = a, f = r;
|
|
22
|
+
break;
|
|
23
|
+
case 2:
|
|
24
|
+
l = r, d = a, f = c;
|
|
25
|
+
break;
|
|
26
|
+
case 3:
|
|
27
|
+
l = r, d = s, f = a;
|
|
28
|
+
break;
|
|
29
|
+
case 4:
|
|
30
|
+
l = c, d = r, f = a;
|
|
31
|
+
break;
|
|
32
|
+
case 5:
|
|
33
|
+
l = a, d = r, f = s;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return [Math.round(l * 255), Math.round(d * 255), Math.round(f * 255)];
|
|
37
|
+
}
|
|
38
|
+
const Rt = 66, At = 66, Tt = 1500, Ct = 1, Ee = 16, kt = 16, Et = 8, Lt = 96, Ot = 2, It = {
|
|
39
|
+
name: "chromatic",
|
|
40
|
+
modes: {
|
|
41
|
+
dark: {
|
|
42
|
+
colors: ["#000000", "#aae8ff", "#c5fe9e", "#f7888d", "#0d0d0d", "#fffdc3", "#007cff"],
|
|
43
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
44
|
+
direction: 80,
|
|
45
|
+
speed: 1.2,
|
|
46
|
+
intensity: 2,
|
|
47
|
+
scale: 1.6,
|
|
48
|
+
softness: 0.18,
|
|
49
|
+
distortion: 0.3,
|
|
50
|
+
complexity: 0.68,
|
|
51
|
+
shape: 1,
|
|
52
|
+
blur: 1,
|
|
53
|
+
vignette: 0.26,
|
|
54
|
+
vigOpacity: 0.6,
|
|
55
|
+
shaderOpacity: 1
|
|
56
|
+
},
|
|
57
|
+
light: {
|
|
58
|
+
colors: ["#ffffff", "#ffffff", "#ffffff", "#ffb3b3", "#adadad", "#f5ff70", "#007cff"],
|
|
59
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
60
|
+
direction: 80,
|
|
61
|
+
speed: 1.2,
|
|
62
|
+
intensity: 2,
|
|
63
|
+
scale: 2.5,
|
|
64
|
+
softness: 0.18,
|
|
65
|
+
distortion: 0.3,
|
|
66
|
+
complexity: 0.68,
|
|
67
|
+
shape: 1,
|
|
68
|
+
blur: 1,
|
|
69
|
+
vignette: 0.24,
|
|
70
|
+
vigOpacity: 0.16,
|
|
71
|
+
shaderOpacity: 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, Pt = {
|
|
75
|
+
name: "silver",
|
|
76
|
+
modes: {
|
|
77
|
+
dark: {
|
|
78
|
+
colors: ["#000000", "#dedede", "#747270", "#e5e5e5", "#0d0d0d", "#ffffff", "#e6e6e6"],
|
|
79
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
80
|
+
direction: 80,
|
|
81
|
+
speed: 1.2,
|
|
82
|
+
intensity: 2,
|
|
83
|
+
scale: 2.5,
|
|
84
|
+
softness: 0.18,
|
|
85
|
+
distortion: 0.3,
|
|
86
|
+
complexity: 0.68,
|
|
87
|
+
shape: 1,
|
|
88
|
+
blur: 1,
|
|
89
|
+
vignette: 0.26,
|
|
90
|
+
vigOpacity: 0.6,
|
|
91
|
+
shaderOpacity: 0.88
|
|
92
|
+
},
|
|
93
|
+
light: {
|
|
94
|
+
colors: ["#f6f6f6", "#ffffff", "#ffffff", "#f7f7f7", "#c9c9c9", "#d0d0d0", "#d1d1d1"],
|
|
95
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
96
|
+
direction: 80,
|
|
97
|
+
speed: 1.2,
|
|
98
|
+
intensity: 2,
|
|
99
|
+
scale: 2.5,
|
|
100
|
+
softness: 0.18,
|
|
101
|
+
distortion: 0.3,
|
|
102
|
+
complexity: 0.68,
|
|
103
|
+
shape: 1,
|
|
104
|
+
blur: 1,
|
|
105
|
+
vignette: 0.2,
|
|
106
|
+
vigOpacity: 0.26,
|
|
107
|
+
shaderOpacity: 1
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, Ft = {
|
|
111
|
+
name: "gold",
|
|
112
|
+
modes: {
|
|
113
|
+
dark: {
|
|
114
|
+
colors: ["#000000", "#ffffff", "#ffffff", "#f7d488", "#0d0d0d", "#fffdc3", "#ffffff"],
|
|
115
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
116
|
+
direction: 80,
|
|
117
|
+
speed: 1,
|
|
118
|
+
intensity: 2,
|
|
119
|
+
scale: 2.5,
|
|
120
|
+
softness: 0.18,
|
|
121
|
+
distortion: 0.3,
|
|
122
|
+
complexity: 0.68,
|
|
123
|
+
shape: 1,
|
|
124
|
+
blur: 1,
|
|
125
|
+
vignette: 0.26,
|
|
126
|
+
vigOpacity: 0.6,
|
|
127
|
+
shaderOpacity: 0.92
|
|
128
|
+
},
|
|
129
|
+
light: {
|
|
130
|
+
colors: ["#fff8e1", "#fffbe0", "#ffffff", "#fff6d6", "#d2c7a7", "#dcd2bc", "#f9f7e5"],
|
|
131
|
+
alphas: [1, 1, 1, 1, 1, 1, 1],
|
|
132
|
+
direction: 80,
|
|
133
|
+
speed: 1.2,
|
|
134
|
+
intensity: 2,
|
|
135
|
+
scale: 2.5,
|
|
136
|
+
softness: 0.18,
|
|
137
|
+
distortion: 0.3,
|
|
138
|
+
complexity: 0.68,
|
|
139
|
+
shape: 1,
|
|
140
|
+
blur: 1,
|
|
141
|
+
vignette: 0.22,
|
|
142
|
+
vigOpacity: 0.24,
|
|
143
|
+
shaderOpacity: 1
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, Ze = {
|
|
147
|
+
chromatic: It,
|
|
148
|
+
silver: Pt,
|
|
149
|
+
gold: Ft
|
|
150
|
+
}, $t = (
|
|
151
|
+
/* glsl */
|
|
152
|
+
`
|
|
153
|
+
attribute vec2 a_position;
|
|
154
|
+
void main() { gl_Position = vec4(a_position, 0.0, 1.0); }
|
|
155
|
+
`
|
|
156
|
+
), Ht = (
|
|
157
|
+
/* glsl */
|
|
158
|
+
`
|
|
159
|
+
precision highp float;
|
|
160
|
+
|
|
161
|
+
uniform vec2 u_resolution;
|
|
162
|
+
uniform float u_time;
|
|
163
|
+
uniform vec3 u_color1, u_color2, u_color3, u_color4, u_color5, u_color6, u_color7;
|
|
164
|
+
uniform float u_alpha1, u_alpha2, u_alpha3, u_alpha4, u_alpha5, u_alpha6, u_alpha7;
|
|
165
|
+
uniform float u_intensity, u_scale, u_direction;
|
|
166
|
+
uniform float u_softness, u_distortion, u_complexity, u_shape;
|
|
167
|
+
uniform float u_vignette, u_vigOpacity, u_blur, u_shaderOpacity;
|
|
168
|
+
|
|
169
|
+
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
|
170
|
+
vec2 mod289v2(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
|
171
|
+
vec3 permute(vec3 x) { return mod289((x * 34.0 + 1.0) * x); }
|
|
172
|
+
|
|
173
|
+
float snoise(vec2 v) {
|
|
174
|
+
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
|
|
175
|
+
-0.577350269189626, 0.024390243902439);
|
|
176
|
+
vec2 i = floor(v + dot(v, C.yy));
|
|
177
|
+
vec2 x0 = v - i + dot(i, C.xx);
|
|
178
|
+
vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
|
179
|
+
vec4 x12 = x0.xyxy + C.xxzz;
|
|
180
|
+
x12.xy -= i1;
|
|
181
|
+
i = mod289v2(i);
|
|
182
|
+
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
|
|
183
|
+
vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
|
|
184
|
+
m = m * m; m = m * m;
|
|
185
|
+
vec3 x_ = 2.0 * fract(p * C.www) - 1.0;
|
|
186
|
+
vec3 h = abs(x_) - 0.5;
|
|
187
|
+
vec3 ox = floor(x_ + 0.5);
|
|
188
|
+
vec3 a0 = x_ - ox;
|
|
189
|
+
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
|
|
190
|
+
vec3 g;
|
|
191
|
+
g.x = a0.x * x0.x + h.x * x0.y;
|
|
192
|
+
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
193
|
+
return 130.0 * dot(m, g);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
float fbm(vec2 p, float oct) {
|
|
197
|
+
float val = 0.0, amp = 0.5;
|
|
198
|
+
int n = int(oct);
|
|
199
|
+
for (int i = 0; i < 7; i++) {
|
|
200
|
+
if (i >= n) break;
|
|
201
|
+
val += amp * snoise(p);
|
|
202
|
+
p *= 2.0;
|
|
203
|
+
amp *= 0.5;
|
|
204
|
+
}
|
|
205
|
+
return val;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
float nfbm(vec2 p) { return fbm(p, 3.0 + u_complexity * 4.0); }
|
|
209
|
+
|
|
210
|
+
/* 5-stop palette used by effect 1 (Plasma) — direct port of \`palette\` from
|
|
211
|
+
* the canonical engine. Stops at t = 0, 0.25, 0.5, 0.75, 1.0. */
|
|
212
|
+
vec3 palette(float t) {
|
|
213
|
+
t = clamp(t, 0.0, 1.0);
|
|
214
|
+
t = t * t * (3.0 - 2.0 * t);
|
|
215
|
+
float k = 64.0;
|
|
216
|
+
float w1 = u_alpha1 * exp(-k * t * t);
|
|
217
|
+
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
|
|
218
|
+
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
|
|
219
|
+
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
|
|
220
|
+
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
|
|
221
|
+
float total = w1 + w2 + w3 + w4 + w5 + 0.0001;
|
|
222
|
+
return (u_color1 * w1 + u_color2 * w2 + u_color3 * w3 +
|
|
223
|
+
u_color4 * w4 + u_color5 * w5) / total;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* Per-pixel alpha that re-introduces transparency when the user dials any
|
|
227
|
+
* palette stop's alpha below 1. Same \`paletteAlpha\` from the canonical
|
|
228
|
+
* engine. With every preset shipping all-1 alphas, this returns ~1 for every
|
|
229
|
+
* pixel — but mirroring it keeps custom-preset behaviour identical. */
|
|
230
|
+
float paletteAlpha(float t) {
|
|
231
|
+
t = clamp(t, 0.0, 1.0);
|
|
232
|
+
t = t * t * (3.0 - 2.0 * t);
|
|
233
|
+
float k = 64.0;
|
|
234
|
+
float w1 = u_alpha1 * exp(-k * t * t);
|
|
235
|
+
float w2 = u_alpha2 * exp(-k * (t - 0.25) * (t - 0.25));
|
|
236
|
+
float w3 = u_alpha3 * exp(-k * (t - 0.5) * (t - 0.5));
|
|
237
|
+
float w4 = u_alpha4 * exp(-k * (t - 0.75) * (t - 0.75));
|
|
238
|
+
float w5 = u_alpha5 * exp(-k * (t - 1.0) * (t - 1.0));
|
|
239
|
+
float totalW = w1 + w2 + w3 + w4 + w5 + 0.0001;
|
|
240
|
+
float rawW = exp(-k * t * t)
|
|
241
|
+
+ exp(-k * (t - 0.25) * (t - 0.25))
|
|
242
|
+
+ exp(-k * (t - 0.5) * (t - 0.5))
|
|
243
|
+
+ exp(-k * (t - 0.75) * (t - 0.75))
|
|
244
|
+
+ exp(-k * (t - 1.0) * (t - 1.0))
|
|
245
|
+
+ 0.0001;
|
|
246
|
+
return totalW / rawW;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
vec2 warp(vec2 p, float t) {
|
|
250
|
+
float str = u_distortion * 2.0;
|
|
251
|
+
return vec2(
|
|
252
|
+
nfbm(p + vec2(t * 0.1, 0.0)),
|
|
253
|
+
nfbm(p + vec2(0.0, t * 0.12) + 5.0)
|
|
254
|
+
) * str;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Plasma: four sine bands warped by an FBM field, mapped through the
|
|
258
|
+
* 5-stop palette. Identical to effect 1 in the canonical engine. */
|
|
259
|
+
vec3 computeEffect(vec2 uv, float aspect, float t, float dist, float cpx) {
|
|
260
|
+
vec2 p = (uv - 0.5) * u_scale;
|
|
261
|
+
p.x *= aspect;
|
|
262
|
+
p += vec2(cos(u_direction), sin(u_direction)) * t * 0.15;
|
|
263
|
+
|
|
264
|
+
float freq = 3.0 + cpx * 8.0;
|
|
265
|
+
float val = 0.0;
|
|
266
|
+
val += sin(p.x * freq + t);
|
|
267
|
+
val += sin(p.y * freq + t * 1.3);
|
|
268
|
+
val += sin((p.x + p.y) * freq * 0.7 + t * 0.7);
|
|
269
|
+
val += sin(length(p) * freq * 0.8 - t * 1.5);
|
|
270
|
+
vec2 w = warp(p, t);
|
|
271
|
+
val += (w.x + w.y) * dist;
|
|
272
|
+
val = val * 0.2 * u_intensity + 0.5;
|
|
273
|
+
|
|
274
|
+
return palette(clamp(val, 0.0, 1.0));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void main() {
|
|
278
|
+
vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
279
|
+
float aspect = u_resolution.x / u_resolution.y;
|
|
280
|
+
float t = u_time; // JS already multiplied u_time by preset.speed.
|
|
281
|
+
float dist = u_distortion;
|
|
282
|
+
float cpx = u_complexity;
|
|
283
|
+
|
|
284
|
+
/* 5-tap cross blur (center + cardinal offsets). The chromatic/silver/gold
|
|
285
|
+
* presets all ship with blur=1 so this path is always active. 5 taps
|
|
286
|
+
* instead of the canonical engine's 9 saves ~44% fragment work; the
|
|
287
|
+
* perceptual difference is nil because the output is already soft from
|
|
288
|
+
* the plasma's low spatial frequency and CSS blur on reflections. */
|
|
289
|
+
vec3 col;
|
|
290
|
+
if (u_blur < 0.01) {
|
|
291
|
+
col = computeEffect(uv, aspect, t, dist, cpx);
|
|
292
|
+
} else {
|
|
293
|
+
float r = u_blur * 0.02;
|
|
294
|
+
col = computeEffect(uv, aspect, t, dist, cpx) * 0.4;
|
|
295
|
+
col += computeEffect(uv + vec2( r, 0.0), aspect, t, dist, cpx) * 0.15;
|
|
296
|
+
col += computeEffect(uv + vec2(-r, 0.0), aspect, t, dist, cpx) * 0.15;
|
|
297
|
+
col += computeEffect(uv + vec2(0.0, r), aspect, t, dist, cpx) * 0.15;
|
|
298
|
+
col += computeEffect(uv + vec2(0.0, -r), aspect, t, dist, cpx) * 0.15;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Gamma punch — adds the contrast pop that defines the chromatic
|
|
302
|
+
* highlights. From the canonical engine: \`col = pow(col, vec3(1.3))\`. */
|
|
303
|
+
col = pow(col, vec3(1.3));
|
|
304
|
+
|
|
305
|
+
/* Vignette — soft edge darkening so corners read as recessed. The 40-px
|
|
306
|
+
* scale at the bottom of the formula is hard-coded in the canonical
|
|
307
|
+
* engine; we keep it for visual parity. */
|
|
308
|
+
float edgeDist = min(min(uv.x, 1.0 - uv.x), min(uv.y, 1.0 - uv.y));
|
|
309
|
+
float vigPx = 40.0 / min(u_resolution.x, u_resolution.y);
|
|
310
|
+
float vigRange = vigPx * (1.0 + u_vignette * 3.0);
|
|
311
|
+
float vig = edgeDist * edgeDist / (vigRange * vigRange);
|
|
312
|
+
vig = smoothstep(0.0, 1.0, vig);
|
|
313
|
+
col *= mix(1.0, vig, u_vignette * u_vigOpacity);
|
|
314
|
+
|
|
315
|
+
/* Per-pixel alpha. With all-1 alphas the formula collapses to ~1 but the
|
|
316
|
+
* computation matches the canonical engine so custom presets behave the
|
|
317
|
+
* same. */
|
|
318
|
+
float colorAlpha = (u_alpha1 + u_alpha2 + u_alpha3 + u_alpha4 + u_alpha5) / 5.0;
|
|
319
|
+
if (colorAlpha < 0.999) {
|
|
320
|
+
vec3 c1d = col - u_color1, c2d = col - u_color2, c3d = col - u_color3,
|
|
321
|
+
c4d = col - u_color4, c5d = col - u_color5;
|
|
322
|
+
float prox1 = exp(-8.0 * dot(c1d, c1d));
|
|
323
|
+
float prox2 = exp(-8.0 * dot(c2d, c2d));
|
|
324
|
+
float prox3 = exp(-8.0 * dot(c3d, c3d));
|
|
325
|
+
float prox4 = exp(-8.0 * dot(c4d, c4d));
|
|
326
|
+
float prox5 = exp(-8.0 * dot(c5d, c5d));
|
|
327
|
+
float pTotal = prox1 + prox2 + prox3 + prox4 + prox5 + 0.0001;
|
|
328
|
+
colorAlpha = (prox1 * u_alpha1 + prox2 * u_alpha2 + prox3 * u_alpha3 +
|
|
329
|
+
prox4 * u_alpha4 + prox5 * u_alpha5) / pTotal;
|
|
330
|
+
}
|
|
331
|
+
float alpha = colorAlpha;
|
|
332
|
+
|
|
333
|
+
/* Touch the unused-at-effect-1 uniforms so GL drivers that complain about
|
|
334
|
+
* declared-but-unread uniforms (some Mali / Adreno builds do) keep them
|
|
335
|
+
* live. The contribution is provably zero. */
|
|
336
|
+
alpha += 0.0 * (u_softness + u_shape +
|
|
337
|
+
u_alpha6 + u_alpha7 +
|
|
338
|
+
u_color6.x + u_color7.x);
|
|
339
|
+
|
|
340
|
+
gl_FragColor = vec4(col, alpha * u_shaderOpacity);
|
|
341
|
+
}
|
|
342
|
+
`
|
|
343
|
+
);
|
|
344
|
+
function Le(e, t, a) {
|
|
345
|
+
const n = e.createShader(t);
|
|
346
|
+
if (!n) throw new Error("metal-fx: gl.createShader returned null");
|
|
347
|
+
if (e.shaderSource(n, a), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) {
|
|
348
|
+
const o = e.getShaderInfoLog(n);
|
|
349
|
+
throw e.deleteShader(n), new Error(`metal-fx: shader compile failed: ${o ?? "(no info log)"}`);
|
|
350
|
+
}
|
|
351
|
+
return n;
|
|
352
|
+
}
|
|
353
|
+
function Nt(e, t, a) {
|
|
354
|
+
const n = e.createProgram();
|
|
355
|
+
if (!n) throw new Error("metal-fx: gl.createProgram returned null");
|
|
356
|
+
if (e.attachShader(n, t), e.attachShader(n, a), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
|
|
357
|
+
const o = e.getProgramInfoLog(n);
|
|
358
|
+
throw e.deleteProgram(n), new Error(`metal-fx: program link failed: ${o ?? "(no info log)"}`);
|
|
359
|
+
}
|
|
360
|
+
return n;
|
|
361
|
+
}
|
|
362
|
+
const et = 140, tt = 40, at = 1.6, nt = 1.3;
|
|
363
|
+
let i = null, ne = null;
|
|
364
|
+
function Gt(e) {
|
|
365
|
+
ne = e;
|
|
366
|
+
}
|
|
367
|
+
const Wt = [
|
|
368
|
+
"u_resolution",
|
|
369
|
+
"u_time",
|
|
370
|
+
"u_color1",
|
|
371
|
+
"u_color2",
|
|
372
|
+
"u_color3",
|
|
373
|
+
"u_color4",
|
|
374
|
+
"u_color5",
|
|
375
|
+
"u_color6",
|
|
376
|
+
"u_color7",
|
|
377
|
+
"u_alpha1",
|
|
378
|
+
"u_alpha2",
|
|
379
|
+
"u_alpha3",
|
|
380
|
+
"u_alpha4",
|
|
381
|
+
"u_alpha5",
|
|
382
|
+
"u_alpha6",
|
|
383
|
+
"u_alpha7",
|
|
384
|
+
"u_intensity",
|
|
385
|
+
"u_scale",
|
|
386
|
+
"u_direction",
|
|
387
|
+
"u_softness",
|
|
388
|
+
"u_distortion",
|
|
389
|
+
"u_complexity",
|
|
390
|
+
"u_shape",
|
|
391
|
+
"u_vignette",
|
|
392
|
+
"u_vigOpacity",
|
|
393
|
+
"u_blur",
|
|
394
|
+
"u_shaderOpacity"
|
|
395
|
+
];
|
|
396
|
+
function Oe(e) {
|
|
397
|
+
e.enable(e.BLEND), e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA);
|
|
398
|
+
const t = Le(e, e.VERTEX_SHADER, $t), a = Le(e, e.FRAGMENT_SHADER, Ht), n = Nt(e, t, a);
|
|
399
|
+
e.useProgram(n);
|
|
400
|
+
const o = e.createBuffer();
|
|
401
|
+
if (!o) throw new Error("metal-fx: gl.createBuffer returned null");
|
|
402
|
+
e.bindBuffer(e.ARRAY_BUFFER, o), e.bufferData(e.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), e.STATIC_DRAW);
|
|
403
|
+
const r = e.getAttribLocation(n, "a_position");
|
|
404
|
+
e.enableVertexAttribArray(r), e.vertexAttribPointer(r, 2, e.FLOAT, !1, 0, 0);
|
|
405
|
+
const s = {};
|
|
406
|
+
for (const c of Wt) s[c] = e.getUniformLocation(n, c);
|
|
407
|
+
return { program: n, buffer: o, uniforms: s };
|
|
408
|
+
}
|
|
409
|
+
function ot() {
|
|
410
|
+
if (i) return i;
|
|
411
|
+
const e = Math.min(Ot, typeof window < "u" && window.devicePixelRatio || 1), t = Math.round(Lt * e), a = typeof OffscreenCanvas < "u";
|
|
412
|
+
let n, o;
|
|
413
|
+
if (a)
|
|
414
|
+
n = new OffscreenCanvas(t, t), o = n.getContext("webgl", {
|
|
415
|
+
alpha: !0,
|
|
416
|
+
premultipliedAlpha: !1,
|
|
417
|
+
antialias: !1
|
|
418
|
+
});
|
|
419
|
+
else {
|
|
420
|
+
const f = document.createElement("canvas");
|
|
421
|
+
f.width = t, f.height = t, o = f.getContext("webgl", {
|
|
422
|
+
alpha: !0,
|
|
423
|
+
premultipliedAlpha: !1,
|
|
424
|
+
antialias: !1,
|
|
425
|
+
preserveDrawingBuffer: !0
|
|
426
|
+
}) ?? f.getContext("experimental-webgl"), n = f;
|
|
427
|
+
}
|
|
428
|
+
if (!o) throw new Error("metal-fx: WebGL not supported");
|
|
429
|
+
const { program: r, buffer: s, uniforms: c } = Oe(o), l = (f) => {
|
|
430
|
+
f.preventDefault(), i && (i.contextLost = !0);
|
|
431
|
+
}, d = () => {
|
|
432
|
+
if (!i) return;
|
|
433
|
+
const f = Oe(i.gl);
|
|
434
|
+
i.program = f.program, i.buffer = f.buffer, i.uniforms = f.uniforms, i.presetDirty = !0, i.contextLost = !1, ne == null || ne();
|
|
435
|
+
};
|
|
436
|
+
return n.addEventListener("webglcontextlost", l, !1), n.addEventListener("webglcontextrestored", d, !1), i = {
|
|
437
|
+
glCanvas: n,
|
|
438
|
+
gl: o,
|
|
439
|
+
program: r,
|
|
440
|
+
buffer: s,
|
|
441
|
+
uniforms: c,
|
|
442
|
+
preset: Ze.chromatic.modes.dark,
|
|
443
|
+
presetDirty: !0,
|
|
444
|
+
contextLost: !1,
|
|
445
|
+
useOffscreen: a,
|
|
446
|
+
frameBitmap: null,
|
|
447
|
+
startMs: performance.now(),
|
|
448
|
+
pausedMs: 0,
|
|
449
|
+
pausedAtMs: null,
|
|
450
|
+
rafId: 0,
|
|
451
|
+
dpr: e,
|
|
452
|
+
instances: /* @__PURE__ */ new Set(),
|
|
453
|
+
frameCount: 0,
|
|
454
|
+
glowQueue: [],
|
|
455
|
+
glowIdx: 0,
|
|
456
|
+
glowSkip: 0,
|
|
457
|
+
glowPixels: new Uint8Array(t * t * 4),
|
|
458
|
+
glowPixelsW: t,
|
|
459
|
+
glowPixelsH: t
|
|
460
|
+
}, i;
|
|
461
|
+
}
|
|
462
|
+
function zt() {
|
|
463
|
+
var o;
|
|
464
|
+
if (!i) return;
|
|
465
|
+
const { gl: e, program: t, buffer: a, frameBitmap: n } = i;
|
|
466
|
+
try {
|
|
467
|
+
n == null || n.close(), e.deleteBuffer(a), e.deleteProgram(t), (o = e.getExtension("WEBGL_lose_context")) == null || o.loseContext();
|
|
468
|
+
} catch {
|
|
469
|
+
}
|
|
470
|
+
i = null;
|
|
471
|
+
}
|
|
472
|
+
let Ie = 0;
|
|
473
|
+
function ie() {
|
|
474
|
+
if (!i) return;
|
|
475
|
+
const e = performance.now();
|
|
476
|
+
if (e - Ie < Tt) return;
|
|
477
|
+
Ie = e;
|
|
478
|
+
const { gl: t, glCanvas: a } = i, n = a.width, o = a.height;
|
|
479
|
+
(i.glowPixelsW !== n || i.glowPixelsH !== o) && (i.glowPixelsW = n, i.glowPixelsH = o, i.glowPixels = new Uint8Array(n * o * 4)), t.readPixels(0, 0, n, o, t.RGBA, t.UNSIGNED_BYTE, i.glowPixels);
|
|
480
|
+
}
|
|
481
|
+
const X = { bx: 0, by: 0 };
|
|
482
|
+
function ye(e, t, a) {
|
|
483
|
+
if (!i)
|
|
484
|
+
return X.bx = 0, X.by = 0, X;
|
|
485
|
+
const { glCanvas: n } = i, o = n.width, r = n.height, s = e.dpr, c = e.cssWidth * s, l = e.cssHeight * s, d = et * s, f = tt * s;
|
|
486
|
+
let g = c * (o / d) / e.shaderScale, u = l * (r / f) / e.shaderScale;
|
|
487
|
+
g > o && (g = o), u > r && (u = r);
|
|
488
|
+
const p = (o - g) / 2, h = (r - u) / 2, m = p + t / e.cssWidth * g, A = h + a / e.cssHeight * u;
|
|
489
|
+
return X.bx = Math.round(m), X.by = Math.round(r - 1 - A), X;
|
|
490
|
+
}
|
|
491
|
+
const N = { r: 0, g: 0, b: 0, lum: 0, count: 0 };
|
|
492
|
+
function rt(e, t, a, n, o, r) {
|
|
493
|
+
const s = Math.max(1, r | 0), c = Math.max(0, n - s), l = Math.min(t, n + s + 1), d = Math.max(0, o - s), f = Math.min(a, o + s + 1);
|
|
494
|
+
N.r = 0, N.g = 0, N.b = 0, N.lum = 0, N.count = 0;
|
|
495
|
+
for (let g = d; g < f; g++) {
|
|
496
|
+
const u = g * t;
|
|
497
|
+
for (let p = c; p < l; p++) {
|
|
498
|
+
const h = (u + p) * 4;
|
|
499
|
+
N.r += e[h], N.g += e[h + 1], N.b += e[h + 2], N.lum += (0.2126 * e[h] + 0.7152 * e[h + 1] + 0.0722 * e[h + 2]) / 255, N.count++;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return N;
|
|
503
|
+
}
|
|
504
|
+
const T = { r: 255, g: 255, b: 255 };
|
|
505
|
+
function Pe(e, t, a, n) {
|
|
506
|
+
if (!i) return 0;
|
|
507
|
+
ie();
|
|
508
|
+
const o = ye(e, t, a), r = rt(i.glowPixels, i.glowPixelsW, i.glowPixelsH, o.bx, o.by, n);
|
|
509
|
+
return r.count > 0 ? r.lum / r.count : 0;
|
|
510
|
+
}
|
|
511
|
+
function Bt(e, t, a, n) {
|
|
512
|
+
if (!i)
|
|
513
|
+
return T.r = 255, T.g = 255, T.b = 255, T;
|
|
514
|
+
ie();
|
|
515
|
+
const o = ye(e, t, a), r = rt(i.glowPixels, i.glowPixelsW, i.glowPixelsH, o.bx, o.by, n);
|
|
516
|
+
return r.count === 0 ? (T.r = 255, T.g = 255, T.b = 255, T) : (T.r = r.r / r.count, T.g = r.g / r.count, T.b = r.b / r.count, T);
|
|
517
|
+
}
|
|
518
|
+
function Dt(e, t, a, n) {
|
|
519
|
+
if (!i)
|
|
520
|
+
return T.r = 255, T.g = 255, T.b = 255, T;
|
|
521
|
+
ie();
|
|
522
|
+
const o = ye(e, t, a), { glowPixels: r, glowPixelsW: s, glowPixelsH: c } = i, l = Math.max(1, n | 0), d = Math.max(0, o.bx - l), f = Math.min(s, o.bx + l + 1), g = Math.max(0, o.by - l), u = Math.min(c, o.by + l + 1);
|
|
523
|
+
let p = -1;
|
|
524
|
+
T.r = 255, T.g = 255, T.b = 255;
|
|
525
|
+
for (let h = g; h < u; h++) {
|
|
526
|
+
const m = h * s;
|
|
527
|
+
for (let A = d; A < f; A++) {
|
|
528
|
+
const x = (m + A) * 4, E = r[x], M = r[x + 1], O = r[x + 2], P = Math.max(E, M, O), y = Math.min(E, M, O), S = (P > 0 ? (P - y) / P : 0) * (0.35 + 0.65 * (P / 255));
|
|
529
|
+
S > p && (p = S, T.r = E, T.g = M, T.b = O);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return T;
|
|
533
|
+
}
|
|
534
|
+
Gt(() => {
|
|
535
|
+
i && i.instances.size > 0 && i.pausedAtMs === null && K();
|
|
536
|
+
});
|
|
537
|
+
typeof document < "u" && document.addEventListener("visibilitychange", () => {
|
|
538
|
+
!i || i.pausedAtMs !== null || i.contextLost || (document.hidden ? _e() : i.instances.size > 0 && K());
|
|
539
|
+
});
|
|
540
|
+
function Ut(e) {
|
|
541
|
+
const t = ot(), a = e.hostCanvas.getContext("2d", { alpha: !0 });
|
|
542
|
+
if (!a) throw new Error("metal-fx: canvas 2D context unavailable");
|
|
543
|
+
const n = e.scale ?? 1, o = {
|
|
544
|
+
canvas: e.hostCanvas,
|
|
545
|
+
ctx: a,
|
|
546
|
+
cssWidth: e.cssWidth,
|
|
547
|
+
cssHeight: e.cssHeight,
|
|
548
|
+
cornerRadius: e.cornerRadius,
|
|
549
|
+
kind: e.kind,
|
|
550
|
+
ringCssPx: e.ringCssPx ?? (e.kind === "circle" ? 2 : 1) * n,
|
|
551
|
+
shaderScale: e.shaderScale ?? (e.kind === "circle" ? nt : at) * n,
|
|
552
|
+
opacityMul: e.opacityMul ?? 1,
|
|
553
|
+
visible: !0,
|
|
554
|
+
paused: e.paused ?? !1,
|
|
555
|
+
everCopied: !1,
|
|
556
|
+
dpr: typeof window < "u" && window.devicePixelRatio || 1,
|
|
557
|
+
scale: n,
|
|
558
|
+
onAfterFrame: e.onAfterFrame,
|
|
559
|
+
onFirstCopy: e.onFirstCopy
|
|
560
|
+
};
|
|
561
|
+
return it(o), t.instances.add(o), t.rafId === 0 && t.pausedAtMs === null && K(), o;
|
|
562
|
+
}
|
|
563
|
+
function Xt(e) {
|
|
564
|
+
if (!i) return;
|
|
565
|
+
i.instances.delete(e);
|
|
566
|
+
const t = i.glowQueue.indexOf(e);
|
|
567
|
+
t !== -1 && i.glowQueue.splice(t, 1), i.instances.size === 0 && (_e(), zt());
|
|
568
|
+
}
|
|
569
|
+
function Vt(e) {
|
|
570
|
+
i && (i.glowQueue.includes(e) || i.glowQueue.push(e));
|
|
571
|
+
}
|
|
572
|
+
function qt(e) {
|
|
573
|
+
if (!i) return;
|
|
574
|
+
const t = i.glowQueue.indexOf(e);
|
|
575
|
+
t !== -1 && i.glowQueue.splice(t, 1);
|
|
576
|
+
}
|
|
577
|
+
function J(e, t) {
|
|
578
|
+
let a = !1;
|
|
579
|
+
t.cssWidth !== void 0 && t.cssWidth !== e.cssWidth && (e.cssWidth = t.cssWidth, a = !0), t.cssHeight !== void 0 && t.cssHeight !== e.cssHeight && (e.cssHeight = t.cssHeight, a = !0), t.cornerRadius !== void 0 && (e.cornerRadius = t.cornerRadius), t.scale !== void 0 && (e.scale = t.scale), t.kind !== void 0 && t.kind !== e.kind && (e.kind = t.kind, t.shaderScale === void 0 && (e.shaderScale = (t.kind === "circle" ? nt : at) * e.scale), t.ringCssPx === void 0 && (e.ringCssPx = (t.kind === "circle" ? 2 : 1) * e.scale)), t.shaderScale !== void 0 && (e.shaderScale = t.shaderScale), t.ringCssPx !== void 0 && (e.ringCssPx = t.ringCssPx), t.opacityMul !== void 0 && (e.opacityMul = t.opacityMul), t.paused !== void 0 && t.paused !== e.paused && (e.paused = t.paused, !t.paused && i && i.rafId === 0 && i.pausedAtMs === null && !i.contextLost && K()), a && it(e);
|
|
580
|
+
}
|
|
581
|
+
function Yt(e, t) {
|
|
582
|
+
e.visible = t, t && i && i.rafId === 0 && i.pausedAtMs === null && !i.contextLost && K();
|
|
583
|
+
}
|
|
584
|
+
function jt(e, t) {
|
|
585
|
+
const a = ot();
|
|
586
|
+
a.preset = Ze[e].modes[t], a.presetDirty = !0;
|
|
587
|
+
}
|
|
588
|
+
function un() {
|
|
589
|
+
!i || i.pausedAtMs !== null || (i.pausedAtMs = performance.now(), _e());
|
|
590
|
+
}
|
|
591
|
+
function hn() {
|
|
592
|
+
!i || i.pausedAtMs === null || (i.pausedMs += performance.now() - i.pausedAtMs, i.pausedAtMs = null, i.instances.size > 0 && K());
|
|
593
|
+
}
|
|
594
|
+
let be = null;
|
|
595
|
+
function Kt(e) {
|
|
596
|
+
be = e;
|
|
597
|
+
}
|
|
598
|
+
function it(e) {
|
|
599
|
+
e.dpr = typeof window < "u" && window.devicePixelRatio || 1;
|
|
600
|
+
const t = Math.max(1, Math.round(e.cssWidth * e.dpr)), a = Math.max(1, Math.round(e.cssHeight * e.dpr));
|
|
601
|
+
e.canvas.width !== t && (e.canvas.width = t), e.canvas.height !== a && (e.canvas.height = a);
|
|
602
|
+
}
|
|
603
|
+
function Qt(e) {
|
|
604
|
+
const { ctx: t, dpr: a, canvas: n } = e, o = e.ringCssPx * a, r = n.width, s = n.height, c = Math.max(0, (e.cornerRadius - e.ringCssPx) * a);
|
|
605
|
+
t.save(), t.globalCompositeOperation = "destination-out", t.fillStyle = "#000", t.beginPath(), t.roundRect(o, o, r - 2 * o, s - 2 * o, c), t.fill(), t.restore();
|
|
606
|
+
}
|
|
607
|
+
function Jt(e) {
|
|
608
|
+
var p;
|
|
609
|
+
if (!i) return;
|
|
610
|
+
const t = i.frameBitmap ?? i.glCanvas, a = e.dpr, n = e.canvas.width, o = e.canvas.height;
|
|
611
|
+
if (n < 1 || o < 1) return;
|
|
612
|
+
const r = i.glCanvas.width, s = i.glCanvas.height, c = et * a, l = tt * a;
|
|
613
|
+
let d = n * (r / c) / e.shaderScale, f = o * (s / l) / e.shaderScale;
|
|
614
|
+
d > r && (d = r), f > s && (f = s);
|
|
615
|
+
const g = Math.max(0, (r - d) / 2), u = Math.max(0, (s - f) / 2);
|
|
616
|
+
if (e.ctx.clearRect(0, 0, n, o), e.opacityMul < 1 && (e.ctx.globalAlpha = e.opacityMul), e.ctx.drawImage(t, g, u, d, f, 0, 0, n, o), e.opacityMul < 1 && (e.ctx.globalAlpha = 1), Qt(e), e.onFirstCopy) {
|
|
617
|
+
const h = e.onFirstCopy;
|
|
618
|
+
e.onFirstCopy = void 0, h();
|
|
619
|
+
}
|
|
620
|
+
(p = e.onAfterFrame) == null || p.call(e);
|
|
621
|
+
}
|
|
622
|
+
function Zt() {
|
|
623
|
+
if (!i) return;
|
|
624
|
+
const { gl: e, uniforms: t, preset: a, glCanvas: n } = i;
|
|
625
|
+
t.u_resolution && e.uniform2f(t.u_resolution, n.width, n.height);
|
|
626
|
+
for (let o = 0; o < 7; o++) {
|
|
627
|
+
const r = t[`u_color${o + 1}`];
|
|
628
|
+
if (r) {
|
|
629
|
+
const [c, l, d] = _t(a.colors[o]);
|
|
630
|
+
e.uniform3f(r, c, l, d);
|
|
631
|
+
}
|
|
632
|
+
const s = t[`u_alpha${o + 1}`];
|
|
633
|
+
s && e.uniform1f(s, a.alphas[o]);
|
|
634
|
+
}
|
|
635
|
+
t.u_intensity && e.uniform1f(t.u_intensity, a.intensity), t.u_scale && e.uniform1f(t.u_scale, a.scale), t.u_direction && e.uniform1f(t.u_direction, a.direction * Math.PI / 180), t.u_softness && e.uniform1f(t.u_softness, a.softness), t.u_distortion && e.uniform1f(t.u_distortion, a.distortion), t.u_complexity && e.uniform1f(t.u_complexity, a.complexity), t.u_shape && e.uniform1f(t.u_shape, a.shape), t.u_vignette && e.uniform1f(t.u_vignette, a.vignette), t.u_vigOpacity && e.uniform1f(t.u_vigOpacity, a.vigOpacity), t.u_blur && e.uniform1f(t.u_blur, a.blur), t.u_shaderOpacity && e.uniform1f(t.u_shaderOpacity, a.shaderOpacity), i.presetDirty = !1;
|
|
636
|
+
}
|
|
637
|
+
function ea(e) {
|
|
638
|
+
if (!i) return;
|
|
639
|
+
const { gl: t, uniforms: a, preset: n, glCanvas: o } = i, r = (e - i.startMs - i.pausedMs) / 1e3 * n.speed;
|
|
640
|
+
t.viewport(0, 0, o.width, o.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), i.presetDirty && Zt(), a.u_time && t.uniform1f(a.u_time, r), t.drawArrays(t.TRIANGLES, 0, 6), i.frameCount++;
|
|
641
|
+
}
|
|
642
|
+
let Fe = 0;
|
|
643
|
+
function st(e) {
|
|
644
|
+
var a;
|
|
645
|
+
if (!i) return;
|
|
646
|
+
if (i.contextLost) {
|
|
647
|
+
i.rafId = 0;
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
let t = !1;
|
|
651
|
+
for (const n of i.instances)
|
|
652
|
+
if (n.visible && (!n.paused || !n.everCopied)) {
|
|
653
|
+
t = !0;
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
if (!t) {
|
|
657
|
+
i.rafId = 0;
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (i.rafId = requestAnimationFrame(st), !(e - Fe < Rt)) {
|
|
661
|
+
Fe = e, ea(e), i.useOffscreen && (i.glowQueue.length > 0 && ie(), (a = i.frameBitmap) == null || a.close(), i.frameBitmap = i.glCanvas.transferToImageBitmap());
|
|
662
|
+
for (const n of i.instances)
|
|
663
|
+
n.visible && (n.paused && n.everCopied || (Jt(n), n.everCopied = !0));
|
|
664
|
+
if (be && i.glowQueue.length > 0 && ++i.glowSkip % Ct === 0) {
|
|
665
|
+
const n = i.glowQueue;
|
|
666
|
+
i.glowIdx >= n.length && (i.glowIdx = 0);
|
|
667
|
+
const o = n[i.glowIdx];
|
|
668
|
+
o.visible && !o.paused && be(o, e), i.glowIdx++;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
function K() {
|
|
673
|
+
!i || i.rafId !== 0 || (i.rafId = requestAnimationFrame(st));
|
|
674
|
+
}
|
|
675
|
+
function _e() {
|
|
676
|
+
i && (i.rafId !== 0 && cancelAnimationFrame(i.rafId), i.rafId = 0);
|
|
677
|
+
}
|
|
678
|
+
const oe = {
|
|
679
|
+
linear: (e) => e,
|
|
680
|
+
smoothstep: (e) => e * e * (3 - 2 * e)
|
|
681
|
+
};
|
|
682
|
+
function V(e, t, a, n = oe.linear) {
|
|
683
|
+
return { from: e, to: t, dur: a, ease: n, startMs: -1, val: e, done: !1 };
|
|
684
|
+
}
|
|
685
|
+
function q(e, t) {
|
|
686
|
+
e.startMs = t, e.val = e.from, e.done = !1;
|
|
687
|
+
}
|
|
688
|
+
function $e(e, t) {
|
|
689
|
+
if (e.done || e.startMs < 0) return e.val;
|
|
690
|
+
const a = Math.min(1, (t - e.startMs) / e.dur);
|
|
691
|
+
return e.val = e.from + (e.to - e.from) * e.ease(a), a >= 1 && (e.done = !0), e.val;
|
|
692
|
+
}
|
|
693
|
+
const ta = 1.5, ee = 1 / 3, aa = 4 * ee, na = 2 * ee, oa = 2 * ee, ra = 1.35 * ee, ia = 13 * ee;
|
|
694
|
+
function Me(e, t, a) {
|
|
695
|
+
const n = Math.max(0, Math.min(a, Math.min(e, t) / 2));
|
|
696
|
+
return 2 * Math.max(0, e - 2 * n) + 2 * Math.max(0, t - 2 * n) + 2 * Math.PI * n;
|
|
697
|
+
}
|
|
698
|
+
function Se(e, t, a, n) {
|
|
699
|
+
return n === "circle" ? 2 * Math.PI * Math.max(0, Math.min(a, Math.min(e, t) / 2)) : Me(e, t, a);
|
|
700
|
+
}
|
|
701
|
+
function Z(e, t, a, n, o, r, s, c) {
|
|
702
|
+
const l = c || { x: 0, y: 0 }, d = Math.max(0, Math.min(n, Math.min(t, a) / 2));
|
|
703
|
+
if (s === "circle") {
|
|
704
|
+
const x = 2 * Math.PI * d;
|
|
705
|
+
if (x <= 1e-4)
|
|
706
|
+
return l.x = t * 0.5, l.y = a * 0.5, l;
|
|
707
|
+
e = (e % x + x) % x;
|
|
708
|
+
const E = -Math.PI / 2 + e / x * Math.PI * 2, M = Math.max(0, d - o + r);
|
|
709
|
+
return l.x = t * 0.5 + M * Math.cos(E), l.y = a * 0.5 + M * Math.sin(E), l;
|
|
710
|
+
}
|
|
711
|
+
const f = Math.max(0, t - 2 * d), g = Math.max(0, a - 2 * d), u = Math.PI * d / 2, p = 2 * (f + g) + 4 * u;
|
|
712
|
+
e = (e % p + p) % p;
|
|
713
|
+
const h = Math.max(0, d - o + r);
|
|
714
|
+
let m = e;
|
|
715
|
+
if (m < f)
|
|
716
|
+
return l.x = d + m, l.y = o - r, l;
|
|
717
|
+
if (m -= f, m < u) {
|
|
718
|
+
const x = -Math.PI / 2 + (u > 0 ? m / u : 0) * (Math.PI / 2);
|
|
719
|
+
return l.x = t - d + h * Math.cos(x), l.y = d + h * Math.sin(x), l;
|
|
720
|
+
}
|
|
721
|
+
if (m -= u, m < g)
|
|
722
|
+
return l.x = t - o + r, l.y = d + m, l;
|
|
723
|
+
if (m -= g, m < u) {
|
|
724
|
+
const x = (u > 0 ? m / u : 0) * (Math.PI / 2);
|
|
725
|
+
return l.x = t - d + h * Math.cos(x), l.y = a - d + h * Math.sin(x), l;
|
|
726
|
+
}
|
|
727
|
+
if (m -= u, m < f)
|
|
728
|
+
return l.x = t - d - m, l.y = a - o + r, l;
|
|
729
|
+
if (m -= f, m < u) {
|
|
730
|
+
const x = Math.PI / 2 + (u > 0 ? m / u : 0) * (Math.PI / 2);
|
|
731
|
+
return l.x = d + h * Math.cos(x), l.y = a - d + h * Math.sin(x), l;
|
|
732
|
+
}
|
|
733
|
+
if (m -= u, m < g)
|
|
734
|
+
return l.x = o - r, l.y = a - d - m, l;
|
|
735
|
+
m -= g;
|
|
736
|
+
const A = Math.PI + (u > 0 ? m / u : 0) * (Math.PI / 2);
|
|
737
|
+
return l.x = d + h * Math.cos(A), l.y = d + h * Math.sin(A), l;
|
|
738
|
+
}
|
|
739
|
+
function He(e, t) {
|
|
740
|
+
const a = e * 2 / t;
|
|
741
|
+
let n = "";
|
|
742
|
+
for (let o = 0; o <= t; o++) {
|
|
743
|
+
const r = -e + o * a;
|
|
744
|
+
n += (o === 0 ? "M " : "L ") + r.toFixed(3) + " 0 ";
|
|
745
|
+
}
|
|
746
|
+
return n;
|
|
747
|
+
}
|
|
748
|
+
const he = { x: 0, y: 0 }, pe = { x: 0, y: 0 };
|
|
749
|
+
function sa(e, t, a, n, o, r) {
|
|
750
|
+
return Z(e - 0.1, t, a, n, o, 0, r, he), Z(e + 0.1, t, a, n, o, 0, r, pe), Math.atan2(pe.y - he.y, pe.x - he.x);
|
|
751
|
+
}
|
|
752
|
+
function Ne(e, t, a) {
|
|
753
|
+
const n = Math.max(0, Math.min(1, (a - e) / (t - e)));
|
|
754
|
+
return n * n * (3 - 2 * n);
|
|
755
|
+
}
|
|
756
|
+
function la(e) {
|
|
757
|
+
const t = Se(e.width, e.height, e.cornerRadius, e.kind), a = ta * (e.scale ?? 1), n = [];
|
|
758
|
+
for (let o = 0; o < Ee; o++) {
|
|
759
|
+
const r = o / Ee * t, s = Z(r, e.width, e.height, e.cornerRadius, a, 0, e.kind);
|
|
760
|
+
n.push({ x: s.x, y: s.y, arc: r });
|
|
761
|
+
}
|
|
762
|
+
return n;
|
|
763
|
+
}
|
|
764
|
+
function ca(e, t) {
|
|
765
|
+
const { width: a, height: n, cornerRadius: o } = e, r = e.scale ?? 1, s = e.kind === "circle" ? 2 : 1, c = Math.max(0, o - s), l = (-200 * r).toFixed(0), d = l, f = (540 * r).toFixed(0), g = (440 * r).toFixed(0), u = `x="${l}" y="${d}" width="${f}" height="${g}"`, p = `${u} filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"`, h = (A) => (A * r).toFixed(3), m = (A) => (A * r).toFixed(3);
|
|
766
|
+
return [
|
|
767
|
+
"<defs>",
|
|
768
|
+
`<filter id="${t}_bXl" ${p}><feGaussianBlur stdDeviation="${m(8.4)}"/></filter>`,
|
|
769
|
+
`<filter id="${t}_bLg" ${p}><feGaussianBlur stdDeviation="${m(4.8)}"/></filter>`,
|
|
770
|
+
`<filter id="${t}_bMd" ${p}><feGaussianBlur stdDeviation="${m(2.1)}"/></filter>`,
|
|
771
|
+
`<filter id="${t}_bSm" ${p}><feGaussianBlur stdDeviation="${m(0.9)}"/></filter>`,
|
|
772
|
+
`<filter id="${t}_ebO" ${p}><feGaussianBlur stdDeviation="${m(oa)}"/></filter>`,
|
|
773
|
+
`<filter id="${t}_ebC" ${p}><feGaussianBlur stdDeviation="${m(ra)}"/></filter>`,
|
|
774
|
+
`<radialGradient id="${t}_fg" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="white"/><stop offset="0.30" stop-color="white"/><stop offset="0.65" stop-color="#404040"/><stop offset="1" stop-color="black"/></radialGradient>`,
|
|
775
|
+
`<mask id="${t}_fm" maskUnits="userSpaceOnUse" ${u}><rect ${u} fill="black"/><circle id="${t}_fc" cx="0" cy="0" r="${(ia * r).toFixed(3)}" fill="url(#${t}_fg)"/></mask>`,
|
|
776
|
+
`<mask id="${t}_rm" maskUnits="userSpaceOnUse" ${u}><rect ${u} fill="#808080"/><rect x="0" y="0" width="${a}" height="${n}" rx="${o}" ry="${o}" fill="white"/><rect x="${s}" y="${s}" width="${a - s * 2}" height="${n - s * 2}" rx="${c}" ry="${c}" fill="black"/></mask>`,
|
|
777
|
+
"</defs>",
|
|
778
|
+
// Safari clips mask to the masked element's bbox; our horizontal strokes
|
|
779
|
+
// have zero height, so the mask becomes a sliver. These spacer rects
|
|
780
|
+
// inflate the bbox to the full filter region.
|
|
781
|
+
`<g id="${t}_h" mask="url(#${t}_rm)" opacity="0">`,
|
|
782
|
+
`<rect ${u} fill="none" pointer-events="none"/>`,
|
|
783
|
+
`<g id="${t}_hI" stroke="white">`,
|
|
784
|
+
`<path id="${t}_pXl" stroke-width="${h(26.4)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.385" filter="url(#${t}_bXl)"/>`,
|
|
785
|
+
`<path id="${t}_pLg" stroke-width="${h(15.6)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.595" filter="url(#${t}_bLg)"/>`,
|
|
786
|
+
`<path id="${t}_pMd" stroke-width="${h(7.2)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${t}_bMd)"/>`,
|
|
787
|
+
`<path id="${t}_pSm" stroke-width="${h(3)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.70" filter="url(#${t}_bSm)"/>`,
|
|
788
|
+
"</g></g>",
|
|
789
|
+
`<g id="${t}_e" mask="url(#${t}_rm)" opacity="0">`,
|
|
790
|
+
`<rect ${u} fill="none" pointer-events="none"/>`,
|
|
791
|
+
`<g mask="url(#${t}_fm)">`,
|
|
792
|
+
`<g id="${t}_eI" stroke="white">`,
|
|
793
|
+
`<path id="${t}_eO" stroke-width="${h(aa)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.85" filter="url(#${t}_ebO)"/>`,
|
|
794
|
+
`<path id="${t}_eC" stroke-width="${h(na)}" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="1.0" filter="url(#${t}_ebC)"/>`,
|
|
795
|
+
"</g></g></g>"
|
|
796
|
+
].join("");
|
|
797
|
+
}
|
|
798
|
+
const da = 875e-5, Ge = 0.08, We = 0.32, fa = 0.05, ua = 3e3, ze = 0.85, ae = 0.34, me = 1500, ha = 15, pa = 75e-4, ma = 120, ga = 1.5, xa = 7.8, va = 9.13952, ba = 1, wa = 1 / 3, ya = 0.8, _a = 3.51, Be = 2e3, ge = 400, Ma = 2.625, Sa = 1.008, Ra = 0.31, lt = 140, ct = 40, dt = 20;
|
|
799
|
+
let Aa = 0;
|
|
800
|
+
const W = { x: 0, y: 0 };
|
|
801
|
+
function De(e, t) {
|
|
802
|
+
const a = `mfxg_${++Aa}`, n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
803
|
+
n.setAttribute("class", "metal-fx-glow-svg"), n.setAttribute("preserveAspectRatio", "none"), n.setAttribute("viewBox", `0 0 ${t.width} ${t.height}`), n.innerHTML = ca(t, a), e.appendChild(n);
|
|
804
|
+
const o = (x) => n.querySelector(`#${a}_${x}`), r = o("h"), s = o("hI"), c = o("e"), l = o("eI"), d = o("fc"), f = Se(t.width, t.height, t.cornerRadius, t.kind) / Me(lt, ct, dt), g = Math.max(1, xa * f), u = Math.max(0.6, va * wa * f), p = He(g, kt), h = He(u, Et), m = [o("pXl"), o("pLg"), o("pMd"), o("pSm")], A = [o("eO"), o("eC")];
|
|
805
|
+
for (const x of m) x.setAttribute("d", p);
|
|
806
|
+
for (const x of A) x.setAttribute("d", h);
|
|
807
|
+
return s.style.transformOrigin = "0 0", l.style.transformOrigin = "0 0", s.style.willChange = "transform", l.style.willChange = "transform", s.style.transition = "transform 100ms linear", l.style.transition = "transform 100ms linear", r.style.willChange = "opacity", c.style.willChange = "opacity", r.style.transition = "opacity 100ms linear", c.style.transition = "opacity 100ms linear", d.style.willChange = "transform", {
|
|
808
|
+
svg: n,
|
|
809
|
+
haloGroup: r,
|
|
810
|
+
haloInner: s,
|
|
811
|
+
extraGroup: c,
|
|
812
|
+
extraInner: l,
|
|
813
|
+
fadeCircle: d,
|
|
814
|
+
width: t.width,
|
|
815
|
+
height: t.height,
|
|
816
|
+
cornerRadius: t.cornerRadius,
|
|
817
|
+
kind: t.kind,
|
|
818
|
+
scale: t.scale ?? 1,
|
|
819
|
+
perim: la(t),
|
|
820
|
+
currentIdx: 0,
|
|
821
|
+
appearedAt: 0,
|
|
822
|
+
glowOpacity: 0,
|
|
823
|
+
relocTween: null,
|
|
824
|
+
relocNextIdx: -1,
|
|
825
|
+
wanderS: 0,
|
|
826
|
+
wanderTargetS: 0,
|
|
827
|
+
wanderFrames: 0,
|
|
828
|
+
tintFrom: { r: 255, g: 255, b: 255 },
|
|
829
|
+
tintTarget: { r: 255, g: 255, b: 255 },
|
|
830
|
+
tintTween: null,
|
|
831
|
+
tintHoldUntil: 0,
|
|
832
|
+
lastHaloStroke: "",
|
|
833
|
+
lastExtraStroke: ""
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
function Ta(e, t, a, n, o = "dark") {
|
|
837
|
+
var B;
|
|
838
|
+
const { width: r, height: s, cornerRadius: c, perim: l } = e;
|
|
839
|
+
if (l.length === 0) return;
|
|
840
|
+
const d = 2;
|
|
841
|
+
let f = -1, g = e.currentIdx, u = 0;
|
|
842
|
+
for (let k = 0; k < l.length; k++) {
|
|
843
|
+
const I = l[k], H = Pe(t, I.x, I.y, d);
|
|
844
|
+
H > f && (f = H, g = k), k === e.currentIdx && (u = H);
|
|
845
|
+
}
|
|
846
|
+
const p = e.appearedAt > 0 && a - e.appearedAt < ua, h = ae + (ze - ae) * Ne(Ge, We, u), m = !p && f - u > fa;
|
|
847
|
+
if (!e.relocTween || e.relocTween.done)
|
|
848
|
+
if (e.appearedAt === 0)
|
|
849
|
+
e.currentIdx = g, e.appearedAt = a, e.wanderS = 0, e.wanderTargetS = 0, e.wanderFrames = 0, e.relocTween = V(0, h, me, oe.smoothstep), q(e.relocTween, a);
|
|
850
|
+
else if ((B = e.relocTween) != null && B.done && e.relocTween.to === 0) {
|
|
851
|
+
e.currentIdx = e.relocNextIdx, e.appearedAt = a, e.wanderS = 0, e.wanderTargetS = 0, e.wanderFrames = 0;
|
|
852
|
+
const k = l[e.currentIdx], I = Pe(t, k.x, k.y, d), H = ae + (ze - ae) * Ne(Ge, We, I);
|
|
853
|
+
e.relocTween = V(0, H, me, oe.smoothstep), q(e.relocTween, a);
|
|
854
|
+
} else m ? (e.relocNextIdx = g, e.relocTween = V(e.glowOpacity, 0, me, oe.smoothstep), q(e.relocTween, a)) : e.glowOpacity += (h - e.glowOpacity) * da;
|
|
855
|
+
e.relocTween && (e.glowOpacity = $e(e.relocTween, a)), e.glowOpacity = Math.max(0, Math.min(1, e.glowOpacity));
|
|
856
|
+
const A = Se(r, s, c, e.kind) / Me(lt, ct, dt), x = ha * A;
|
|
857
|
+
e.wanderFrames++ >= ma && (e.wanderTargetS = (Math.random() * 2 - 1) * x, e.wanderFrames = 0), e.wanderS += (e.wanderTargetS - e.wanderS) * pa;
|
|
858
|
+
const E = l[e.currentIdx].arc + e.wanderS, M = ga * e.scale;
|
|
859
|
+
Z(E, r, s, c, M, 0, e.kind, W);
|
|
860
|
+
const O = W.x, P = W.y, y = sa(E, r, s, c, M, e.kind), w = `translate(${O.toFixed(3)}px,${P.toFixed(3)}px) rotate(${y.toFixed(4)}rad)`;
|
|
861
|
+
e.haloInner.style.transform = w;
|
|
862
|
+
const S = ba * A * e.scale;
|
|
863
|
+
Z(E, r, s, c, M, S, e.kind, W), e.extraInner.style.transform = `translate(${W.x.toFixed(3)}px,${W.y.toFixed(3)}px) rotate(${y.toFixed(4)}rad)`, e.fadeCircle.style.transform = `translate(${W.x.toFixed(3)}px,${W.y.toFixed(3)}px)`;
|
|
864
|
+
const R = o === "light", v = R ? Dt(t, O, P, d) : Bt(t, O, P, d);
|
|
865
|
+
e.tintTween ? e.tintTween.done && (R ? (e.tintFrom = {
|
|
866
|
+
r: e.tintFrom.r + (e.tintTarget.r - e.tintFrom.r) * e.tintTween.val,
|
|
867
|
+
g: e.tintFrom.g + (e.tintTarget.g - e.tintFrom.g) * e.tintTween.val,
|
|
868
|
+
b: e.tintFrom.b + (e.tintTarget.b - e.tintFrom.b) * e.tintTween.val
|
|
869
|
+
}, e.tintTarget = { ...v }, e.tintTween = V(0, 1, ge), q(e.tintTween, a)) : a >= e.tintHoldUntil && (e.tintFrom = { ...e.tintTarget }, e.tintTarget = { ...v }, e.tintTween = V(0, 1, ge), q(e.tintTween, a), e.tintHoldUntil = a + Be)) : (e.tintFrom = { ...v }, e.tintTarget = { ...v }, e.tintTween = V(0, 1, ge), q(e.tintTween, a), e.tintHoldUntil = R ? 0 : a + Be), $e(e.tintTween, a);
|
|
870
|
+
const b = e.tintTween.val;
|
|
871
|
+
let F, L, _;
|
|
872
|
+
if (R)
|
|
873
|
+
F = Math.round(e.tintFrom.r + (e.tintTarget.r - e.tintFrom.r) * b), L = Math.round(e.tintFrom.g + (e.tintTarget.g - e.tintFrom.g) * b), _ = Math.round(e.tintFrom.b + (e.tintTarget.b - e.tintFrom.b) * b);
|
|
874
|
+
else {
|
|
875
|
+
const k = e.tintFrom.r + (e.tintTarget.r - e.tintFrom.r) * b, I = e.tintFrom.g + (e.tintTarget.g - e.tintFrom.g) * b, H = e.tintFrom.b + (e.tintTarget.b - e.tintFrom.b) * b, G = Math.max(k, I, H) || 1;
|
|
876
|
+
F = Math.round(255 * (k / G)), L = Math.round(255 * (I / G)), _ = Math.round(255 * (H / G));
|
|
877
|
+
}
|
|
878
|
+
const C = `rgb(${F},${L},${_})`;
|
|
879
|
+
if (C !== e.lastHaloStroke && (e.lastHaloStroke = C, e.haloInner.style.stroke = C), R) {
|
|
880
|
+
const k = Mt(F, L, _), [I, H, G] = St(k[0], Math.min(1, k[1] * Ma), Math.max(Ra, k[2] * Sa)), D = `rgb(${I},${H},${G})`;
|
|
881
|
+
D !== e.lastExtraStroke && (e.lastExtraStroke = D, e.extraInner.style.stroke = D);
|
|
882
|
+
} else e.lastExtraStroke !== "#ffffff" && (e.lastExtraStroke = "#ffffff", e.extraInner.style.stroke = "#ffffff");
|
|
883
|
+
const $ = Math.max(0, Math.min(1, n));
|
|
884
|
+
e.haloGroup.style.opacity = (e.glowOpacity * ya * $).toFixed(3), e.extraGroup.style.opacity = Math.min(1, e.glowOpacity * _a * $).toFixed(3);
|
|
885
|
+
}
|
|
886
|
+
const we = 12, Ue = 32, Xe = 1, Ve = 0.55, Ca = 1, ka = 1, Ea = 0.85, La = 0, Oa = 1.3, qe = 3.6, Ia = 0.7, Pa = 1, Fa = 0.52, $a = 1, Ha = 0.044, Na = 235, Ga = 2.535, Wa = 0.7, za = 0.5, Ba = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT", "OPTION"]);
|
|
887
|
+
function Da(e, t) {
|
|
888
|
+
const a = Math.max(e.left - t.right, t.left - e.right, 0), n = Math.max(e.top - t.bottom, t.top - e.bottom, 0);
|
|
889
|
+
return Math.sqrt(a * a + n * n);
|
|
890
|
+
}
|
|
891
|
+
function Ua(e, t, a, n) {
|
|
892
|
+
return !(Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top) < a || Math.max(
|
|
893
|
+
e.left - t.right,
|
|
894
|
+
t.left - e.right,
|
|
895
|
+
0
|
|
896
|
+
) > n);
|
|
897
|
+
}
|
|
898
|
+
function Xa(e, t, a, n) {
|
|
899
|
+
return Math.min(e.right, t.right) - Math.max(e.left, t.left) < a ? !1 : Math.max(
|
|
900
|
+
e.top - t.bottom,
|
|
901
|
+
t.top - e.bottom,
|
|
902
|
+
0
|
|
903
|
+
) <= n;
|
|
904
|
+
}
|
|
905
|
+
function U(e, t, a, n, o, r) {
|
|
906
|
+
const s = Math.max(0, Math.min(r, n * 0.5, o * 0.5)), c = e.roundRect;
|
|
907
|
+
if (typeof c == "function") {
|
|
908
|
+
c.call(e, t, a, n, o, s);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
e.moveTo(t + s, a), e.lineTo(t + n - s, a), e.quadraticCurveTo(t + n, a, t + n, a + s), e.lineTo(t + n, a + o - s), e.quadraticCurveTo(t + n, a + o, t + n - s, a + o), e.lineTo(t + s, a + o), e.quadraticCurveTo(t, a + o, t, a + o - s), e.lineTo(t, a + s), e.quadraticCurveTo(t, a, t + s, a);
|
|
912
|
+
}
|
|
913
|
+
function ft(e, t, a, n, o) {
|
|
914
|
+
if (!o.flipX && !o.flipY) {
|
|
915
|
+
e.drawImage(t, 0, 0, a, n, o.x, o.y, o.w, o.h);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
e.save(), o.flipX && (e.translate(o.x + o.w, 0), e.scale(-1, 1)), o.flipY && (e.translate(0, o.y + o.h), e.scale(1, -1)), e.drawImage(
|
|
919
|
+
t,
|
|
920
|
+
0,
|
|
921
|
+
0,
|
|
922
|
+
a,
|
|
923
|
+
n,
|
|
924
|
+
o.flipX ? 0 : o.x,
|
|
925
|
+
o.flipY ? 0 : o.y,
|
|
926
|
+
o.w,
|
|
927
|
+
o.h
|
|
928
|
+
), e.restore();
|
|
929
|
+
}
|
|
930
|
+
const Va = 4;
|
|
931
|
+
function qa(e, t, a, n, o, r, s) {
|
|
932
|
+
if (n <= 2 * s || o <= 2 * s) {
|
|
933
|
+
e.beginPath(), U(e, t, a, n, o, r), e.clip();
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
e.beginPath(), U(e, t, a, n, o, r), U(e, t + s, a + s, n - 2 * s, o - 2 * s, Math.max(0, r - s)), e.clip("evenodd");
|
|
937
|
+
}
|
|
938
|
+
function Ya(e, t, a, n, o, r, s, c, l, d, f) {
|
|
939
|
+
const g = Math.max(1, Math.round((we + Va * 3) * f));
|
|
940
|
+
let u = Math.max(0, s), p = !0;
|
|
941
|
+
for (let h = 0; h < 3 && u > 1e-4; h++) {
|
|
942
|
+
const m = Math.min(1, u);
|
|
943
|
+
e.save(), qa(e, d.x, d.y, d.w, d.h, d.r, g), e.globalCompositeOperation = p ? "source-over" : "lighter", p = !1, e.globalAlpha = m, ft(e, t, a, n, l), e.globalAlpha = 1, e.globalCompositeOperation = "destination-in", e.fillStyle = c, e.fillRect(0, 0, o, r), e.restore(), u -= m;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function ut(e, t, a, n, o, r, s) {
|
|
947
|
+
const c = s | 0;
|
|
948
|
+
if (c < 1 || n <= 2 * c || o <= 2 * c) {
|
|
949
|
+
e.beginPath(), U(e, t, a, n, o, r), e.clip();
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
e.beginPath(), U(e, t, a, n, o, r), U(e, t + c, a + c, n - 2 * c, o - 2 * c, Math.max(0, r - c)), e.clip("evenodd");
|
|
953
|
+
}
|
|
954
|
+
function ja(e, t, a, n, o, r, s, c, l, d, f, g) {
|
|
955
|
+
let u = c * f, p = !0;
|
|
956
|
+
for (let h = 0; h < 3 && u > 1e-4; h++) {
|
|
957
|
+
const m = Math.min(1, u);
|
|
958
|
+
e.save(), ut(e, s.x, s.y, s.w, s.h, s.r, l), e.globalCompositeOperation = p ? "source-over" : "lighter", p = !1, e.globalAlpha = m, ft(e, t, a, n, g), e.globalAlpha = 1, e.globalCompositeOperation = "destination-in", e.fillStyle = d, e.fillRect(0, 0, o, r), e.restore(), u -= m;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function Ka(e, t, a, n, o, r, s, c) {
|
|
962
|
+
const l = e.createLinearGradient(n, o, r, s);
|
|
963
|
+
l.addColorStop(0, `rgba(255,255,255,${c.toFixed(3)})`), l.addColorStop(0.5, `rgba(255,255,255,${(c * 0.45).toFixed(3)})`), l.addColorStop(1, "rgba(255,255,255,0)"), e.save(), ut(e, t.x, t.y, t.w, t.h, t.r, a), e.globalCompositeOperation = "lighter", e.lineWidth = a * 2, e.strokeStyle = l, e.beginPath(), U(e, t.x, t.y, t.w, t.h, t.r), e.stroke(), e.restore();
|
|
964
|
+
}
|
|
965
|
+
function ht(e) {
|
|
966
|
+
const t = getComputedStyle(e), a = [
|
|
967
|
+
parseFloat(t.borderTopLeftRadius) || 0,
|
|
968
|
+
parseFloat(t.borderTopRightRadius) || 0,
|
|
969
|
+
parseFloat(t.borderBottomRightRadius) || 0,
|
|
970
|
+
parseFloat(t.borderBottomLeftRadius) || 0
|
|
971
|
+
].filter((n) => n > 0);
|
|
972
|
+
return a.length ? Math.min.apply(null, a) : 0;
|
|
973
|
+
}
|
|
974
|
+
function pt(e) {
|
|
975
|
+
const t = getComputedStyle(e), a = Math.max(
|
|
976
|
+
parseFloat(t.borderTopWidth) || 0,
|
|
977
|
+
parseFloat(t.borderRightWidth) || 0,
|
|
978
|
+
parseFloat(t.borderBottomWidth) || 0,
|
|
979
|
+
parseFloat(t.borderLeftWidth) || 0
|
|
980
|
+
);
|
|
981
|
+
let n = 0, o = 0;
|
|
982
|
+
const r = t.boxShadow;
|
|
983
|
+
if (r && r !== "none") {
|
|
984
|
+
const d = r.replace(/rgba?\([^)]*\)/g, (u) => u.replace(/,/g, "\0")).split(/,\s*/);
|
|
985
|
+
let f = 1 / 0, g = 1 / 0;
|
|
986
|
+
for (const u of d) {
|
|
987
|
+
const p = u.match(/-?\d+(?:\.\d+)?px/g);
|
|
988
|
+
if (!p || p.length < 4) continue;
|
|
989
|
+
const h = parseFloat(p[3]);
|
|
990
|
+
h > 0 && (/\binset\b/.test(u) ? h < f && (f = h) : h < g && (g = h));
|
|
991
|
+
}
|
|
992
|
+
Number.isFinite(f) && (n = f), Number.isFinite(g) && (o = g);
|
|
993
|
+
}
|
|
994
|
+
const s = Math.max(a, o);
|
|
995
|
+
return { width: Math.max(a, n, o) || 1, outerCssPx: s };
|
|
996
|
+
}
|
|
997
|
+
function Ye(e) {
|
|
998
|
+
e.cornerRadius = ht(e.el);
|
|
999
|
+
const t = pt(e.el);
|
|
1000
|
+
e.hairlineWidth = t.width, e.hairlineOuterCssPx = t.outerCssPx;
|
|
1001
|
+
}
|
|
1002
|
+
function Qa(e) {
|
|
1003
|
+
typeof ResizeObserver < "u" && (e.resizeObserver = new ResizeObserver(() => Ye(e)), e.resizeObserver.observe(e.el)), typeof MutationObserver < "u" && (e.mutationObserver = new MutationObserver(() => Ye(e)), e.mutationObserver.observe(e.el, {
|
|
1004
|
+
attributes: !0,
|
|
1005
|
+
attributeFilter: ["style", "class"]
|
|
1006
|
+
}));
|
|
1007
|
+
}
|
|
1008
|
+
function Ja(e) {
|
|
1009
|
+
var t, a;
|
|
1010
|
+
(t = e.resizeObserver) == null || t.disconnect(), e.resizeObserver = null, (a = e.mutationObserver) == null || a.disconnect(), e.mutationObserver = null;
|
|
1011
|
+
}
|
|
1012
|
+
const j = /* @__PURE__ */ new Set();
|
|
1013
|
+
function Za(e, t, a) {
|
|
1014
|
+
if (typeof document > "u" || Ba.has(e.tagName)) return null;
|
|
1015
|
+
for (const p of j)
|
|
1016
|
+
if (p.el === e) return p;
|
|
1017
|
+
const n = document.createElement("div");
|
|
1018
|
+
n.setAttribute("data-metal-fx-reflection", ""), n.setAttribute("aria-hidden", "true");
|
|
1019
|
+
const o = document.createElement("canvas");
|
|
1020
|
+
o.className = "metal-fx-reflection-canvas";
|
|
1021
|
+
const r = o.getContext("2d", { alpha: !0 });
|
|
1022
|
+
if (!r) return null;
|
|
1023
|
+
const s = document.createElement("canvas");
|
|
1024
|
+
s.className = "metal-fx-reflection-stroke-canvas";
|
|
1025
|
+
const c = s.getContext("2d", { alpha: !0 });
|
|
1026
|
+
if (!c) return null;
|
|
1027
|
+
n.appendChild(o), n.appendChild(s);
|
|
1028
|
+
const l = getComputedStyle(e);
|
|
1029
|
+
let d = !1;
|
|
1030
|
+
l.position === "static" && (e.style.position = "relative", d = !0);
|
|
1031
|
+
let f = !1;
|
|
1032
|
+
l.isolation !== "isolate" && (e.style.isolation = "isolate", f = !0), e.setAttribute("data-metal-fx-reflect-host", ""), e.insertBefore(n, e.firstChild);
|
|
1033
|
+
const g = pt(e), u = {
|
|
1034
|
+
el: e,
|
|
1035
|
+
anchor: t,
|
|
1036
|
+
anchorEl: a,
|
|
1037
|
+
wrap: n,
|
|
1038
|
+
canvas: o,
|
|
1039
|
+
ctx: r,
|
|
1040
|
+
strokeCanvas: s,
|
|
1041
|
+
strokeCtx: c,
|
|
1042
|
+
cornerRadius: ht(e),
|
|
1043
|
+
hairlineWidth: g.width,
|
|
1044
|
+
hairlineOuterCssPx: g.outerCssPx,
|
|
1045
|
+
appliedPositionRelative: d,
|
|
1046
|
+
appliedIsolation: f,
|
|
1047
|
+
resizeObserver: null,
|
|
1048
|
+
mutationObserver: null
|
|
1049
|
+
};
|
|
1050
|
+
return Qa(u), j.add(u), u;
|
|
1051
|
+
}
|
|
1052
|
+
function en(e) {
|
|
1053
|
+
for (const t of j)
|
|
1054
|
+
if (t.el === e) {
|
|
1055
|
+
Ja(t), t.canvas.width = 0, t.canvas.height = 0, t.strokeCanvas.width = 0, t.strokeCanvas.height = 0, t.wrap.parentNode === t.el && t.el.removeChild(t.wrap), t.el.removeAttribute("data-metal-fx-reflect-host"), t.appliedPositionRelative && (t.el.style.position = ""), t.appliedIsolation && (t.el.style.isolation = ""), j.delete(t);
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function tn() {
|
|
1060
|
+
if (j.size === 0) return;
|
|
1061
|
+
const e = typeof window < "u" && window.devicePixelRatio || 1, t = /* @__PURE__ */ new Map();
|
|
1062
|
+
for (const a of j) {
|
|
1063
|
+
const n = a.el.getBoundingClientRect();
|
|
1064
|
+
let o = t.get(a.anchorEl);
|
|
1065
|
+
if (o || (o = a.anchorEl.getBoundingClientRect(), t.set(a.anchorEl, o)), n.width < 1 || n.height < 1 || o.width < 1 || o.height < 1) continue;
|
|
1066
|
+
if (!Ua(o, n, Xe, Ue) && !Xa(o, n, Xe, Ue)) {
|
|
1067
|
+
a.canvas.width !== 1 && (a.canvas.width = 1, a.canvas.height = 1), a.strokeCanvas.width !== 1 && (a.strokeCanvas.width = 1, a.strokeCanvas.height = 1);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
const r = a.anchor.canvas, s = r.width | 0, c = r.height | 0;
|
|
1071
|
+
if (s < 4 || c < 4) continue;
|
|
1072
|
+
const l = (o.left + o.right) * 0.5, d = (o.top + o.bottom) * 0.5, f = (n.left + n.right) * 0.5, g = (n.top + n.bottom) * 0.5, u = l - f, p = d - g, h = Math.max(o.left - n.right, n.left - o.right, 0), m = Math.max(o.top - n.bottom, n.top - o.bottom, 0), A = h >= m, x = Da(o, n);
|
|
1073
|
+
let E = 1 - Math.min(1, x / we);
|
|
1074
|
+
E = E * E * (3 - 2 * E);
|
|
1075
|
+
const M = Ve + (Ca - Ve) * E, O = Math.min(
|
|
1076
|
+
qe,
|
|
1077
|
+
M * Oa * Ia
|
|
1078
|
+
), P = a.anchor.scale ?? 1, y = Math.max(Pa * P, a.hairlineWidth), w = Math.max(1, Math.round(y * e)), S = Math.max(
|
|
1079
|
+
1,
|
|
1080
|
+
Math.round(Math.max($a * P, a.hairlineWidth) * e)
|
|
1081
|
+
), R = a.hairlineOuterCssPx;
|
|
1082
|
+
a.wrap.style.inset = `${-R}px`, a.wrap.style.borderRadius = `${Math.max(0, a.cornerRadius)}px`;
|
|
1083
|
+
const v = Math.max(1, Math.round((n.width + R * 2) * e)), b = Math.max(1, Math.round((n.height + R * 2) * e));
|
|
1084
|
+
a.canvas.width !== v && (a.canvas.width = v), a.canvas.height !== b && (a.canvas.height = b), a.strokeCanvas.width !== v && (a.strokeCanvas.width = v), a.strokeCanvas.height !== b && (a.strokeCanvas.height = b);
|
|
1085
|
+
const F = a.ctx;
|
|
1086
|
+
F.setTransform(1, 0, 0, 1, 0, 0), F.clearRect(0, 0, v, b);
|
|
1087
|
+
const L = a.strokeCtx;
|
|
1088
|
+
L.setTransform(1, 0, 0, 1, 0, 0), L.clearRect(0, 0, v, b);
|
|
1089
|
+
const _ = Math.min(we * e, Math.max(v, b));
|
|
1090
|
+
let C, $, B, k;
|
|
1091
|
+
A ? (C = u > 0 ? v : 0, B = u > 0 ? v - _ : _, $ = b * 0.5, k = b * 0.5) : ($ = p > 0 ? b : 0, k = p > 0 ? b - _ : _, C = v * 0.5, B = v * 0.5);
|
|
1092
|
+
const I = F.createLinearGradient(C, $, B, k);
|
|
1093
|
+
I.addColorStop(0, `rgba(0,0,0,${ka})`), I.addColorStop(0.5, `rgba(0,0,0,${Ea})`), I.addColorStop(1, `rgba(0,0,0,${La})`);
|
|
1094
|
+
const H = s / e, G = Math.max(1, Math.round(Na * Math.max(0.1, H / 140) * e));
|
|
1095
|
+
let D, se, le, ce, Re = !1, Ae = !1;
|
|
1096
|
+
if (A) {
|
|
1097
|
+
const Q = Math.max(o.top, n.top), fe = Math.min(o.bottom, n.bottom);
|
|
1098
|
+
Re = !0, D = u > 0 ? v - G : 0, se = Math.round((Q - n.top + R) * e), le = G, ce = Math.max(1, Math.round((fe - Q) * e));
|
|
1099
|
+
} else {
|
|
1100
|
+
const Q = Math.max(o.left, n.left), fe = Math.min(o.right, n.right);
|
|
1101
|
+
Ae = !0, D = Math.round((Q - n.left + R) * e), se = p > 0 ? b - G : 0, le = Math.max(1, Math.round((fe - Q) * e)), ce = G;
|
|
1102
|
+
}
|
|
1103
|
+
const Te = { x: D, y: se, w: le, h: ce, flipX: Re, flipY: Ae }, de = { x: 0, y: 0, w: v, h: b, r: Math.max(0, a.cornerRadius * e) }, mt = Math.min(
|
|
1104
|
+
qe,
|
|
1105
|
+
O * Ga * Wa * za
|
|
1106
|
+
);
|
|
1107
|
+
Ya(F, r, s, c, v, b, mt, I, Te, de, e), ja(
|
|
1108
|
+
L,
|
|
1109
|
+
r,
|
|
1110
|
+
s,
|
|
1111
|
+
c,
|
|
1112
|
+
v,
|
|
1113
|
+
b,
|
|
1114
|
+
de,
|
|
1115
|
+
O,
|
|
1116
|
+
w,
|
|
1117
|
+
I,
|
|
1118
|
+
Fa,
|
|
1119
|
+
Te
|
|
1120
|
+
), Ka(
|
|
1121
|
+
L,
|
|
1122
|
+
de,
|
|
1123
|
+
S,
|
|
1124
|
+
C,
|
|
1125
|
+
$,
|
|
1126
|
+
B,
|
|
1127
|
+
k,
|
|
1128
|
+
Math.min(0.85, Ha * O)
|
|
1129
|
+
), F.globalCompositeOperation = "source-over", L.globalCompositeOperation = "source-over";
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
let xe = !1, je = 0;
|
|
1133
|
+
function an() {
|
|
1134
|
+
xe || (xe = !0, !(typeof requestAnimationFrame > "u") && requestAnimationFrame((e) => {
|
|
1135
|
+
xe = !1, !(e - je < At) && (je = e, tn());
|
|
1136
|
+
}));
|
|
1137
|
+
}
|
|
1138
|
+
const Ke = "metal-fx-styles", nn = (
|
|
1139
|
+
/* css */
|
|
1140
|
+
`
|
|
1141
|
+
.metal-fx-root {
|
|
1142
|
+
position: relative;
|
|
1143
|
+
display: inline-flex;
|
|
1144
|
+
align-items: center;
|
|
1145
|
+
justify-content: center;
|
|
1146
|
+
isolation: isolate;
|
|
1147
|
+
overflow: visible;
|
|
1148
|
+
background: #272727;
|
|
1149
|
+
color: #f8f8f8;
|
|
1150
|
+
}
|
|
1151
|
+
.metal-fx-root[data-theme='light'] {
|
|
1152
|
+
background: #ffffff;
|
|
1153
|
+
color: #1d1d1d;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
.metal-fx-root::before {
|
|
1157
|
+
content: '';
|
|
1158
|
+
position: absolute;
|
|
1159
|
+
inset: 0;
|
|
1160
|
+
border-radius: inherit;
|
|
1161
|
+
pointer-events: none;
|
|
1162
|
+
z-index: 2;
|
|
1163
|
+
box-shadow: inset 0 0 50px 0 rgba(255, 255, 255, 0.02);
|
|
1164
|
+
}
|
|
1165
|
+
.metal-fx-root[data-theme='light']::before {
|
|
1166
|
+
box-shadow: inset 0 0 50px 0 rgba(0, 0, 0, 0.02);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
.metal-fx-root::after {
|
|
1170
|
+
content: '';
|
|
1171
|
+
position: absolute;
|
|
1172
|
+
inset: 0;
|
|
1173
|
+
border-radius: inherit;
|
|
1174
|
+
pointer-events: none;
|
|
1175
|
+
z-index: 4;
|
|
1176
|
+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
|
|
1177
|
+
}
|
|
1178
|
+
.metal-fx-root[data-theme='light']::after {
|
|
1179
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
|
|
1180
|
+
}
|
|
1181
|
+
/* Circle variant gets a thicker outer rim than the button variant. */
|
|
1182
|
+
.metal-fx-root[data-variant='circle']::after {
|
|
1183
|
+
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
|
|
1184
|
+
}
|
|
1185
|
+
.metal-fx-root[data-theme='light'][data-variant='circle']::after {
|
|
1186
|
+
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
.metal-fx-canvas {
|
|
1190
|
+
position: absolute;
|
|
1191
|
+
inset: 0;
|
|
1192
|
+
width: 100%;
|
|
1193
|
+
height: 100%;
|
|
1194
|
+
display: block;
|
|
1195
|
+
z-index: 0;
|
|
1196
|
+
pointer-events: none;
|
|
1197
|
+
border-radius: inherit;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/* The inner spacer — defines the inset geometry where the metal ring meets
|
|
1201
|
+
the interior (3 px for Button, 1-2 px for Circle) and carries the Circle dark
|
|
1202
|
+
hairline ('box-shadow: inset' rules below). Intentionally transparent so
|
|
1203
|
+
the wrapper's background propagates through to the punched shader centre,
|
|
1204
|
+
giving consumers a single surface tone to override. See "Single-surface
|
|
1205
|
+
background" in the file header for the rationale. */
|
|
1206
|
+
.metal-fx-inner {
|
|
1207
|
+
position: absolute;
|
|
1208
|
+
inset: 3px;
|
|
1209
|
+
border-radius: inherit;
|
|
1210
|
+
z-index: 1;
|
|
1211
|
+
pointer-events: none;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
.metal-fx-root[data-variant='button'][data-shape='pill'] .metal-fx-inner {
|
|
1215
|
+
border-radius: calc(var(--mfx-radius, 20px) - 3px);
|
|
1216
|
+
}
|
|
1217
|
+
.metal-fx-root[data-variant='button'][data-shape='circle'] .metal-fx-inner {
|
|
1218
|
+
border-radius: calc(var(--mfx-radius, 16px) - 3px);
|
|
1219
|
+
}
|
|
1220
|
+
.metal-fx-root[data-variant='circle'][data-shape='pill'] .metal-fx-inner {
|
|
1221
|
+
inset: 0;
|
|
1222
|
+
border-radius: var(--mfx-radius, 20px);
|
|
1223
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
|
|
1224
|
+
}
|
|
1225
|
+
.metal-fx-root[data-variant='circle'][data-shape='circle'] .metal-fx-inner {
|
|
1226
|
+
inset: 0;
|
|
1227
|
+
border-radius: var(--mfx-radius, 16px);
|
|
1228
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
|
|
1229
|
+
}
|
|
1230
|
+
/* Circle-variant hairline alpha — light mode.
|
|
1231
|
+
Source-of-truth: index.html L2261-2267. The 0.45-alpha black inset that
|
|
1232
|
+
reads as a single-pixel frame against the dark interior is too heavy
|
|
1233
|
+
on a #ffffff inner: it ends up looking like a hard 2-px black ring
|
|
1234
|
+
against the iridescent shader. Suppressed entirely (alpha 0) — the
|
|
1235
|
+
shader's own iridescent rim already defines the silhouette in light
|
|
1236
|
+
mode, so an extra dark hairline only competes with it. The rule is
|
|
1237
|
+
kept (rather than deleted) as a tunable hook in case a future variant
|
|
1238
|
+
wants to re-introduce a soft edge. NOTE: we keep the dark-mode inset
|
|
1239
|
+
and border-radius values because — unlike index.html — our renderer
|
|
1240
|
+
does NOT overscan the canvas in light mode, so there is no 1-px gap
|
|
1241
|
+
between inner element and shader to compensate for. */
|
|
1242
|
+
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='pill'] .metal-fx-inner,
|
|
1243
|
+
.metal-fx-root[data-theme='light'][data-variant='circle'][data-shape='circle'] .metal-fx-inner {
|
|
1244
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/* ─── Combined glow SVG (z=3) ──────────────────────────────────────────────
|
|
1248
|
+
Single SVG per instance that holds BOTH the wide-halo group
|
|
1249
|
+
(#mfx_haloTravel) and the catch-light group (#mfx_extraTravel), exactly
|
|
1250
|
+
mirroring canonical's _buildGlowSvgInner (index.html L8078). One
|
|
1251
|
+
mix-blend-mode: screen lifts the combined composite onto the shader
|
|
1252
|
+
ring; per-frame opacity attributes on each inner group still drive the
|
|
1253
|
+
independent fade-in / fade-out cycles for the halo and the catch-light.
|
|
1254
|
+
|
|
1255
|
+
Why a single SVG: the circle variant anchors halo + catch-light at the same
|
|
1256
|
+
perimeter point, so they overlap in the bright zone. Two separately-
|
|
1257
|
+
screened SVGs would double-screen the overlap (A + B + C - AB - AC -
|
|
1258
|
+
BC + ABC instead of A + B + C - AB - AC once both groups composite
|
|
1259
|
+
in source-over inside one SVG and then screen against the host once).
|
|
1260
|
+
That overlap looked muted versus canonical specifically on the circle
|
|
1261
|
+
variant where both layers travel together.
|
|
1262
|
+
|
|
1263
|
+
Source-of-truth opacity: #btnGlowSvg drops to 0.7 in dark and 0.2746 in
|
|
1264
|
+
light (index.html L632/L643). */
|
|
1265
|
+
.metal-fx-glow-svg {
|
|
1266
|
+
position: absolute;
|
|
1267
|
+
inset: 0;
|
|
1268
|
+
width: 100%;
|
|
1269
|
+
height: 100%;
|
|
1270
|
+
overflow: visible;
|
|
1271
|
+
z-index: 3;
|
|
1272
|
+
pointer-events: none;
|
|
1273
|
+
opacity: 0.7;
|
|
1274
|
+
}
|
|
1275
|
+
.metal-fx-root[data-theme='light'] .metal-fx-glow-svg {
|
|
1276
|
+
/* Light-mode 1-px overscan mirrors .btn-glow-svg in metal.html so the
|
|
1277
|
+
halo stays glued to the visible silhouette (the shader ring there sits
|
|
1278
|
+
1 px outside the host's padding box). */
|
|
1279
|
+
inset: -1px;
|
|
1280
|
+
width: calc(100% + 2px);
|
|
1281
|
+
height: calc(100% + 2px);
|
|
1282
|
+
mix-blend-mode: multiply;
|
|
1283
|
+
/* Source-of-truth: html[data-theme="light"] #btnGlowSvg { opacity: 0.2746 }
|
|
1284
|
+
→ −35 % from 0.4225 from the original 0.7 dark-mode opacity. */
|
|
1285
|
+
opacity: 0.2746;
|
|
1286
|
+
filter: saturate(5.355) brightness(0.78);
|
|
1287
|
+
}
|
|
1288
|
+
/* Circle light-mode small variants (e.g. 36×36 send button): the geometrically
|
|
1289
|
+
shrunk halo loses density when multiplied against #ffffff. Mirror the
|
|
1290
|
+
canonical override at index.html L2316 — bump saturation + drop brightness
|
|
1291
|
+
so the small glow holds together visually. */
|
|
1292
|
+
.metal-fx-root[data-variant='circle'][data-shape='circle'][data-theme='light'] .metal-fx-glow-svg {
|
|
1293
|
+
filter: saturate(7.5) brightness(0.6);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/* The wrapped child — hoisted into z=5 so it sits above every overlay, with
|
|
1297
|
+
normalized chrome so consumer button styles don't fight the metal frame. */
|
|
1298
|
+
.metal-fx-content {
|
|
1299
|
+
position: relative;
|
|
1300
|
+
z-index: 5;
|
|
1301
|
+
display: inline-flex;
|
|
1302
|
+
align-items: center;
|
|
1303
|
+
justify-content: center;
|
|
1304
|
+
width: 100%;
|
|
1305
|
+
pointer-events: none;
|
|
1306
|
+
}
|
|
1307
|
+
.metal-fx-content > * {
|
|
1308
|
+
pointer-events: auto;
|
|
1309
|
+
}
|
|
1310
|
+
.metal-fx-root[data-normalize='true'] .metal-fx-content > * {
|
|
1311
|
+
background: transparent !important;
|
|
1312
|
+
border: 0 !important;
|
|
1313
|
+
outline: 0 !important;
|
|
1314
|
+
box-shadow: none !important;
|
|
1315
|
+
/* Sizing: we deliberately DO NOT force \`width: 100%; height: 100%\` on the
|
|
1316
|
+
child here. That used to be the contract ("the wrapper is the visible
|
|
1317
|
+
button surface; the child stretches to fill it"), but it created a cyclic
|
|
1318
|
+
percentage dependency: the wrapper is \`inline-flex\` with no intrinsic
|
|
1319
|
+
size, .metal-fx-content is \`width/height: 100%\` of the wrapper, and the
|
|
1320
|
+
child was \`100%\` of .metal-fx-content. With nothing breaking the cycle,
|
|
1321
|
+
icon-only / class-sized children collapsed.
|
|
1322
|
+
|
|
1323
|
+
The new contract: the child sizes itself (intrinsic content, CSS class,
|
|
1324
|
+
or inline style — all work), and the wrapper's \`inline-flex\` wraps it
|
|
1325
|
+
tightly. Consumers who want a metal frame BIGGER than the child (e.g.
|
|
1326
|
+
padding around an icon) size <MetalFx style={{ width, height }}> AND
|
|
1327
|
+
explicitly set width/height on the child to fill (or accept that the
|
|
1328
|
+
child renders at its intrinsic size, centered).
|
|
1329
|
+
|
|
1330
|
+
Typography is intentionally NOT touched. We used to apply
|
|
1331
|
+
\`color: inherit; font: inherit;\` here to "match" the wrapper, but
|
|
1332
|
+
\`font: inherit\` is a shorthand that overrides font-family, font-size,
|
|
1333
|
+
font-weight, AND line-height on the child — which (a) shrank the
|
|
1334
|
+
button height (line-height changes propagate through the flex
|
|
1335
|
+
content box) and (b) scaled em-based icons / font-icons inside the
|
|
1336
|
+
child to whatever the wrapper inherited. The wrapper now stays out
|
|
1337
|
+
of the child's typography entirely; consumers who want typographic
|
|
1338
|
+
normalization can apply it themselves on the child element. */
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
[data-metal-fx-reflection] {
|
|
1342
|
+
position: absolute;
|
|
1343
|
+
inset: 0;
|
|
1344
|
+
pointer-events: none;
|
|
1345
|
+
border-radius: inherit;
|
|
1346
|
+
overflow: hidden;
|
|
1347
|
+
z-index: 0;
|
|
1348
|
+
isolation: isolate;
|
|
1349
|
+
}
|
|
1350
|
+
.metal-fx-reflection-canvas {
|
|
1351
|
+
position: absolute;
|
|
1352
|
+
inset: 0;
|
|
1353
|
+
width: 100%;
|
|
1354
|
+
height: 100%;
|
|
1355
|
+
display: block;
|
|
1356
|
+
filter: blur(4px) saturate(1.2) brightness(1.58);
|
|
1357
|
+
}
|
|
1358
|
+
.metal-fx-reflection-stroke-canvas {
|
|
1359
|
+
position: absolute;
|
|
1360
|
+
inset: 0;
|
|
1361
|
+
width: 100%;
|
|
1362
|
+
height: 100%;
|
|
1363
|
+
display: block;
|
|
1364
|
+
filter: saturate(1.35) brightness(1.75);
|
|
1365
|
+
}
|
|
1366
|
+
/* Hosts that participate as reflection targets need positioning + isolation
|
|
1367
|
+
so the wrap composites only against the host (not the parent stack). The
|
|
1368
|
+
wrap injects these inline as well, but stating them here keeps reflections
|
|
1369
|
+
working on hosts that already have other inline styles applied. */
|
|
1370
|
+
[data-metal-fx-reflect-host] {
|
|
1371
|
+
isolation: isolate;
|
|
1372
|
+
}
|
|
1373
|
+
`
|
|
1374
|
+
);
|
|
1375
|
+
let ve = !1;
|
|
1376
|
+
function on() {
|
|
1377
|
+
if (ve || typeof document > "u") return;
|
|
1378
|
+
if (document.getElementById(Ke)) {
|
|
1379
|
+
ve = !0;
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
const e = document.createElement("style");
|
|
1383
|
+
e.id = Ke, e.textContent = nn, document.head.appendChild(e), ve = !0;
|
|
1384
|
+
}
|
|
1385
|
+
const rn = ["data-variant", "data-shape", "data-theme", "data-paused", "data-normalize"];
|
|
1386
|
+
on();
|
|
1387
|
+
const sn = { position: "absolute", inset: "0", width: "100%", height: "100%" }, ln = { position: "absolute", inset: "3px" }, cn = { position: "absolute", inset: "0", pointerEvents: "none", zIndex: 3, borderRadius: "inherit" }, re = /* @__PURE__ */ new Map();
|
|
1388
|
+
Kt((e, t) => {
|
|
1389
|
+
const a = re.get(e);
|
|
1390
|
+
a && Ta(a.handles, e, t, e.opacityMul, a.themeRef.current);
|
|
1391
|
+
});
|
|
1392
|
+
function dn(e) {
|
|
1393
|
+
const a = Y(((c) => c !== "auto" ? c : typeof window > "u" || !window.matchMedia || window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light")(e()));
|
|
1394
|
+
let n = null;
|
|
1395
|
+
const o = () => {
|
|
1396
|
+
n && (a.value = n.matches ? "dark" : "light");
|
|
1397
|
+
}, r = () => {
|
|
1398
|
+
n == null || n.removeEventListener("change", o), n = null;
|
|
1399
|
+
}, s = () => {
|
|
1400
|
+
if (r(), e() !== "auto") {
|
|
1401
|
+
a.value = e();
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
typeof window > "u" || !window.matchMedia || (n = window.matchMedia("(prefers-color-scheme: dark)"), o(), n.addEventListener("change", o));
|
|
1405
|
+
};
|
|
1406
|
+
return Qe(s), z(e, s), Je(r), a;
|
|
1407
|
+
}
|
|
1408
|
+
const pn = /* @__PURE__ */ gt({
|
|
1409
|
+
__name: "MetalFx",
|
|
1410
|
+
props: {
|
|
1411
|
+
variant: { default: "button" },
|
|
1412
|
+
preset: { default: "chromatic" },
|
|
1413
|
+
theme: { default: "auto" },
|
|
1414
|
+
strength: { default: 1 },
|
|
1415
|
+
paused: { type: Boolean, default: !1 },
|
|
1416
|
+
borderRadius: {},
|
|
1417
|
+
normalizeHostStyles: { type: Boolean, default: !0 },
|
|
1418
|
+
reflectionTargets: {},
|
|
1419
|
+
disableGlow: { type: Boolean, default: !1 },
|
|
1420
|
+
shaderScale: {},
|
|
1421
|
+
ringCssPx: {},
|
|
1422
|
+
scale: { default: 1 }
|
|
1423
|
+
},
|
|
1424
|
+
setup(e, { expose: t }) {
|
|
1425
|
+
const a = e, n = Y(null), o = Y(null), r = Y(null), s = Y(null);
|
|
1426
|
+
let c = null, l = null, d = 0;
|
|
1427
|
+
const f = Y(!1), g = dn(() => a.theme), u = { get current() {
|
|
1428
|
+
return g.value;
|
|
1429
|
+
} }, p = ue(() => a.variant === "circle" ? "circle" : "pill"), h = ue(() => !a.disableGlow);
|
|
1430
|
+
t({
|
|
1431
|
+
/** The wrapper element, mirroring the React version's forwarded ref. */
|
|
1432
|
+
rootEl: n
|
|
1433
|
+
});
|
|
1434
|
+
const m = (y, w) => {
|
|
1435
|
+
if (p.value === "circle") return Math.min(y, w) / 2;
|
|
1436
|
+
const S = typeof a.borderRadius == "number" ? a.borderRadius : (() => {
|
|
1437
|
+
var v;
|
|
1438
|
+
const R = (v = s.value) == null ? void 0 : v.firstElementChild;
|
|
1439
|
+
if (R) {
|
|
1440
|
+
const b = parseFloat(getComputedStyle(R).borderTopLeftRadius);
|
|
1441
|
+
if (Number.isFinite(b) && b > 0) return b;
|
|
1442
|
+
}
|
|
1443
|
+
return d;
|
|
1444
|
+
})();
|
|
1445
|
+
return Math.min(S, Math.min(y, w) / 2);
|
|
1446
|
+
};
|
|
1447
|
+
z([() => a.preset, g], ([y, w]) => {
|
|
1448
|
+
jt(y, w);
|
|
1449
|
+
}, { immediate: !0 }), z(() => a.paused, (y) => {
|
|
1450
|
+
c && J(c, { paused: y });
|
|
1451
|
+
}), z([() => a.shaderScale, () => a.ringCssPx, () => a.scale], ([y, w, S]) => {
|
|
1452
|
+
if (!c) return;
|
|
1453
|
+
const R = {};
|
|
1454
|
+
y !== void 0 && (R.shaderScale = y), w !== void 0 && (R.ringCssPx = w), S !== void 0 && (R.scale = S), Object.keys(R).length > 0 && J(c, R);
|
|
1455
|
+
});
|
|
1456
|
+
const A = () => {
|
|
1457
|
+
c && J(c, { opacityMul: Math.max(0, Math.min(1, a.strength)) });
|
|
1458
|
+
};
|
|
1459
|
+
z([() => a.strength, () => a.variant], A);
|
|
1460
|
+
let x = null;
|
|
1461
|
+
const E = () => {
|
|
1462
|
+
const y = o.value, w = n.value, S = r.value;
|
|
1463
|
+
if (!y || !w) return;
|
|
1464
|
+
{
|
|
1465
|
+
const _ = getComputedStyle(w), C = parseFloat(_.borderTopLeftRadius);
|
|
1466
|
+
d = Number.isFinite(C) ? C : 0;
|
|
1467
|
+
}
|
|
1468
|
+
const R = () => {
|
|
1469
|
+
const _ = w.getBoundingClientRect(), C = Math.max(1, Math.round(_.width)), $ = Math.max(1, Math.round(_.height));
|
|
1470
|
+
return { cssWidth: C, cssHeight: $, cornerRadius: m(C, $) };
|
|
1471
|
+
}, v = R();
|
|
1472
|
+
c = Ut({
|
|
1473
|
+
hostCanvas: y,
|
|
1474
|
+
cssWidth: v.cssWidth,
|
|
1475
|
+
cssHeight: v.cssHeight,
|
|
1476
|
+
cornerRadius: v.cornerRadius,
|
|
1477
|
+
kind: p.value,
|
|
1478
|
+
paused: a.paused,
|
|
1479
|
+
shaderScale: a.shaderScale,
|
|
1480
|
+
ringCssPx: a.ringCssPx,
|
|
1481
|
+
scale: a.scale,
|
|
1482
|
+
onFirstCopy: () => {
|
|
1483
|
+
f.value = !0;
|
|
1484
|
+
}
|
|
1485
|
+
}), w.style.setProperty("--mfx-radius", `${v.cornerRadius}px`), w.style.borderRadius = `${v.cornerRadius}px`, A(), S && (l = De(S, {
|
|
1486
|
+
width: v.cssWidth,
|
|
1487
|
+
height: v.cssHeight,
|
|
1488
|
+
cornerRadius: v.cornerRadius,
|
|
1489
|
+
kind: p.value,
|
|
1490
|
+
scale: a.scale
|
|
1491
|
+
}));
|
|
1492
|
+
let b = 0;
|
|
1493
|
+
const F = new ResizeObserver(() => {
|
|
1494
|
+
b === 0 && (b = requestAnimationFrame(() => {
|
|
1495
|
+
b = 0;
|
|
1496
|
+
const _ = R(), C = c;
|
|
1497
|
+
C && (J(C, { cssWidth: _.cssWidth, cssHeight: _.cssHeight, cornerRadius: _.cornerRadius }), w.style.setProperty("--mfx-radius", `${_.cornerRadius}px`), w.style.borderRadius = `${_.cornerRadius}px`, S && (S.innerHTML = "", l = De(S, {
|
|
1498
|
+
width: _.cssWidth,
|
|
1499
|
+
height: _.cssHeight,
|
|
1500
|
+
cornerRadius: _.cornerRadius,
|
|
1501
|
+
kind: p.value,
|
|
1502
|
+
scale: a.scale
|
|
1503
|
+
}), C && l && re.set(C, { handles: l, themeRef: u })));
|
|
1504
|
+
}));
|
|
1505
|
+
});
|
|
1506
|
+
F.observe(w);
|
|
1507
|
+
let L = null;
|
|
1508
|
+
typeof IntersectionObserver < "u" && (L = new IntersectionObserver(
|
|
1509
|
+
(_) => {
|
|
1510
|
+
const C = c;
|
|
1511
|
+
if (C)
|
|
1512
|
+
for (const $ of _) Yt(C, $.isIntersecting);
|
|
1513
|
+
},
|
|
1514
|
+
{ rootMargin: "64px" }
|
|
1515
|
+
), L.observe(w)), c && l && (re.set(c, { handles: l, themeRef: u }), Vt(c)), x = () => {
|
|
1516
|
+
F.disconnect(), L == null || L.disconnect(), b !== 0 && cancelAnimationFrame(b);
|
|
1517
|
+
const _ = c;
|
|
1518
|
+
_ && (re.delete(_), qt(_), Xt(_)), c = null, l = null, S && (S.innerHTML = "");
|
|
1519
|
+
};
|
|
1520
|
+
};
|
|
1521
|
+
let M = null;
|
|
1522
|
+
const O = () => {
|
|
1523
|
+
M == null || M(), M = null;
|
|
1524
|
+
const y = c, w = n.value, S = a.reflectionTargets;
|
|
1525
|
+
if (!y || !w || !S || g.value !== "dark") return;
|
|
1526
|
+
y.onAfterFrame = an;
|
|
1527
|
+
const R = S.flatMap((v) => {
|
|
1528
|
+
const b = yt(v);
|
|
1529
|
+
return b ? [b] : [];
|
|
1530
|
+
});
|
|
1531
|
+
for (const v of R) Za(v, y, w);
|
|
1532
|
+
M = () => {
|
|
1533
|
+
y.onAfterFrame = void 0;
|
|
1534
|
+
for (const v of R) en(v);
|
|
1535
|
+
};
|
|
1536
|
+
};
|
|
1537
|
+
Qe(() => {
|
|
1538
|
+
E(), Ce(O);
|
|
1539
|
+
}), z(p, () => {
|
|
1540
|
+
x == null || x(), x = null, M == null || M(), M = null, E(), Ce(O);
|
|
1541
|
+
}, { flush: "post" }), z([() => a.reflectionTargets, g], () => {
|
|
1542
|
+
O();
|
|
1543
|
+
}, { flush: "post" }), Je(() => {
|
|
1544
|
+
M == null || M(), M = null, x == null || x(), x = null;
|
|
1545
|
+
}), z([() => a.borderRadius, g, () => a.variant], () => {
|
|
1546
|
+
const y = n.value, w = c;
|
|
1547
|
+
if (!y || !w) return;
|
|
1548
|
+
const S = m(w.cssWidth, w.cssHeight);
|
|
1549
|
+
J(w, { cornerRadius: S }), y.style.setProperty("--mfx-radius", `${S}px`), y.style.borderRadius = `${S}px`;
|
|
1550
|
+
}, { flush: "post" });
|
|
1551
|
+
const P = ue(() => ({
|
|
1552
|
+
"--mfx-strength": String(Math.min(1, Math.max(0, a.strength))),
|
|
1553
|
+
opacity: f.value ? 1 : 0,
|
|
1554
|
+
visibility: f.value ? "visible" : "hidden",
|
|
1555
|
+
transition: f.value ? "opacity 0.15s ease-out" : "none"
|
|
1556
|
+
}));
|
|
1557
|
+
return (y, w) => (xt(), vt("div", {
|
|
1558
|
+
ref_key: "rootRef",
|
|
1559
|
+
ref: n,
|
|
1560
|
+
class: "metal-fx-root",
|
|
1561
|
+
"data-variant": e.variant,
|
|
1562
|
+
"data-shape": p.value,
|
|
1563
|
+
"data-theme": bt(g),
|
|
1564
|
+
"data-paused": e.paused ? "true" : void 0,
|
|
1565
|
+
"data-normalize": e.normalizeHostStyles ? "true" : "false",
|
|
1566
|
+
style: ke(P.value)
|
|
1567
|
+
}, [
|
|
1568
|
+
te("canvas", {
|
|
1569
|
+
ref_key: "canvasRef",
|
|
1570
|
+
ref: o,
|
|
1571
|
+
class: "metal-fx-canvas",
|
|
1572
|
+
style: sn
|
|
1573
|
+
}, null, 512),
|
|
1574
|
+
te("div", {
|
|
1575
|
+
class: "metal-fx-inner",
|
|
1576
|
+
"aria-hidden": "true",
|
|
1577
|
+
style: ln
|
|
1578
|
+
}),
|
|
1579
|
+
te("div", {
|
|
1580
|
+
ref_key: "glowHostRef",
|
|
1581
|
+
ref: r,
|
|
1582
|
+
"aria-hidden": "true",
|
|
1583
|
+
style: ke([cn, h.value ? null : { display: "none" }])
|
|
1584
|
+
}, null, 4),
|
|
1585
|
+
te("div", {
|
|
1586
|
+
ref_key: "contentRef",
|
|
1587
|
+
ref: s,
|
|
1588
|
+
class: "metal-fx-content"
|
|
1589
|
+
}, [
|
|
1590
|
+
wt(y.$slots, "default")
|
|
1591
|
+
], 512)
|
|
1592
|
+
], 12, rn));
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
export {
|
|
1596
|
+
pn as MetalFx,
|
|
1597
|
+
Ze as PRESETS,
|
|
1598
|
+
Ut as createInstance,
|
|
1599
|
+
Xt as destroyInstance,
|
|
1600
|
+
_t as hexToRgb,
|
|
1601
|
+
un as pauseShared,
|
|
1602
|
+
hn as resumeShared,
|
|
1603
|
+
jt as setSharedPreset,
|
|
1604
|
+
J as updateInstance
|
|
1605
|
+
};
|