familiar-vue 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +8 -3
  2. package/dist/blocks/bots/engine/plastic.d.ts +5 -0
  3. package/dist/blocks/bots/engine/types.d.ts +5 -3
  4. package/dist/blocks/bots/types-1.d.ts +2 -2
  5. package/dist/blocks/bots/types.d.ts +2 -2
  6. package/dist/blocks/gallery/GalleryGrid.vue.d.ts +46 -0
  7. package/dist/blocks/gallery/MusicPlayer.vue.d.ts +34 -0
  8. package/dist/blocks/gallery/VideoPlayer.vue.d.ts +34 -0
  9. package/dist/blocks/gallery/icons.d.ts +49 -0
  10. package/dist/blocks/gallery/index.d.ts +141 -0
  11. package/dist/blocks/gallery/styles.d.ts +1 -0
  12. package/dist/blocks/gallery/support.d.ts +38 -0
  13. package/dist/blocks/gallery/types.d.ts +132 -0
  14. package/dist/blocks/image/studio/ImageStudio.vue.d.ts +1 -1
  15. package/dist/blocks/jelly/JellySurface.vue.d.ts +43 -0
  16. package/dist/blocks/jelly/engine/color.d.ts +12 -0
  17. package/dist/blocks/jelly/engine/environment.d.ts +2 -0
  18. package/dist/blocks/jelly/engine/frosted.d.ts +25 -0
  19. package/dist/blocks/jelly/engine/geometry.d.ts +13 -0
  20. package/dist/blocks/jelly/engine/icons.d.ts +16 -0
  21. package/dist/blocks/jelly/engine/renderer.d.ts +39 -0
  22. package/dist/blocks/jelly/engine/sound.d.ts +9 -0
  23. package/dist/blocks/jelly/engine/textures.d.ts +5 -0
  24. package/dist/blocks/jelly/index.d.ts +23 -0
  25. package/dist/blocks/jelly/types.d.ts +68 -0
  26. package/dist/blocks/loading/BreathingRing.vue.d.ts +25 -0
  27. package/dist/blocks/loading/index.d.ts +54 -1
  28. package/dist/blocks/loading/types.d.ts +22 -0
  29. package/dist/blocks/metal/MetalBadge.vue.d.ts +2 -2
  30. package/dist/bots.cjs +1 -1
  31. package/dist/bots.js +1 -1
  32. package/dist/familiar-vue.css +1 -1
  33. package/dist/gallery.cjs +2 -0
  34. package/dist/gallery.cjs.map +1 -0
  35. package/dist/gallery.d.ts +1 -0
  36. package/dist/gallery.js +8 -0
  37. package/dist/gallery.js.map +1 -0
  38. package/dist/index-Bb3rhhZY.cjs +221 -0
  39. package/dist/index-Bb3rhhZY.cjs.map +1 -0
  40. package/dist/index-C96O9k0x.cjs +289 -0
  41. package/dist/index-C96O9k0x.cjs.map +1 -0
  42. package/dist/index-CgkG0Pah.js +2580 -0
  43. package/dist/index-CgkG0Pah.js.map +1 -0
  44. package/dist/index-CjA5aaxl.js +934 -0
  45. package/dist/index-CjA5aaxl.js.map +1 -0
  46. package/dist/index-CpPZg7s9.js +476 -0
  47. package/dist/index-CpPZg7s9.js.map +1 -0
  48. package/dist/{index-CQIOTNIw.js → index-Da5OgBHn.js} +1269 -1239
  49. package/dist/index-Da5OgBHn.js.map +1 -0
  50. package/dist/index-Dc4JnH_g.cjs +80 -0
  51. package/dist/index-Dc4JnH_g.cjs.map +1 -0
  52. package/dist/index-U59nAOr-.cjs +1096 -0
  53. package/dist/index-U59nAOr-.cjs.map +1 -0
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.d.ts +8 -2
  56. package/dist/index.js +58 -49
  57. package/dist/index.js.map +1 -1
  58. package/dist/jelly.cjs +2 -0
  59. package/dist/jelly.cjs.map +1 -0
  60. package/dist/jelly.d.ts +2 -0
  61. package/dist/jelly.js +9 -0
  62. package/dist/jelly.js.map +1 -0
  63. package/dist/loading.cjs +1 -1
  64. package/dist/loading.js +4 -3
  65. package/package.json +11 -1
  66. package/dist/index-BAZi5af3.cjs +0 -221
  67. package/dist/index-BAZi5af3.cjs.map +0 -1
  68. package/dist/index-BmMsid7x.js +0 -422
  69. package/dist/index-BmMsid7x.js.map +0 -1
  70. package/dist/index-CQIOTNIw.js.map +0 -1
  71. package/dist/index-DZJ-MNwi.cjs +0 -80
  72. package/dist/index-DZJ-MNwi.cjs.map +0 -1
@@ -0,0 +1,934 @@
1
+ import { defineComponent as et, ref as se, computed as ce, watch as tt, onMounted as ot, onBeforeUnmount as nt, openBlock as be, createElementBlock as ye, normalizeStyle as rt, normalizeClass as at, createElementVNode as ue, withDirectives as it, vShow as st, createCommentVNode as Se, toDisplayString as lt, renderSlot as ct } from "vue";
2
+ import * as r from "three";
3
+ function xe(n) {
4
+ return n < 0.04045 ? n * 0.0773993808 : Math.pow(n * 0.9478672986 + 0.0521327014, 2.4);
5
+ }
6
+ function ut(n) {
7
+ return n < 31308e-7 ? n * 12.92 : 1.055 * Math.pow(n, 0.41666) - 0.055;
8
+ }
9
+ function Z(n) {
10
+ const o = new r.Color(n);
11
+ if (r.ColorManagement.legacyMode === !1) return o;
12
+ const d = new r.Color();
13
+ return d.r = xe(o.r), d.g = xe(o.g), d.b = xe(o.b), d;
14
+ }
15
+ function De(n) {
16
+ const o = new r.Color(n);
17
+ return r.ColorManagement.legacyMode === !1 && o.convertLinearToSRGB(), [o.r, o.g, o.b];
18
+ }
19
+ function le(n) {
20
+ if (r.ColorManagement.legacyMode === !1) return `#${n.getHexString()}`;
21
+ const o = (d) => {
22
+ const e = ut(Math.max(0, Math.min(1, d)));
23
+ return Math.round(Math.max(0, Math.min(1, e)) * 255).toString(16).padStart(2, "0");
24
+ };
25
+ return `#${o(n.r)}${o(n.g)}${o(n.b)}`;
26
+ }
27
+ const ht = 1.44, dt = (
28
+ /* glsl */
29
+ `
30
+ varying vec2 v_uv;
31
+
32
+ void main() {
33
+ // The engine's unit plane is 1x1; the quad must cover the padded scissor
34
+ // viewport, so write clip space directly and ignore the camera matrices.
35
+ v_uv = position.xy * 2.0;
36
+ gl_Position = vec4(position.xy * 2.0, 0.0, 1.0);
37
+ }
38
+ `
39
+ ), ft = (
40
+ /* glsl */
41
+ `
42
+ varying vec2 v_uv;
43
+
44
+ uniform float u_span; // padded viewport half-extent (1.44)
45
+ uniform vec2 u_halfSize; // Physical half-size in normalized units (aspectW, aspectH)
46
+ uniform float u_radius; // Corner radius ratio [0.06 .. 1.0]
47
+ uniform float u_ior; // Index of refraction (1.10 ~ 2.20)
48
+ uniform float u_thickness; // Acrylic optical thickness (0.30 ~ 2.60)
49
+ uniform vec2 u_tilt; // Hover 3D tilt (rotY, rotX in radians)
50
+ uniform float u_scale; // Hover & spring press scale
51
+ uniform float u_press; // Spring press depth [0..1]
52
+ uniform vec3 u_baseColor; // RGB primary jelly color
53
+ uniform float u_isCrystal; // 1.0 if clear white crystal mode
54
+ uniform float u_hasGradient; // 1.0 if multi-stop sunset gradient
55
+ uniform vec3 u_grad0;
56
+ uniform vec3 u_grad1;
57
+ uniform vec3 u_grad2;
58
+ uniform vec3 u_grad3;
59
+ uniform vec2 u_pointer; // Interactive pointer light offset
60
+
61
+ // Exact 2D Signed Distance Function (SDF) for a Rounded Box / Capsule / Circle
62
+ float sdRoundedBox2D(vec2 p, vec2 b, float r) {
63
+ vec2 q = abs(p) - b + r;
64
+ return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
65
+ }
66
+
67
+ // Smooth Analytical 2D Outward Normal along the Rounded Box / Capsule perimeter
68
+ vec2 gradRoundedBox2D(vec2 p, vec2 b, float r) {
69
+ const float eps = 0.0012;
70
+ float dx = sdRoundedBox2D(p + vec2(eps, 0.0), b, r) - sdRoundedBox2D(p - vec2(eps, 0.0), b, r);
71
+ float dy = sdRoundedBox2D(p + vec2(0.0, eps), b, r) - sdRoundedBox2D(p - vec2(0.0, eps), b, r);
72
+ return normalize(vec2(dx, dy) + vec2(1e-6));
73
+ }
74
+
75
+ // Exact Analytic 3D Jelly Cushion Height Z(p) & Exact 3D Surface Normal N(p)
76
+ // ZERO raymarching stepping artifacts — 100% smooth G2 continuous normals!
77
+ void evalJellySurface3D(
78
+ vec2 p,
79
+ vec2 b,
80
+ float r,
81
+ float bevelW,
82
+ float halfDepth,
83
+ out float sdf2D,
84
+ out float bevelU,
85
+ out float zHeight,
86
+ out vec2 contourN2D,
87
+ out vec3 normal3D
88
+ ) {
89
+ sdf2D = sdRoundedBox2D(p, b, r);
90
+ contourN2D = gradRoundedBox2D(p, b, r);
91
+
92
+ // bevelU: 0.0 on the flat inner plateau, smoothly increasing to 1.0 at the outer equator rim
93
+ bevelU = clamp(1.0 + sdf2D / bevelW, 0.0, 1.0);
94
+
95
+ // Smooth super-elliptical quarter-dome profile:
96
+ // Flat plateau (bevelU == 0 -> z = halfDepth) curving down to 0 at equator (bevelU == 1)
97
+ float uCurve = smoothstep(0.0, 1.0, bevelU);
98
+ float radArg = max(0.0004, 1.0 - uCurve * uCurve);
99
+ zHeight = halfDepth * sqrt(radArg);
100
+
101
+ // Analytic derivative dz/d(sdf2D) gives the exact 3D surface normal
102
+ // As bevelU -> 1.0 at the outer rim, the normal tilts smoothly to horizontal (side wall)
103
+ float dU_dSdf = (bevelU > 0.0001 && bevelU < 0.9999) ? (1.0 / bevelW) : 0.0;
104
+ float dCurve_dU = 6.0 * bevelU * (1.0 - bevelU);
105
+ float dz_dSdf = -halfDepth * (uCurve / sqrt(radArg)) * dCurve_dU * dU_dSdf;
106
+
107
+ // Outward 3D normal: (-dz/dx, -dz/dy, 1.0) normalized
108
+ normal3D = normalize(vec3(-contourN2D * dz_dSdf, 1.0));
109
+ }
110
+
111
+ // 5-stop vivid gradient matching Three.js Instagram/Sunset backing texture
112
+ vec3 evalRichGradient(vec2 uv01) {
113
+ float t = clamp(uv01.x * 0.56 + (1.0 - uv01.y) * 0.56 - 0.06, 0.0, 1.0);
114
+ if (t < 0.333) {
115
+ return mix(u_grad0, u_grad1, smoothstep(0.0, 1.0, t * 3.0));
116
+ } else if (t < 0.666) {
117
+ return mix(u_grad1, u_grad2, smoothstep(0.0, 1.0, (t - 0.333) * 3.0));
118
+ } else {
119
+ return mix(u_grad2, u_grad3, smoothstep(0.0, 1.0, (t - 0.666) * 3.0));
120
+ }
121
+ }
122
+
123
+ // Studio Softbox HDR Environment Map in Spherical Reflection Space (Works at all grazing angles!)
124
+ vec3 sampleStudioSoftboxHDR(vec3 R, vec2 ptr) {
125
+ // Base studio ambient dome (bright clean photography cyclorama)
126
+ float skyGrad = clamp(R.y * 0.5 + 0.5, 0.0, 1.0);
127
+ vec3 env = mix(vec3(0.18, 0.21, 0.27), vec3(0.42, 0.46, 0.54), skyGrad);
128
+
129
+ // 1. Main Overhead Studio Softbox (Wide luminous diffused light bank above & slightly in front)
130
+ vec3 L_top = normalize(vec3(ptr.x * 0.25, 0.78 - ptr.y * 0.18, 0.62));
131
+ float topSoftbox = smoothstep(0.68, 0.94, dot(R, L_top));
132
+ env += vec3(2.85, 2.90, 3.00) * topSoftbox;
133
+
134
+ // 2. Top-Left Key Rim Strip Light (Creates the signature reference-photo upper-left glossy highlight)
135
+ vec3 L_keyLeft = normalize(vec3(-0.62 + ptr.x * 0.2, 0.64 - ptr.y * 0.2, 0.45));
136
+ float keyLeftStrip = smoothstep(0.74, 0.96, dot(R, L_keyLeft));
137
+ env += vec3(2.50, 2.55, 2.65) * keyLeftStrip;
138
+
139
+ // 3. Right Contour Rim Softbox
140
+ vec3 L_right = normalize(vec3(0.76, 0.15, 0.63));
141
+ float rightStrip = smoothstep(0.76, 0.95, dot(R, L_right));
142
+ env += vec3(1.65, 1.72, 1.88) * rightStrip;
143
+
144
+ // 4. Bottom Uplight White Reflector Card (Creates the luminous lower bevel bounce arc)
145
+ vec3 L_bot = normalize(vec3(0.12, -0.82, 0.56));
146
+ float botCard = smoothstep(0.70, 0.93, dot(R, L_bot));
147
+ env += vec3(1.45, 1.52, 1.65) * botCard;
148
+
149
+ return env;
150
+ }
151
+
152
+ void main() {
153
+ // 1. Map viewport coordinates with 3D perspective foreshortening & hover scale
154
+ vec2 span = u_halfSize * u_span;
155
+ vec2 p = (v_uv * span) / max(0.65, u_scale);
156
+
157
+ // Apply subtle 3D perspective parallax shift when tilting on hover
158
+ float persp = 1.0 + (p.x * u_tilt.x - p.y * u_tilt.y) * 0.14;
159
+ p *= persp;
160
+ p -= vec2(u_tilt.x, -u_tilt.y) * 0.08;
161
+
162
+ float minHalf = min(u_halfSize.x, u_halfSize.y);
163
+ float cornerR = clamp(u_radius, 0.06, 1.0) * minHalf;
164
+ float bevelW = minHalf * 0.31; // Wide, plush jelly bevel shoulder
165
+ float halfDepth = minHalf * (0.42 - u_press * 0.11);
166
+
167
+ // 2. Evaluate exact 3D Jelly Surface Height & Analytic 3D Normal
168
+ float sdf2D, bevelU, zHeight;
169
+ vec2 contourN2D;
170
+ vec3 localN;
171
+ evalJellySurface3D(p, u_halfSize, cornerR, bevelW, halfDepth, sdf2D, bevelU, zHeight, contourN2D, localN);
172
+
173
+ // Crisp analytical anti-aliased outer silhouette
174
+ float aa = fwidth(sdf2D) * 1.15;
175
+ float alpha = 1.0 - smoothstep(-aa, aa, sdf2D);
176
+ if (alpha <= 0.002) {
177
+ discard;
178
+ }
179
+
180
+ // Apply interactive 3D hover tilt to the surface normal
181
+ vec3 N = normalize(vec3(
182
+ localN.x + u_tilt.x * 0.75,
183
+ localN.y - u_tilt.y * 0.75,
184
+ localN.z
185
+ ));
186
+ vec3 V = normalize(vec3(-p * 0.18, 1.0));
187
+
188
+ // 3. Snell's Law 3D Refraction through the thick acrylic dome + Chromatic Dispersion
189
+ float iorR = max(1.08, u_ior - 0.022);
190
+ float iorG = max(1.10, u_ior);
191
+ float iorB = max(1.12, u_ior + 0.024);
192
+
193
+ vec3 TR = refract(-V, N, 1.0 / iorR);
194
+ vec3 TG = refract(-V, N, 1.0 / iorG);
195
+ vec3 TB = refract(-V, N, 1.0 / iorB);
196
+
197
+ // Optical path thickness from the curved front dome down to the internal pigment backing plate
198
+ float opticalDepth = (zHeight + halfDepth * 0.55) * u_thickness;
199
+ vec2 pBackR = p + (TR.xy / max(0.28, -TR.z)) * opticalDepth * 0.52;
200
+ vec2 pBackG = p + (TG.xy / max(0.28, -TG.z)) * opticalDepth * 0.52;
201
+ vec2 pBackB = p + (TB.xy / max(0.28, -TB.z)) * opticalDepth * 0.52;
202
+
203
+ vec2 uvR = (pBackR / (u_halfSize * 2.0)) + 0.5;
204
+ vec2 uvG = (pBackG / (u_halfSize * 2.0)) + 0.5;
205
+ vec2 uvB = (pBackB / (u_halfSize * 2.0)) + 0.5;
206
+
207
+ // 4. Internal Pigment Core & Subsurface Scattering Glow (Bright, Juicy, High-Saturation!)
208
+ vec3 bodyColor;
209
+ if (u_isCrystal > 0.5) {
210
+ // Clear Crystal White Acrylic (Reference Photo Top-Right Nike Style):
211
+ // Luminous pure white studio base + cool silver-graphite refractive bevel ring + bright crystal rim lip
212
+ float domeLight = clamp(0.55 + 0.45 * (uvG.y - uvG.x * 0.25), 0.0, 1.0);
213
+ vec3 crystalBase = mix(vec3(0.90, 0.93, 0.97), vec3(1.0, 1.0, 1.0), domeLight);
214
+
215
+ // Inner silver-gray glass thickness refraction band along the curved bevel
216
+ float glassRefractRing = exp(-pow((bevelU - 0.64) / 0.20, 2.0));
217
+ // Outer bright crystal caustic lip
218
+ float crystalOuterLip = exp(-pow((bevelU - 0.89) / 0.075, 2.0));
219
+
220
+ bodyColor = mix(crystalBase, vec3(0.52, 0.57, 0.64), glassRefractRing * 0.58);
221
+ bodyColor += vec3(0.96, 0.99, 1.0) * crystalOuterLip * 0.62;
222
+
223
+ // Subtle prism dispersion at the crystal bevel
224
+ bodyColor.r += glassRefractRing * 0.035;
225
+ bodyColor.b += glassRefractRing * 0.065;
226
+ } else if (u_hasGradient > 0.5) {
227
+ // Multi-stop Sunset / Instagram Gradient with RGB dispersion
228
+ float cR = evalRichGradient(uvR).r;
229
+ float cG = evalRichGradient(uvG).g;
230
+ float cB = evalRichGradient(uvB).b;
231
+ bodyColor = vec3(cR, cG, cB);
232
+
233
+ // Inner subsurface luminosity boost in the center
234
+ float centerGlow = 1.0 - smoothstep(0.0, 0.95, length(p / u_halfSize));
235
+ bodyColor = min(vec3(1.0), bodyColor * (1.05 + centerGlow * 0.14));
236
+ } else {
237
+ // Solid Juicy Jelly Color (Xiaomi Orange, WeChat Green, NetEase Red, etc.)
238
+ // Center has a warm subsurface transmission glow; body has rich pure chroma
239
+ float radNorm = length(pBackG / (u_halfSize * 1.15));
240
+ vec3 juicyCenter = min(vec3(1.0), pow(u_baseColor, vec3(0.84)) * 1.22 + vec3(0.08, 0.06, 0.02));
241
+ vec3 richBase = u_baseColor * 1.04;
242
+ bodyColor = mix(juicyCenter, richBase, smoothstep(0.0, 0.92, radNorm));
243
+ }
244
+
245
+ // 5. Signature Acrylic Jelly Optical Depth Layers (Reference Photo Fidelity):
246
+ // (a) Rich Inner Bevel Depth Ring (bevelU ~ 0.48) where acrylic thickness increases
247
+ // (b) Luminous Golden/Emerald Internal Caustic Rim Band (bevelU ~ 0.82)
248
+ if (u_isCrystal < 0.5) {
249
+ // (a) Subtle rich thickness absorption along the inner bevel shoulder (never muddy black!)
250
+ float depthTrench = exp(-pow((bevelU - 0.50) / 0.21, 2.0));
251
+ vec3 richDeepTone = pow(max(bodyColor, vec3(0.02)), vec3(1.42)) * 0.76;
252
+ bodyColor = mix(bodyColor, richDeepTone, depthTrench * clamp(0.32 * u_thickness, 0.15, 0.58));
253
+
254
+ // (b) Internal Total-Reflection Caustic Rim (Glowing amber/emerald light trapped inside the outer rim!)
255
+ float causticRim = exp(-pow((bevelU - 0.83) / 0.11, 2.0));
256
+ vec3 glowingRimColor = min(vec3(1.0), pow(bodyColor, vec3(0.60)) * 1.38 + vec3(0.30, 0.25, 0.06));
257
+ // Stronger on bottom & side rims where overhead studio light exits after internal bounce
258
+ float rimDirectional = clamp(0.65 + 0.35 * (-contourN2D.y * 0.6 + abs(contourN2D.x) * 0.4), 0.35, 1.0);
259
+ bodyColor = mix(bodyColor, glowingRimColor, causticRim * rimDirectional * 0.85);
260
+
261
+ // Crisp thin outer edge definition (bevelU > 0.93)
262
+ float outerEdge = smoothstep(0.92, 1.0, bevelU);
263
+ bodyColor *= (1.0 - outerEdge * 0.30);
264
+ }
265
+
266
+ // 6. Studio Softbox Specular Reflections + Signature Curved Rim Highlight Tubes
267
+ float NdotV = clamp(dot(N, V), 0.0, 1.0);
268
+ float f0 = pow((1.0 - u_ior) / (1.0 + u_ior), 2.0);
269
+ float fresnel = f0 + (1.0 - f0) * pow(1.0 - NdotV, 4.2);
270
+
271
+ vec3 R = reflect(-V, N);
272
+ vec3 studioRefl = sampleStudioSoftboxHDR(R, u_pointer);
273
+
274
+ // Reference-Photo Signature Glossy White Rim Highlight Tubes hugging the curved bevel shoulder:
275
+ // Continuous, ultra-clean white light strip along bevelU in [0.46 .. 0.74]
276
+ float rimTubeRadial = exp(-pow((bevelU - 0.58) / 0.115, 2.0)) * smoothstep(0.15, 0.42, bevelU);
277
+
278
+ // Top & Top-Left / Top-Right sweeping softbox reflection arc
279
+ float topLightAngle = dot(contourN2D, normalize(vec2(-0.28 + u_pointer.x * 0.3, 0.96 - u_pointer.y * 0.2)));
280
+ float topRimArc = smoothstep(-0.15, 0.68, topLightAngle);
281
+
282
+ // Secondary Left & Right vertical contour highlight strips
283
+ float sideRimArc = pow(abs(contourN2D.x), 1.6) * smoothstep(-0.4, 0.6, contourN2D.y);
284
+
285
+ // Bottom-Right glossy counter-reflection arc
286
+ float botLightAngle = dot(contourN2D, normalize(vec2(0.38 - u_pointer.x * 0.25, -0.92 + u_pointer.y * 0.2)));
287
+ float botRimArc = smoothstep(0.15, 0.82, botLightAngle);
288
+
289
+ float studioRimHighlight = rimTubeRadial * (topRimArc * 0.98 + sideRimArc * 0.38 + botRimArc * 0.52);
290
+
291
+ // Direct Key & Fill Area Light Speculars on the 3D Curved Bevel
292
+ vec3 L_key = normalize(vec3(-0.32 + u_pointer.x * 0.35, 0.56 - u_pointer.y * 0.35, 0.76));
293
+ vec3 H_key = normalize(L_key + V);
294
+ float specKeySharp = pow(max(0.0, dot(N, H_key)), 110.0) * 0.95;
295
+ float specKeyBroad = pow(max(0.0, dot(N, H_key)), 20.0) * 0.18;
296
+
297
+ vec3 L_fill = normalize(vec3(0.45, -0.52, 0.72));
298
+ vec3 H_fill = normalize(L_fill + V);
299
+ float specFillSharp = pow(max(0.0, dot(N, H_fill)), 85.0) * 0.48;
300
+
301
+ // Top flat-face subtle studio softbox sheen (gives the flat face a wet glass coat feel)
302
+ float flatFaceMask = 1.0 - smoothstep(0.0, 0.45, bevelU);
303
+ float topGlassSheen = flatFaceMask * smoothstep(-0.15, 0.92, (p.y / u_halfSize.y) - u_tilt.y * 1.2) * 0.14;
304
+
305
+ // 7. Final Physical Composition
306
+ vec3 color = bodyColor;
307
+ // Blend Fresnel Studio Environment reflection along the curved 3D bevel
308
+ color = mix(color, studioRefl, clamp(fresnel * 0.52, 0.0, 0.74));
309
+ // Add crisp white studio softbox rim tubes & area light speculars
310
+ color += vec3(1.0, 0.995, 0.99) * (studioRimHighlight + specKeySharp + specKeyBroad + specFillSharp + topGlassSheen);
311
+
312
+ // Clean Filmic Highlight Compression (preserves vivid saturation while keeping highlights silky)
313
+ vec3 x = max(vec3(0.0), color * 1.04);
314
+ color = clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
315
+ color = pow(color, vec3(0.92));
316
+
317
+ gl_FragColor = vec4(color * alpha, alpha);
318
+ }
319
+ `
320
+ );
321
+ function pt() {
322
+ return new r.ShaderMaterial({
323
+ uniforms: {
324
+ u_span: { value: ht },
325
+ u_halfSize: { value: new r.Vector2(1, 1) },
326
+ u_radius: { value: 0.45 },
327
+ u_ior: { value: 1.52 },
328
+ u_thickness: { value: 1.45 },
329
+ u_tilt: { value: new r.Vector2(0, 0) },
330
+ u_scale: { value: 1 },
331
+ u_press: { value: 0 },
332
+ u_baseColor: { value: new r.Vector3(1, 0.4039, 0) },
333
+ u_isCrystal: { value: 0 },
334
+ u_hasGradient: { value: 0 },
335
+ u_grad0: { value: new r.Vector3(0.38, 0.08, 0.91) },
336
+ u_grad1: { value: new r.Vector3(0.88, 0.19, 0.42) },
337
+ u_grad2: { value: new r.Vector3(0.99, 0.49, 0.08) },
338
+ u_grad3: { value: new r.Vector3(1, 0.78, 0) },
339
+ u_pointer: { value: new r.Vector2(0, 0) }
340
+ },
341
+ vertexShader: dt,
342
+ fragmentShader: ft,
343
+ transparent: !0,
344
+ depthTest: !1,
345
+ depthWrite: !1,
346
+ premultipliedAlpha: !0,
347
+ side: r.DoubleSide,
348
+ extensions: { derivatives: !0 }
349
+ });
350
+ }
351
+ const Le = /* @__PURE__ */ new Map();
352
+ function we(n, o, d, e, p, b) {
353
+ const s = Math.min(d, n, o), a = Math.max(0, n - s), c = Math.max(0, o - s), u = [];
354
+ for (let t = 0; t < b; t++) {
355
+ const i = t / b;
356
+ u.push([n, -c + 2 * c * i]);
357
+ }
358
+ for (let t = 0; t < e; t++) {
359
+ const i = t / e * (Math.PI * 0.5);
360
+ u.push([a + s * Math.cos(i), c + s * Math.sin(i)]);
361
+ }
362
+ for (let t = 0; t < p; t++) {
363
+ const i = t / p;
364
+ u.push([a - 2 * a * i, o]);
365
+ }
366
+ for (let t = 0; t < e; t++) {
367
+ const i = Math.PI * 0.5 + t / e * (Math.PI * 0.5);
368
+ u.push([-a + s * Math.cos(i), c + s * Math.sin(i)]);
369
+ }
370
+ for (let t = 0; t < b; t++) {
371
+ const i = t / b;
372
+ u.push([-n, c - 2 * c * i]);
373
+ }
374
+ for (let t = 0; t < e; t++) {
375
+ const i = Math.PI + t / e * (Math.PI * 0.5);
376
+ u.push([-a + s * Math.cos(i), -c + s * Math.sin(i)]);
377
+ }
378
+ for (let t = 0; t < p; t++) {
379
+ const i = t / p;
380
+ u.push([-a + 2 * a * i, -o]);
381
+ }
382
+ for (let t = 0; t < e; t++) {
383
+ const i = Math.PI * 1.5 + t / e * (Math.PI * 0.5);
384
+ u.push([a + s * Math.cos(i), -c + s * Math.sin(i)]);
385
+ }
386
+ return u.push([u[0][0], u[0][1]]), u;
387
+ }
388
+ function Me(n, o, d) {
389
+ const e = Math.round(n * 20) / 20, p = Math.round(o * 20) / 20, b = Math.round(r.MathUtils.clamp(d, 0.06, 1) * 50) / 50, s = `geo_v4_${e}_${p}_${b}`, a = Le.get(s);
390
+ if (a) return a;
391
+ const c = e * 1.06, u = p * 1.06, t = Math.min(c, u), i = 0.34, y = r.MathUtils.clamp(b, 0.06, 1) * t, w = t * 0.34, $ = Math.max(0, c - t), Y = Math.max(0, u - t), l = 24, F = Math.max(12, Math.round(20 * (c / t))), m = Math.max(12, Math.round(20 * (u / t))), C = 4 * l + 2 * F + 2 * m, x = 5, L = 16, f = x + L, _ = f * 2, M = Math.max(0.02, c - w), A = Math.max(0.02, u - w), re = Math.max(0.015, y - w), oe = we(
392
+ M,
393
+ A,
394
+ re,
395
+ l,
396
+ F,
397
+ m
398
+ ), j = [], T = [];
399
+ for (let S = 0; S <= f; S++)
400
+ if (S <= x) {
401
+ const z = S / x, P = [];
402
+ for (let N = 0; N <= C; N++) {
403
+ const [k, I] = oe[N], Q = r.MathUtils.clamp(k, -$, $), ee = r.MathUtils.clamp(I, -Y, Y);
404
+ P.push([Q + (k - Q) * z, ee + (I - ee) * z]);
405
+ }
406
+ j.push(P), T.push(i);
407
+ } else {
408
+ const P = (S - x) / L * (Math.PI * 0.5), N = Math.sin(P), k = w * (1 - N), I = Math.max(0.02, c - k), Q = Math.max(0.02, u - k), ee = Math.max(0.012, y - k);
409
+ j.push(
410
+ we(
411
+ I,
412
+ Q,
413
+ ee,
414
+ l,
415
+ F,
416
+ m
417
+ )
418
+ ), T.push(i * Math.pow(Math.max(0, Math.cos(P)), 0.88));
419
+ }
420
+ const K = [], q = [], O = [];
421
+ for (let S = 0; S <= _; S++) {
422
+ const z = S <= f, P = z ? S : _ - S, N = j[P], k = (z ? 1 : -1) * T[P];
423
+ for (let I = 0; I <= C; I++) {
424
+ const [Q, ee] = N[I];
425
+ K.push(Q, ee, k), q.push(Q / (2 * c) + 0.5, ee / (2 * u) + 0.5);
426
+ }
427
+ }
428
+ const ne = C + 1;
429
+ for (let S = 0; S < _; S++)
430
+ for (let z = 0; z < C; z++) {
431
+ const P = S * ne + z, N = P + 1, k = (S + 1) * ne + z, I = k + 1;
432
+ O.push(P, k, N), O.push(N, k, I);
433
+ }
434
+ const X = new r.BufferGeometry();
435
+ return X.setIndex(O), X.setAttribute("position", new r.Float32BufferAttribute(K, 3)), X.setAttribute("uv", new r.Float32BufferAttribute(q, 2)), X.computeVertexNormals(), Le.set(s, X), X;
436
+ }
437
+ const ze = {
438
+ mi: '<svg viewBox="0 0 1024 1024" width="100%" height="100%" fill="currentColor"><path d="M230 689V363c0-15.5 12.5-28 28-28h267c60.8 0 110 49.2 110 110v244h-95V460c0-21.5-17.5-39-39-39H325v268h-95zm160-196h92v196h-92V493zm310-158h94v354h-94V335z"/></svg>',
439
+ nike: `<svg viewBox="0 0 1024 1024" width="100%" height="100%" fill="currentColor"><text x="515" y="470" text-anchor="middle" font-family="'Arial Black', Impact, sans-serif" font-weight="900" font-style="italic" font-size="185" letter-spacing="-6">NIKE</text><path d="M310 488c-60 80-88 162-38 204 50 40 156 4 263-46l330-154c-307 86-460 123-517 96-38-18-50-58-38-100z"/></svg>`,
440
+ music: '<svg viewBox="0 0 1024 1024" width="100%" height="100%" fill="none" stroke="currentColor" stroke-width="68" stroke-linecap="round" stroke-linejoin="round"><path d="M 713 642 A 225 225 0 1 1 425 332" /><path d="M 612 572 A 105 105 0 1 1 595 475" /><path d="M 582 468 Q 505 315 585 255 Q 648 215 682 275" /></svg>',
441
+ wechat: '<svg viewBox="0 0 1024 1024" width="100%" height="100%"><g fill="currentColor"><ellipse cx="435" cy="455" rx="215" ry="178"/><polygon points="295,575 248,660 360,605"/></g><circle cx="365" cy="420" r="26" fill="var(--jb-eye-color, #18c84b)"/><circle cx="498" cy="420" r="26" fill="var(--jb-eye-color, #18c84b)"/><g fill="currentColor"><ellipse cx="625" cy="590" rx="178" ry="148"/><polygon points="735,685 782,755 680,712"/></g><circle cx="568" cy="560" r="22" fill="var(--jb-eye-color, #18c84b)"/><circle cx="682" cy="560" r="22" fill="var(--jb-eye-color, #18c84b)"/></svg>',
442
+ ins: '<svg viewBox="0 0 1024 1024" width="100%" height="100%" fill="none" stroke="currentColor" stroke-width="58" stroke-linecap="round" stroke-linejoin="round"><path d="M355 355l55-65h204l55 65h61c33 0 60 27 60 60v270c0 33-27 60-60 60H294c-33 0-60-27-60-60V415c0-33 27-60 60-60h61z"/><circle cx="512" cy="548" r="122"/><circle cx="695" cy="438" r="28" fill="currentColor" stroke="none"/></svg>',
443
+ fb: '<svg viewBox="0 0 1024 1024" width="100%" height="100%" fill="currentColor"><path d="M455 835V545h-83V435h83v-85c0-88 52-135 137-135h90v107h-67c-31 0-47 16-47 50v63h108l-16 110h-92v290H455z"/></svg>',
444
+ play: '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"><polygon points="6,4 20,12 6,20"/></svg>',
445
+ heart: '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>',
446
+ bolt: '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"><polygon points="13,2 3,14 12,14 11,22 21,10 12,10"/></svg>',
447
+ sparkles: '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"><path d="M12 2L14.4 8.6L21 11L14.4 13.4L12 20L9.6 13.4L3 11L9.6 8.6L12 2Z"/><path d="M19 15L20 18L23 19L20 20L19 23L18 20L15 19L18 18L19 15Z"/></svg>',
448
+ bell: '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/></svg>'
449
+ };
450
+ function ke(n) {
451
+ return ze[n] ?? "";
452
+ }
453
+ function mt(n) {
454
+ const o = new r.Scene();
455
+ o.background = Z("#e2e6ed");
456
+ const d = new r.PlaneGeometry(1, 1), e = (s, a, c, u, t, i) => {
457
+ const y = new r.MeshBasicMaterial({
458
+ color: Z(t).multiplyScalar(i),
459
+ side: r.DoubleSide
460
+ }), w = new r.Mesh(d, y);
461
+ w.scale.set(s, a, 1), w.position.set(...c), w.rotation.set(...u), o.add(w);
462
+ };
463
+ e(26, 8, [0, 13, 4], [Math.PI / 2.3, 0, 0], "#ffffff", 5.4), e(6, 24, [-14, 1, 5], [0, Math.PI / 2.4, 0], "#ffffff", 4.6), e(6, 24, [14, 1, 5], [0, -Math.PI / 2.4, 0], "#ffffff", 4.6), e(26, 12, [0, -13, 3], [-Math.PI / 2.2, 0, 0], "#ffffff", 2.8), e(10, 26, [-13, 0, -8], [0, Math.PI / 4, 0], "#1e2430", 1), e(10, 26, [13, 0, -8], [0, -Math.PI / 4, 0], "#1e2430", 1);
464
+ const p = new r.PMREMGenerator(n);
465
+ p.compileCubemapShader();
466
+ const b = p.fromScene(o, 0.035).texture;
467
+ return p.dispose(), b;
468
+ }
469
+ const Be = 2;
470
+ class vt {
471
+ unitPlaneGeo;
472
+ envMap;
473
+ renderer;
474
+ glCanvas;
475
+ instances = /* @__PURE__ */ new Set();
476
+ running = !1;
477
+ raf = 0;
478
+ lastFrameTime = 0;
479
+ frameWidth = 0;
480
+ frameHeight = 0;
481
+ onResize = () => this.resize();
482
+ constructor() {
483
+ this.glCanvas = document.createElement("canvas"), this.glCanvas.id = "jelly-shared-gl-canvas", this.renderer = new r.WebGLRenderer({
484
+ canvas: this.glCanvas,
485
+ antialias: !0,
486
+ alpha: !0,
487
+ powerPreference: "high-performance"
488
+ }), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, Be)), this.renderer.setSize(window.innerWidth, window.innerHeight, !1), this.renderer.physicallyCorrectLights = !0, this.renderer.outputEncoding = r.sRGBEncoding, this.renderer.toneMapping = r.ACESFilmicToneMapping, this.renderer.toneMappingExposure = 1.08, this.renderer.setScissorTest(!0), this.renderer.setClearColor(0, 0), this.envMap = mt(this.renderer), this.unitPlaneGeo = new r.PlaneGeometry(1, 1), this.frameWidth = window.innerWidth, this.frameHeight = window.innerHeight, window.addEventListener("resize", this.onResize);
489
+ }
490
+ register(o) {
491
+ this.instances.add(o), this.running || this.start();
492
+ }
493
+ unregister(o) {
494
+ this.instances.delete(o), this.instances.size === 0 && this.stop();
495
+ }
496
+ resize() {
497
+ this.frameWidth = window.innerWidth, this.frameHeight = window.innerHeight, this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, Be)), this.renderer.setSize(this.frameWidth, this.frameHeight, !1);
498
+ }
499
+ start() {
500
+ this.running || (this.running = !0, this.lastFrameTime = performance.now(), this.raf = requestAnimationFrame(this.frame));
501
+ }
502
+ stop() {
503
+ this.running = !1, this.raf && cancelAnimationFrame(this.raf), this.raf = 0;
504
+ }
505
+ frame = (o) => {
506
+ if (!this.running) return;
507
+ this.raf = requestAnimationFrame(this.frame);
508
+ const d = Math.min(0.05, Math.max(0, (o - this.lastFrameTime) / 1e3));
509
+ this.lastFrameTime = o;
510
+ const e = window.innerWidth, p = window.innerHeight;
511
+ (e !== this.frameWidth || p !== this.frameHeight) && this.resize();
512
+ const b = this.renderer.getPixelRatio();
513
+ this.renderer.setViewport(0, 0, e, p), this.renderer.setScissor(0, 0, e, p), this.renderer.clear();
514
+ for (const s of this.instances) {
515
+ if (!s.el.isConnected) continue;
516
+ const a = s.el.getBoundingClientRect();
517
+ if (a.width <= 0 || a.height <= 0 || a.bottom < -80 || a.top > p + 80 || a.right < -80 || a.left > e + 80) {
518
+ s.clearComposite();
519
+ continue;
520
+ }
521
+ s.stepPhysics(d);
522
+ const c = a.width * 0.22, u = a.height * 0.22, t = a.width + c * 2, i = a.height + u * 2, y = a.left - c, w = p - (a.bottom + u);
523
+ s.camera.aspect = t / i, s.camera.updateProjectionMatrix(), this.renderer.setViewport(y, w, t, i), this.renderer.setScissor(y, w, t, i), this.renderer.render(s.scene, s.camera), s.present(
524
+ this.glCanvas,
525
+ Math.floor(y * b),
526
+ Math.floor((a.top - u) * b),
527
+ Math.round(t * b),
528
+ Math.round(i * b)
529
+ );
530
+ }
531
+ };
532
+ }
533
+ let de;
534
+ function gt() {
535
+ if (de === void 0)
536
+ try {
537
+ de = new vt();
538
+ } catch (n) {
539
+ console.warn("[familiar-vue/jelly] WebGL is unavailable; falling back to CSS.", n), de = null;
540
+ }
541
+ return de;
542
+ }
543
+ class bt {
544
+ enabled = !0;
545
+ ctx = null;
546
+ initContext() {
547
+ if (!this.ctx) {
548
+ const o = window.AudioContext || window.webkitAudioContext;
549
+ o && (this.ctx = new o());
550
+ }
551
+ this.ctx && this.ctx.state === "suspended" && this.ctx.resume();
552
+ }
553
+ playDown() {
554
+ if (this.enabled)
555
+ try {
556
+ if (this.initContext(), !this.ctx) return;
557
+ const o = this.ctx.currentTime, d = this.ctx.createOscillator(), e = this.ctx.createGain();
558
+ d.type = "sine", d.frequency.setValueAtTime(220, o), d.frequency.exponentialRampToValueAtTime(115, o + 0.055), e.gain.setValueAtTime(0.14, o), e.gain.exponentialRampToValueAtTime(1e-3, o + 0.06), d.connect(e), e.connect(this.ctx.destination), d.start(o), d.stop(o + 0.065);
559
+ } catch {
560
+ }
561
+ }
562
+ playUp() {
563
+ if (this.enabled)
564
+ try {
565
+ if (this.initContext(), !this.ctx) return;
566
+ const o = this.ctx.currentTime, d = this.ctx.createOscillator(), e = this.ctx.createGain();
567
+ d.type = "sine", d.frequency.setValueAtTime(240, o), d.frequency.exponentialRampToValueAtTime(520, o + 0.085), e.gain.setValueAtTime(0.15, o), e.gain.exponentialRampToValueAtTime(1e-3, o + 0.095), d.connect(e), e.connect(this.ctx.destination), d.start(o), d.stop(o + 0.1);
568
+ } catch {
569
+ }
570
+ }
571
+ }
572
+ const fe = new bt(), pe = /* @__PURE__ */ new Map();
573
+ function Re(n, o, d, e, p, b) {
574
+ const s = r.MathUtils.clamp(b, 0.04, 1) * Math.min(e, p), a = o - e, c = d - p, u = e * 2, t = p * 2;
575
+ n.beginPath(), n.moveTo(a + s, c), n.lineTo(a + u - s, c), n.arcTo(a + u, c, a + u, c + s, s), n.lineTo(a + u, c + t - s), n.arcTo(a + u, c + t, a + u - s, c + t, s), n.lineTo(a + s, c + t), n.arcTo(a, c + t, a, c + t - s, s), n.lineTo(a, c + s), n.arcTo(a, c, a + s, c, s), n.closePath();
576
+ }
577
+ function Pe(n, o) {
578
+ return {
579
+ cw: Math.min(1024, Math.round(384 * n)),
580
+ ch: Math.min(1024, Math.round(384 * o))
581
+ };
582
+ }
583
+ function yt(n, o, d, e, p, b) {
584
+ const s = Math.round(n * 20) / 20, a = Math.round(o * 20) / 20, c = Math.round(d * 25) / 25, u = `back_v4_${s}_${a}_${c}_${e}_${p || ""}_${b}`, t = pe.get(u);
585
+ if (t) return t;
586
+ const { cw: i, ch: y } = Pe(s, a), w = i / 2, $ = y / 2, Y = Math.min(i, y), l = Y * 0.045, F = w - l, m = $ - l, C = document.createElement("canvas");
587
+ C.width = i, C.height = y;
588
+ const x = C.getContext("2d");
589
+ if (!x) throw new Error("Jelly backing texture: 2D context unavailable");
590
+ if (x.save(), Re(x, w, $, F, m, c), x.clip(), b) {
591
+ const f = x.createLinearGradient(0, 0, 0, y);
592
+ f.addColorStop(0, "#ffffff"), f.addColorStop(0.65, "#f1f5f9"), f.addColorStop(1, "#cbd5e1"), x.fillStyle = f, x.fillRect(0, 0, i, y);
593
+ } else if (p) {
594
+ const f = p.split(",").map((M) => M.trim()), _ = x.createLinearGradient(i * 0.08, y * 0.92, i * 0.92, y * 0.08);
595
+ f.forEach((M, A) => {
596
+ _.addColorStop(A / Math.max(1, f.length - 1), M);
597
+ }), x.fillStyle = _, x.fillRect(0, 0, i, y);
598
+ } else {
599
+ const f = Z(e), _ = f.clone().offsetHSL(0, 0.04, 0.09), M = f.clone().offsetHSL(0, 0.06, -0.05), A = x.createRadialGradient(
600
+ w,
601
+ $ * 0.88,
602
+ Y * 0.08,
603
+ w,
604
+ $,
605
+ Math.max(i, y) * 0.56
606
+ );
607
+ A.addColorStop(0, le(_)), A.addColorStop(0.75, le(f)), A.addColorStop(1, le(M)), x.fillStyle = A, x.fillRect(0, 0, i, y);
608
+ }
609
+ x.restore();
610
+ const L = new r.CanvasTexture(C);
611
+ return L.encoding = r.sRGBEncoding, L.needsUpdate = !0, pe.set(u, L), L;
612
+ }
613
+ function xt(n, o, d, e) {
614
+ const p = Math.round(n * 20) / 20, b = Math.round(o * 20) / 20, s = Math.round(d * 25) / 25, a = `rim_v4_${p}_${b}_${s}_${e}`, c = pe.get(a);
615
+ if (c) return c;
616
+ const { cw: u, ch: t } = Pe(p, b), i = u / 2, y = t / 2, w = Math.min(u, t), $ = w * 0.055, Y = i - $, l = y - $, F = document.createElement("canvas");
617
+ F.width = u, F.height = t;
618
+ const m = F.getContext("2d");
619
+ if (!m) throw new Error("Jelly rim texture: 2D context unavailable");
620
+ m.save(), Re(m, i, y, Y, l, s);
621
+ const C = m.createLinearGradient(0, 0, u * 0.4, t);
622
+ C.addColorStop(0, "rgba(255, 255, 255, 0.94)"), C.addColorStop(0.45, e), C.addColorStop(1, "rgba(255, 255, 255, 0.55)"), m.strokeStyle = C, m.lineWidth = Math.max(3, w * 0.032), m.shadowColor = "rgba(255, 255, 255, 0.85)", m.shadowBlur = w * 0.035, m.stroke(), m.restore(), m.save();
623
+ const x = w * 0.055, L = Math.max(0.04, s - 0.04);
624
+ Re(m, i, y, Y - x, l - x, L);
625
+ const f = m.createLinearGradient(0, 0, 0, t);
626
+ f.addColorStop(0, "rgba(255, 255, 255, 0.82)"), f.addColorStop(0.32, "rgba(255, 255, 255, 0.14)"), f.addColorStop(0.75, "rgba(255, 255, 255, 0.0)"), f.addColorStop(1, "rgba(255, 255, 255, 0.36)"), m.strokeStyle = f, m.lineWidth = Math.max(1.5, w * 0.016), m.stroke(), m.restore();
627
+ const _ = new r.CanvasTexture(F);
628
+ return _.encoding = r.sRGBEncoding, _.needsUpdate = !0, pe.set(a, _), _;
629
+ }
630
+ const wt = ["disabled", "aria-label"], Mt = ["innerHTML"], Rt = {
631
+ key: 1,
632
+ class: "jelly-label"
633
+ }, Te = /* @__PURE__ */ et({
634
+ name: "JellySurface",
635
+ __name: "JellySurface",
636
+ props: {
637
+ width: { default: 108 },
638
+ height: { default: 108 },
639
+ radius: { default: 0.45 },
640
+ color: { default: "#ff6700" },
641
+ gradient: { default: "" },
642
+ crystal: { type: Boolean, default: !1 },
643
+ textColor: { default: "" },
644
+ icon: { default: "none" },
645
+ label: { default: "" },
646
+ ior: { default: 1.52 },
647
+ thickness: { default: 1.45 },
648
+ roughness: { default: 0.03 },
649
+ finish: { default: "clear" },
650
+ interactive: { type: Boolean, default: !0 },
651
+ disabled: { type: Boolean, default: !1 },
652
+ sound: { type: Boolean, default: !0 },
653
+ ariaLabel: { default: "" }
654
+ },
655
+ emits: ["press", "release"],
656
+ setup(n, { expose: o, emit: d }) {
657
+ const e = n, p = d, b = se(null), s = se(null), a = se(null), c = se(null), u = se(!1), t = se({}), i = ce(() => e.interactive && !e.disabled), y = ce(() => e.icon !== "none" && ke(e.icon) !== ""), w = ce(() => y.value ? ke(e.icon) : ""), $ = ce(() => e.ariaLabel || e.label || "Jelly surface"), Y = ce(() => ({
658
+ width: typeof e.width == "number" ? `${e.width}px` : e.width,
659
+ height: typeof e.height == "number" ? `${e.height}px` : e.height
660
+ })), l = {
661
+ press: 0,
662
+ pressVel: 0,
663
+ targetPress: 0,
664
+ rotX: 0,
665
+ rotY: 0,
666
+ targetRotX: 0,
667
+ targetRotY: 0
668
+ };
669
+ let F = !1, m = !1, C = !1, x = null, L = null, f = null, _ = null, M = null, A = null, re = null, oe = null, j = null, T = null, K = null, q = null, O = null, ne = null, X = 0, S = 0, z = null, P = null, N = null, k = 0;
670
+ function I(h, g) {
671
+ const E = typeof h == "number" ? h : Number.parseFloat(h);
672
+ return Number.isFinite(E) ? E : g;
673
+ }
674
+ const Q = [
675
+ [0.38, 0.08, 0.91],
676
+ [0.88, 0.19, 0.42],
677
+ [0.99, 0.49, 0.08],
678
+ [1, 0.78, 0]
679
+ ];
680
+ function ee(h, g, E, G, H, R) {
681
+ if (!q || !O) return;
682
+ const D = e.finish === "frosted";
683
+ if (O.visible = D, M && (M.visible = !D), !D) return;
684
+ const v = q.uniforms;
685
+ v.u_halfSize.value.set(h, g), v.u_radius.value = E, v.u_ior.value = Number.isFinite(e.ior) ? e.ior : 1.52, v.u_thickness.value = Number.isFinite(e.thickness) ? e.thickness : 1.45, v.u_isCrystal.value = R ? 1 : 0;
686
+ const U = De(G);
687
+ v.u_baseColor.value.set(U[0], U[1], U[2]);
688
+ const V = H ? H.split(",").map((W) => W.trim()).filter(Boolean) : [];
689
+ v.u_hasGradient.value = V.length > 0 ? 1 : 0;
690
+ const B = [v.u_grad0, v.u_grad1, v.u_grad2, v.u_grad3];
691
+ for (let W = 0; W < B.length; W++) {
692
+ const J = V.length ? De(V[Math.min(V.length - 1, W)]) : Q[W];
693
+ B[W].value.set(J[0], J[1], J[2]);
694
+ }
695
+ }
696
+ function me() {
697
+ const h = b.value;
698
+ if (!h) return;
699
+ const g = h.clientWidth, E = h.clientHeight, G = Math.max(32, g || I(e.width, 108)), H = Math.max(32, E || I(e.height, 108)), R = r.MathUtils.clamp(e.radius, 0.06, 1), D = Math.min(G, H), v = e.crystal, U = e.gradient.trim(), V = e.color || "#ff6700", B = Z(V), W = B.clone().offsetHSL(0, 0.08, -0.12), J = B.clone().offsetHSL(0, 0.1, 0.24), ge = e.textColor.trim(), qe = ge && ge !== "auto" ? ge : v ? "#0f172a" : "#ffffff", he = G >= H * 1.35, Oe = !!e.label;
700
+ let Ce = Math.round(D * 0.54);
701
+ y.value && Oe && (Ce = Math.round(D * (he ? 0.38 : 0.42)));
702
+ const Xe = Math.max(11, Math.min(18, Math.round(D * (he ? 0.22 : 0.14)))), Je = v ? "rgba(148, 163, 184, 0.35)" : `rgba(${Math.round(B.r * 255)}, ${Math.round(B.g * 255)}, ${Math.round(B.b * 255)}, 0.54)`, Ye = v ? "linear-gradient(180deg, #ffffff, #f1f5f9 65%, #cbd5e1)" : U ? `linear-gradient(to top right, ${U})` : `radial-gradient(circle at 50% 40%, ${le(B.clone().offsetHSL(0, 0.04, 0.09))}, ${le(B)} 75%, ${le(B.clone().offsetHSL(0, 0.06, -0.05))})`;
703
+ if (t.value = {
704
+ "--jb-css-radius": `${Math.round(R * (D / 2))}px`,
705
+ "--jb-layout-dir": he ? "row" : "column",
706
+ "--jb-gap": he ? "8px" : "3px",
707
+ "--jb-icon-box": `${Ce}px`,
708
+ "--jb-font-size": `${Xe}px`,
709
+ "--jb-fg-color": qe,
710
+ "--jb-fg-shadow": v ? "rgba(15, 23, 42, 0.12)" : "rgba(0, 0, 0, 0.25)",
711
+ "--jb-eye-color": v ? "#ffffff" : V,
712
+ "--jb-caustic": Je,
713
+ "--jb-fallback-bg": Ye
714
+ }, !f || !_ || !re || !A || !oe || !T || !j || !K) return;
715
+ const ie = G / D, ae = H / D, Ke = r.MathUtils.degToRad(_.fov), Ze = ae * 1.06 * 1.44;
716
+ _.position.z = Ze / Math.tan(Ke * 0.5), re.geometry = Me(ie, ae, R), A.scale.set(ie * 2.22, ae * 2.22, 1), oe.scale.set(ie * 2.15, ae * 2.15, 1), j.map = yt(
717
+ ie,
718
+ ae,
719
+ R,
720
+ V,
721
+ U,
722
+ v
723
+ ), j.needsUpdate = !0, T.color.copy(
724
+ v ? Z("#f8fbff") : U ? Z("#ffffff") : B
725
+ ), T.attenuationColor.copy(v ? Z("#cbd5e1") : W), T.attenuationDistance = v ? 2.6 : U ? 1.75 : 1.15, T.ior = Number.isFinite(e.ior) ? e.ior : 1.52, T.thickness = Number.isFinite(e.thickness) ? e.thickness : 1.45, T.roughness = Number.isFinite(e.roughness) ? e.roughness : 0.03, T.needsUpdate = !0;
726
+ const Qe = v ? "rgba(255, 255, 255, 0.90)" : `rgba(${Math.round(J.r * 255)}, ${Math.round(J.g * 255)}, ${Math.round(J.b * 255)}, 0.84)`;
727
+ K.map = xt(ie, ae, R, Qe), K.needsUpdate = !0, ee(ie, ae, R, V, U, v);
728
+ }
729
+ function Ge() {
730
+ k || (k = requestAnimationFrame(() => {
731
+ k = 0, me();
732
+ }));
733
+ }
734
+ function Ee() {
735
+ if (L = gt(), !L) {
736
+ u.value = !0;
737
+ return;
738
+ }
739
+ f = new r.Scene(), f.environment = L.envMap, _ = new r.PerspectiveCamera(22, 1, 0.1, 60), _.position.set(0, 0, 8.8), f.add(new r.AmbientLight("#ffffff", 1.38));
740
+ const h = new r.DirectionalLight("#ffffff", 2.4);
741
+ h.position.set(2.5, 5, 6), f.add(h), ne = new r.PointLight("#ffffff", 1.85, 10), ne.position.set(0, 1.2, 2.6), f.add(ne), M = new r.Group(), f.add(M), j = new r.MeshBasicMaterial({ transparent: !1, alphaTest: 0.08 }), A = new r.Mesh(L.unitPlaneGeo, j), A.position.z = -0.35, M.add(A), T = new r.MeshPhysicalMaterial({
742
+ color: Z("#ff6700"),
743
+ transmission: 0.94,
744
+ opacity: 1,
745
+ transparent: !0,
746
+ ior: 1.52,
747
+ attenuationColor: Z("#ff4500"),
748
+ attenuationDistance: 1.15,
749
+ roughness: 0.03,
750
+ metalness: 0,
751
+ clearcoat: 1,
752
+ clearcoatRoughness: 0.02,
753
+ specularIntensity: 1,
754
+ specularColor: Z("#ffffff"),
755
+ envMapIntensity: 1.85
756
+ }), T.thickness = 1.45, re = new r.Mesh(Me(1, 1, 0.45), T), M.add(re), K = new r.MeshBasicMaterial({ transparent: !0, opacity: 0.9, depthWrite: !1 }), oe = new r.Mesh(L.unitPlaneGeo, K), oe.position.z = 0.34, M.add(oe), q = pt(), O = new r.Mesh(L.unitPlaneGeo, q), O.frustumCulled = !1, O.visible = !1, f.add(O);
757
+ }
758
+ function He(h) {
759
+ if (!M) return;
760
+ (!i.value || C) && (l.targetPress = 0, l.press = 0, l.pressVel = 0, l.targetRotX = 0, l.targetRotY = 0);
761
+ const g = -340 * (l.press - l.targetPress), E = -17 * l.pressVel;
762
+ l.pressVel += (g + E) * h, l.press += l.pressVel * h;
763
+ const G = F && i.value && !C ? 1.04 : 1;
764
+ l.rotX = r.MathUtils.lerp(l.rotX, l.targetRotX, 0.16), l.rotY = r.MathUtils.lerp(l.rotY, l.targetRotY, 0.16);
765
+ const H = l.press;
766
+ if (e.finish === "frosted") {
767
+ if (M.rotation.set(0, 0, 0), M.scale.set(1, 1, 1), M.position.z = 0, q) {
768
+ const R = q.uniforms, D = i.value && !C;
769
+ R.u_tilt.value.set(l.rotY, l.rotX), R.u_scale.value = G * (1 - H * 0.045), R.u_press.value = H, R.u_pointer.value.set(D ? X : 0, D ? S : 0);
770
+ }
771
+ } else {
772
+ M.rotation.x = l.rotX, M.rotation.y = l.rotY;
773
+ const R = G * (1 + H * 0.068), D = G * Math.max(0.48, 1 - H * 0.34);
774
+ M.scale.set(R, R, D), M.position.z = -H * 0.3;
775
+ }
776
+ if (a.value) {
777
+ const R = l.rotY * 14, D = l.rotX * 14, v = G * (1 - H * 0.045);
778
+ a.value.style.transform = `translate3d(${R.toFixed(2)}px, ${D.toFixed(2)}px, 0px) scale(${v.toFixed(3)})`;
779
+ }
780
+ }
781
+ function Ae(h, g, E, G, H) {
782
+ const R = c.value;
783
+ if (!R) return;
784
+ const D = Math.max(1, Math.round(G)), v = Math.max(1, Math.round(H));
785
+ R.width !== D && (R.width = D), R.height !== v && (R.height = v);
786
+ const U = z ?? (z = R.getContext("2d"));
787
+ if (!U) return;
788
+ U.setTransform(1, 0, 0, 1, 0, 0), U.clearRect(0, 0, D, v);
789
+ const V = Math.max(0, Math.floor(g)), B = Math.max(0, Math.floor(E)), W = Math.min(h.width, Math.ceil(g + G)), J = Math.min(h.height, Math.ceil(E + H));
790
+ W <= V || J <= B || U.drawImage(h, V, B, W - V, J - B, V - g, B - E, W - V, J - B);
791
+ }
792
+ function Ne() {
793
+ const h = c.value;
794
+ if (!h) return;
795
+ const g = z ?? (z = h.getContext("2d"));
796
+ g && (g.setTransform(1, 0, 0, 1, 0, 0), g.clearRect(0, 0, h.width, h.height));
797
+ }
798
+ function Ue() {
799
+ l.press = 0.85, l.targetPress = 0, l.pressVel = -18, e.sound && fe.playUp();
800
+ }
801
+ function Ve() {
802
+ i.value && (F = !0);
803
+ }
804
+ function Fe(h) {
805
+ if (!i.value || C) return;
806
+ const g = b.value?.getBoundingClientRect();
807
+ if (!g || g.width <= 0 || g.height <= 0) return;
808
+ const E = (h.clientX - g.left) / g.width * 2 - 1, G = (h.clientY - g.top) / g.height * 2 - 1;
809
+ l.targetRotY = E * 0.24, l.targetRotX = G * 0.24, X = E, S = G, ne?.position.set(E * 2.6, -G * 2.4, 2.8);
810
+ }
811
+ function ve() {
812
+ window.removeEventListener("pointerup", te), window.removeEventListener("pointercancel", te), m && (m = !1, l.targetPress = 0, l.pressVel = -16.5, e.sound && fe.playUp(), p("release"));
813
+ }
814
+ function Ie(h) {
815
+ !i.value || h.button !== 0 || (m = !0, l.targetPress = 1, window.addEventListener("pointerup", te), window.addEventListener("pointercancel", te), e.sound && fe.playDown(), p("press"));
816
+ }
817
+ function te() {
818
+ ve();
819
+ }
820
+ function We() {
821
+ F = !1, m && ve(), l.targetRotX = 0, l.targetRotY = 0, l.targetPress = 0, X = 0, S = 0;
822
+ }
823
+ function $e(h) {
824
+ h.repeat || !i.value || h.key !== " " && h.key !== "Enter" || (m = !0, l.targetPress = 1, e.sound && fe.playDown(), p("press"));
825
+ }
826
+ function je(h) {
827
+ h.key !== " " && h.key !== "Enter" || ve();
828
+ }
829
+ function _e(h) {
830
+ C = h.matches;
831
+ }
832
+ return tt(
833
+ () => [
834
+ e.width,
835
+ e.height,
836
+ e.radius,
837
+ e.color,
838
+ e.gradient,
839
+ e.crystal,
840
+ e.textColor,
841
+ e.icon,
842
+ e.label,
843
+ e.ior,
844
+ e.thickness,
845
+ e.roughness,
846
+ e.finish
847
+ ],
848
+ me,
849
+ { flush: "post" }
850
+ ), o({ pulse: Ue }), ot(() => {
851
+ x = window.matchMedia("(prefers-reduced-motion: reduce)"), C = x.matches, x.addEventListener?.("change", _e), Ee(), me();
852
+ const h = b.value;
853
+ h && typeof ResizeObserver == "function" && (N = new ResizeObserver(Ge), N.observe(h)), L && f && _ && (P = {
854
+ el: h,
855
+ scene: f,
856
+ camera: _,
857
+ stepPhysics: He,
858
+ present: Ae,
859
+ clearComposite: Ne
860
+ }, L.register(P));
861
+ }), nt(() => {
862
+ L && P && L.unregister(P), P = null, N?.disconnect(), N = null, x?.removeEventListener?.("change", _e), window.removeEventListener("pointerup", te), window.removeEventListener("pointercancel", te), k && cancelAnimationFrame(k), k = 0, T?.dispose(), j?.dispose(), K?.dispose(), q?.dispose(), f?.clear(), f = null, _ = null, M = null, A = null, re = null, oe = null, j = null, T = null, K = null, q = null, O = null, ne = null, X = 0, S = 0, z = null;
863
+ }), (h, g) => (be(), ye("div", {
864
+ ref_key: "rootEl",
865
+ ref: b,
866
+ class: at(["jelly-surface", { "is-disabled": n.disabled, "is-fallback": u.value }]),
867
+ style: rt([Y.value, t.value])
868
+ }, [
869
+ g[0] || (g[0] = ue("span", {
870
+ class: "jelly-contact-shadow",
871
+ "aria-hidden": "true"
872
+ }, null, -1)),
873
+ g[1] || (g[1] = ue("span", {
874
+ class: "jelly-caustic",
875
+ "aria-hidden": "true"
876
+ }, null, -1)),
877
+ it(ue("canvas", {
878
+ ref_key: "mirrorEl",
879
+ ref: c,
880
+ class: "jelly-composite",
881
+ "aria-hidden": "true"
882
+ }, null, 512), [
883
+ [st, !u.value]
884
+ ]),
885
+ ue("button", {
886
+ ref_key: "buttonEl",
887
+ ref: s,
888
+ class: "jelly-native",
889
+ type: "button",
890
+ disabled: n.disabled,
891
+ "aria-label": $.value,
892
+ onPointerenter: Ve,
893
+ onPointermove: Fe,
894
+ onPointerleave: We,
895
+ onPointerdown: Ie,
896
+ onPointerup: te,
897
+ onPointercancel: te,
898
+ onKeydown: $e,
899
+ onKeyup: je,
900
+ onBlur: te
901
+ }, [
902
+ ue("span", {
903
+ ref_key: "overlayEl",
904
+ ref: a,
905
+ class: "jelly-overlay"
906
+ }, [
907
+ y.value ? (be(), ye("span", {
908
+ key: 0,
909
+ class: "jelly-icon",
910
+ "aria-hidden": "true",
911
+ innerHTML: w.value
912
+ }, null, 8, Mt)) : Se("", !0),
913
+ n.label ? (be(), ye("span", Rt, lt(n.label), 1)) : Se("", !0),
914
+ ct(h.$slots, "default")
915
+ ], 512)
916
+ ], 40, wt)
917
+ ], 6));
918
+ }
919
+ }), Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
920
+ __proto__: null,
921
+ JellySurface: Te,
922
+ PRESET_ICON_SVGS: ze,
923
+ buildStructuredPerimeterSamples: we,
924
+ default: Te,
925
+ getParametricJellyGeometry: Me
926
+ }, Symbol.toStringTag, { value: "Module" }));
927
+ export {
928
+ ze as P,
929
+ Te as _,
930
+ we as b,
931
+ Me as g,
932
+ Ct as i
933
+ };
934
+ //# sourceMappingURL=index-CjA5aaxl.js.map