@zakisheriff/liquid-glass 0.1.2 → 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.
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -34,85 +35,781 @@ __export(index_exports, {
34
35
  GlassCard: () => GlassCard,
35
36
  GlassInput: () => GlassInput,
36
37
  GlassNav: () => GlassNav,
38
+ GlassSegmented: () => GlassSegmented,
37
39
  GlassSheet: () => GlassSheet,
38
40
  GlassSlider: () => GlassSlider,
41
+ GlassSwitch: () => GlassSwitch,
39
42
  LiquidGlassFilter: () => LiquidGlassFilter,
43
+ SPRINGS: () => SPRINGS,
44
+ canRefractBackdrop: () => canRefractBackdrop,
45
+ createSpring: () => createSpring,
46
+ haptic: () => haptic,
47
+ springFrom: () => springFrom,
40
48
  useGlassAnimation: () => useGlassAnimation,
41
- useGlassEffect: () => useGlassEffect
49
+ useGlassEffect: () => useGlassEffect,
50
+ usePress: () => usePress,
51
+ useRefraction: () => useRefraction
42
52
  });
43
53
  module.exports = __toCommonJS(index_exports);
44
54
 
45
55
  // src/components/GlassButton/GlassButton.tsx
46
- var import_react2 = __toESM(require("react"));
56
+ var import_react3 = __toESM(require("react"));
47
57
 
48
- // src/filters/LiquidGlassFilter.tsx
58
+ // src/engine/press.ts
49
59
  var import_react = require("react");
50
- var import_jsx_runtime = require("react/jsx-runtime");
51
- var GlassFilterContext = (0, import_react.createContext)(false);
52
- function useGlassFilterMounted() {
53
- return (0, import_react.useContext)(GlassFilterContext);
60
+
61
+ // src/engine/spring.ts
62
+ var active = /* @__PURE__ */ new Set();
63
+ var frame = 0;
64
+ var last = 0;
65
+ function step(s, dt) {
66
+ const x = s.value - s.target;
67
+ const v = s.velocity;
68
+ const half = s.c / 2;
69
+ const disc = half * half - s.k;
70
+ if (Math.abs(disc) < 1e-6) {
71
+ const decay = Math.exp(-half * dt);
72
+ const b = v + half * x;
73
+ s.value = s.target + decay * (x + b * dt);
74
+ s.velocity = decay * (v - half * b * dt);
75
+ } else if (disc > 0) {
76
+ const root = Math.sqrt(disc);
77
+ const r1 = -half + root;
78
+ const r2 = -half - root;
79
+ const a = (v - r2 * x) / (r1 - r2);
80
+ const b = x - a;
81
+ const e1 = Math.exp(r1 * dt);
82
+ const e2 = Math.exp(r2 * dt);
83
+ s.value = s.target + a * e1 + b * e2;
84
+ s.velocity = a * r1 * e1 + b * r2 * e2;
85
+ } else {
86
+ const w = Math.sqrt(-disc);
87
+ const decay = Math.exp(-half * dt);
88
+ const cos = Math.cos(w * dt);
89
+ const sin = Math.sin(w * dt);
90
+ s.value = s.target + decay * (x * cos + (v + half * x) / w * sin);
91
+ s.velocity = decay * (v * cos - (half * v + s.k * x) / w * sin);
92
+ }
54
93
  }
55
- function LiquidGlassFilter({ children }) {
56
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(GlassFilterContext.Provider, { value: true, children: [
57
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlassFilterSVG, {}),
58
- children
59
- ] });
94
+ function loop(time) {
95
+ frame = 0;
96
+ const dt = Math.min(0.064, Math.max(0, (time - last) / 1e3));
97
+ last = time;
98
+ for (const s of active) {
99
+ step(s, dt);
100
+ if (Math.abs(s.value - s.target) < 1e-4 && Math.abs(s.velocity) < 1e-3) {
101
+ s.value = s.target;
102
+ s.velocity = 0;
103
+ active.delete(s);
104
+ }
105
+ s.onUpdate(s.value, s.velocity);
106
+ }
107
+ if (active.size) frame = requestAnimationFrame(loop);
60
108
  }
61
- function GlassFilterSVG() {
62
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
- "svg",
64
- {
65
- width: "0",
66
- height: "0",
67
- style: { position: "absolute", pointerEvents: "none" },
68
- "aria-hidden": "true",
69
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
70
- const level = i + 1;
71
- const scale = level * 2;
72
- const freq1 = 0.012 + level * 1e-3;
73
- const freq2 = 0.01 + level * 8e-4;
74
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
75
- "filter",
76
- {
77
- id: `liquid-glass-refract-${level}`,
78
- x: "-10%",
79
- y: "-10%",
80
- width: "120%",
81
- height: "120%",
82
- colorInterpolationFilters: "sRGB",
83
- children: [
84
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
- "feTurbulence",
86
- {
87
- type: "fractalNoise",
88
- baseFrequency: `${freq1} ${freq2}`,
89
- numOctaves: 3,
90
- seed: 42,
91
- result: "noise"
92
- }
93
- ),
94
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
- "feDisplacementMap",
96
- {
97
- in: "SourceGraphic",
98
- in2: "noise",
99
- scale,
100
- xChannelSelector: "R",
101
- yChannelSelector: "G"
102
- }
103
- )
104
- ]
105
- },
106
- level
107
- );
108
- }) })
109
+ function wake() {
110
+ if (frame) return;
111
+ last = performance.now();
112
+ frame = requestAnimationFrame(loop);
113
+ }
114
+ function prefersReducedMotion() {
115
+ return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
116
+ }
117
+ function createSpring(initial, config, onUpdate) {
118
+ const s = {
119
+ value: initial,
120
+ target: initial,
121
+ velocity: 0,
122
+ k: config.stiffness,
123
+ c: config.damping,
124
+ onUpdate
125
+ };
126
+ return {
127
+ get value() {
128
+ return s.value;
129
+ },
130
+ get velocity() {
131
+ return s.velocity;
132
+ },
133
+ get target() {
134
+ return s.target;
135
+ },
136
+ set(target, instant = false) {
137
+ s.target = target;
138
+ if (instant || prefersReducedMotion() || typeof document !== "undefined" && document.hidden) {
139
+ s.value = target;
140
+ s.velocity = 0;
141
+ active.delete(s);
142
+ onUpdate(s.value, 0);
143
+ return;
144
+ }
145
+ active.add(s);
146
+ wake();
147
+ },
148
+ tune(next) {
149
+ s.k = next.stiffness;
150
+ s.c = next.damping;
151
+ },
152
+ impulse(velocity) {
153
+ s.velocity += velocity;
154
+ active.add(s);
155
+ wake();
156
+ },
157
+ stop() {
158
+ active.delete(s);
159
+ }
160
+ };
161
+ }
162
+ function springFrom(response, dampingFraction) {
163
+ const w = 2 * Math.PI / response;
164
+ return { stiffness: w * w, damping: 2 * dampingFraction * w };
165
+ }
166
+ var SPRINGS = {
167
+ /** Finger down: quick, almost no overshoot. */
168
+ press: springFrom(0.22, 0.86),
169
+ /** Finger up: soft settle with the gentle jelly wobble. */
170
+ release: springFrom(0.42, 0.5),
171
+ /** Following the finger during a drag. */
172
+ drag: springFrom(0.12, 0.92),
173
+ /** Sliding into a new slot after release. */
174
+ snap: springFrom(0.36, 0.72),
175
+ /** Lens inflating out of a selection pill. */
176
+ lift: springFrom(0.26, 0.78),
177
+ /** Lens deflating back into a pill: visibly wobbly. */
178
+ settle: springFrom(0.45, 0.46),
179
+ /** Colour cross-fades. */
180
+ fade: springFrom(0.3, 1)
181
+ };
182
+ function rubberband(offset, dimension, constant = 0.55) {
183
+ const sign = Math.sign(offset);
184
+ const x = Math.abs(offset);
185
+ return sign * (1 - 1 / (x * constant / dimension + 1)) * dimension;
186
+ }
187
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
188
+
189
+ // src/engine/press.ts
190
+ var FOLLOW = springFrom(0.2, 0.82);
191
+ function usePress(ref, options = {}) {
192
+ const { grow, lean = 10, stretch = 0.2, disabled = false } = options;
193
+ (0, import_react.useEffect)(() => {
194
+ const el2 = ref.current;
195
+ if (!el2 || disabled) return;
196
+ const v = { sx: 1, sy: 1, tx: 0, ty: 0 };
197
+ const paint = () => {
198
+ el2.style.scale = `${v.sx} ${v.sy}`;
199
+ el2.style.translate = `${v.tx}px ${v.ty}px`;
200
+ };
201
+ const springs = ["sx", "sy", "tx", "ty"].map(
202
+ (key) => createSpring(key[0] === "s" ? 1 : 0, SPRINGS.release, (value) => {
203
+ v[key] = value;
204
+ paint();
205
+ })
206
+ );
207
+ const to = (targets, feel) => springs.forEach((s, i) => {
208
+ s.tune(feel);
209
+ s.set(targets[i]);
210
+ });
211
+ let pointer = null;
212
+ const light = (event, box) => {
213
+ el2.style.setProperty("--lg-x", `${(event.clientX - box.left) / box.width * 100}%`);
214
+ el2.style.setProperty("--lg-y", `${(event.clientY - box.top) / box.height * 100}%`);
215
+ };
216
+ const track = (event) => {
217
+ if (!pointer) return;
218
+ const { box, base } = pointer;
219
+ light(event, box);
220
+ const dx = event.clientX - pointer.x;
221
+ const dy = event.clientY - pointer.y;
222
+ const tx = rubberband(dx, lean * 2.2, 0.5);
223
+ const ty = rubberband(dy, lean * 2.2, 0.5);
224
+ const dist = Math.hypot(dx, dy);
225
+ const pull = 1 - 1 / (1 + dist / 55);
226
+ const k = stretch * pull;
227
+ const cx = dist ? (dx / dist) ** 2 : 0;
228
+ const cy = dist ? (dy / dist) ** 2 : 0;
229
+ to([base * (1 + k * cx - k * 0.5 * cy), base * (1 + k * cy - k * 0.5 * cx), tx, ty], FOLLOW);
230
+ };
231
+ const move = (event) => {
232
+ if (event.pointerId === pointer?.id) track(event);
233
+ };
234
+ const up = (event) => {
235
+ if (event && event.pointerId !== pointer?.id) return;
236
+ pointer = null;
237
+ delete el2.dataset.pressed;
238
+ window.removeEventListener("pointermove", move);
239
+ window.removeEventListener("pointerup", up);
240
+ window.removeEventListener("pointercancel", up);
241
+ to([1, 1, 0, 0], SPRINGS.release);
242
+ };
243
+ const down = (event) => {
244
+ if (!event.isPrimary || event.button !== 0 || pointer) return;
245
+ if (el2.disabled || el2.getAttribute("aria-disabled") === "true") return;
246
+ const box = el2.getBoundingClientRect();
247
+ const w = el2.offsetWidth || 1;
248
+ const h = el2.offsetHeight || 1;
249
+ const natural = Math.min(0.22, Math.max(0.07, 9 / Math.sqrt(w * h)));
250
+ const amount = (grow ?? natural) * (event.pointerType === "mouse" ? 0.75 : 1);
251
+ const base = 1 + amount;
252
+ pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, box, base };
253
+ el2.dataset.pressed = "";
254
+ light(event, box);
255
+ to([base, base, 0, 0], SPRINGS.press);
256
+ window.addEventListener("pointermove", move);
257
+ window.addEventListener("pointerup", up);
258
+ window.addEventListener("pointercancel", up);
259
+ };
260
+ const blur = () => up();
261
+ el2.addEventListener("pointerdown", down);
262
+ window.addEventListener("blur", blur);
263
+ return () => {
264
+ up();
265
+ springs.forEach((s) => s.stop());
266
+ el2.removeEventListener("pointerdown", down);
267
+ window.removeEventListener("blur", blur);
268
+ el2.style.removeProperty("scale");
269
+ el2.style.removeProperty("translate");
270
+ };
271
+ }, [ref, grow, lean, stretch, disabled]);
272
+ }
273
+
274
+ // src/engine/refraction.ts
275
+ var import_react2 = require("react");
276
+
277
+ // src/engine/mirror.ts
278
+ var SELF = "data-lg-mirror-self";
279
+ function clone(source) {
280
+ const root = source.cloneNode(true);
281
+ const originals = [source, ...Array.from(source.querySelectorAll("*"))];
282
+ const copies = [root, ...Array.from(root.querySelectorAll("*"))];
283
+ const pairs = [];
284
+ originals.forEach((original, i) => {
285
+ const copy = copies[i];
286
+ if (!copy) return;
287
+ copy.removeAttribute("id");
288
+ copy.removeAttribute("tabindex");
289
+ if (copy instanceof HTMLImageElement) copy.loading = "eager";
290
+ pairs.push({ original, copy, css: original.style.cssText, cls: original.className.toString() });
291
+ });
292
+ root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
293
+ root.setAttribute("inert", "");
294
+ root.setAttribute("aria-hidden", "true");
295
+ return { root, pairs };
296
+ }
297
+ var alpha = (color) => {
298
+ const m = color.match(/rgba?\(([^)]+)\)/);
299
+ if (!m) return color === "transparent" ? 0 : 1;
300
+ const parts = m[1].split(/[\s,/]+/).filter(Boolean);
301
+ return parts.length > 3 ? parseFloat(parts[3]) : 1;
302
+ };
303
+ function backdropChain(glass, source) {
304
+ const chain = [];
305
+ for (let node = glass.parentElement; node; node = node.parentElement) {
306
+ if (node === source || source.contains(node)) continue;
307
+ const cs = getComputedStyle(node);
308
+ const image = cs.backgroundImage !== "none";
309
+ const a = alpha(cs.backgroundColor);
310
+ if (image || a > 0) chain.unshift(node);
311
+ if (image || a >= 1) break;
312
+ }
313
+ return chain;
314
+ }
315
+ var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
316
+ function mirrorBackdrop(glass, source, filter, padding) {
317
+ const layer = document.createElement("div");
318
+ layer.className = "lg-mirror";
319
+ layer.setAttribute("aria-hidden", "true");
320
+ glass.setAttribute(SELF, "");
321
+ glass.prepend(layer);
322
+ const viewport = document.createElement("div");
323
+ viewport.className = "lg-mirror__viewport";
324
+ layer.append(viewport);
325
+ let copy = clone(source);
326
+ let under = [];
327
+ const buildUnder = () => {
328
+ under.forEach((u) => u.copy.remove());
329
+ under = backdropChain(glass, source).map((original) => {
330
+ const div = document.createElement("div");
331
+ const cs = getComputedStyle(original);
332
+ for (const name of BACKGROUND) div.style.setProperty(name, cs.getPropertyValue(name));
333
+ div.style.position = "absolute";
334
+ div.style.left = "0px";
335
+ div.style.top = "0px";
336
+ div.style.transformOrigin = "0 0";
337
+ return { original, copy: div, placed: "" };
338
+ });
339
+ viewport.prepend(...under.map((u) => u.copy));
340
+ };
341
+ viewport.append(copy.root);
342
+ buildUnder();
343
+ let stopped = false;
344
+ let frame2 = 0;
345
+ let visible = true;
346
+ let placed = "";
347
+ let pad = 0;
348
+ const place = (from, g, sgx, sgy) => {
349
+ const sw = from.offsetWidth;
350
+ const sh = from.offsetHeight;
351
+ if (!sw || !sh) return null;
352
+ const s = from.getBoundingClientRect();
353
+ const kx = s.width / sw / sgx;
354
+ const ky = s.height / sh / sgy;
355
+ const px = (s.left - g.left) / sgx + pad;
356
+ const py = (s.top - g.top) / sgy + pad;
357
+ return { sw, sh, key: `${sw}|${sh}|${px.toFixed(2)}|${py.toFixed(2)}|${kx.toFixed(4)}|${ky.toFixed(4)}`, transform: `translate(${px}px, ${py}px) scale(${kx}, ${ky})` };
358
+ };
359
+ const align = () => {
360
+ const nextPad = padding();
361
+ if (nextPad !== pad) {
362
+ pad = nextPad;
363
+ viewport.style.inset = `${-pad}px`;
364
+ under.forEach((u) => u.placed = "");
365
+ placed = "";
366
+ }
367
+ const gw = glass.offsetWidth;
368
+ const gh = glass.offsetHeight;
369
+ if (!gw || !gh) return;
370
+ const g = glass.getBoundingClientRect();
371
+ const sgx = g.width / gw;
372
+ const sgy = g.height / gh;
373
+ for (const u of under) {
374
+ const at2 = place(u.original, g, sgx, sgy);
375
+ if (!at2 || at2.key === u.placed) continue;
376
+ u.placed = at2.key;
377
+ u.copy.style.width = `${at2.sw}px`;
378
+ u.copy.style.height = `${at2.sh}px`;
379
+ u.copy.style.transform = at2.transform;
380
+ }
381
+ const at = place(source, g, sgx, sgy);
382
+ if (!at) return;
383
+ const { sw, sh } = at;
384
+ const next = at.key;
385
+ if (next === placed) return;
386
+ placed = next;
387
+ const root = copy.root;
388
+ root.style.position = "absolute";
389
+ root.style.left = "0px";
390
+ root.style.top = "0px";
391
+ root.style.margin = "0px";
392
+ root.style.width = `${sw}px`;
393
+ root.style.height = `${sh}px`;
394
+ root.style.scale = "none";
395
+ root.style.translate = "none";
396
+ root.style.transformOrigin = "0 0";
397
+ root.style.transform = at.transform;
398
+ };
399
+ const sync = () => {
400
+ for (const pair of copy.pairs) {
401
+ const css = pair.original.style.cssText;
402
+ const cls = pair.original.className.toString();
403
+ if (css !== pair.css) {
404
+ pair.css = css;
405
+ if (pair.copy !== copy.root) pair.copy.style.cssText = css;
406
+ else {
407
+ pair.copy.style.cssText = css;
408
+ placed = "";
409
+ }
410
+ }
411
+ if (cls !== pair.cls) {
412
+ pair.cls = cls;
413
+ pair.copy.className = cls;
414
+ }
415
+ }
416
+ };
417
+ const applyFilter = () => {
418
+ const value = filter();
419
+ if (layer.style.filter !== value) layer.style.filter = value;
420
+ };
421
+ const tick = () => {
422
+ frame2 = 0;
423
+ if (stopped) return;
424
+ if (visible && !document.hidden) {
425
+ applyFilter();
426
+ sync();
427
+ align();
109
428
  }
429
+ frame2 = requestAnimationFrame(tick);
430
+ };
431
+ frame2 = requestAnimationFrame(tick);
432
+ let pending = 0;
433
+ const recopy = () => {
434
+ pending = 0;
435
+ if (stopped) return;
436
+ const next = clone(source);
437
+ copy.root.replaceWith(next.root);
438
+ copy = next;
439
+ placed = "";
440
+ buildUnder();
441
+ align();
442
+ };
443
+ const mutations = new MutationObserver((records) => {
444
+ if (records.every((r) => layer.contains(r.target) || r.target === layer || r.target === glass)) return;
445
+ const structural = records.some((r) => r.type !== "attributes" && !layer.contains(r.target));
446
+ if (structural && !pending) pending = requestAnimationFrame(recopy);
447
+ });
448
+ mutations.observe(source, { childList: true, characterData: true, subtree: true });
449
+ const io = typeof IntersectionObserver === "function" ? new IntersectionObserver((entries) => {
450
+ visible = entries.some((e) => e.isIntersecting);
451
+ }) : null;
452
+ io?.observe(glass);
453
+ return () => {
454
+ stopped = true;
455
+ cancelAnimationFrame(frame2);
456
+ cancelAnimationFrame(pending);
457
+ mutations.disconnect();
458
+ io?.disconnect();
459
+ layer.remove();
460
+ glass.removeAttribute(SELF);
461
+ };
462
+ }
463
+
464
+ // src/engine/refraction.ts
465
+ var SVG_NS = "http://www.w3.org/2000/svg";
466
+ var cache = /* @__PURE__ */ new Map();
467
+ var defs = null;
468
+ var counter = 0;
469
+ function el(name, attrs) {
470
+ const node = document.createElementNS(SVG_NS, name);
471
+ for (const key in attrs) node.setAttribute(key, String(attrs[key]));
472
+ return node;
473
+ }
474
+ function container() {
475
+ if (defs?.isConnected) return defs;
476
+ const root = el("svg", { width: 0, height: 0, "aria-hidden": "true", "data-liquid-glass-defs": "" });
477
+ root.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
478
+ defs = el("defs", {});
479
+ root.append(defs);
480
+ document.body.append(root);
481
+ return defs;
482
+ }
483
+ function canRefractBackdrop() {
484
+ if (typeof navigator === "undefined") return false;
485
+ const ua = navigator.userAgent;
486
+ return /Chrom(e|ium)\/|Edg\//.test(ua) && !/CriOS|FxiOS|EdgiOS/.test(ua);
487
+ }
488
+ function bevelProfile(bezel, thickness, ior) {
489
+ const N = 256;
490
+ const out = new Float32Array(N);
491
+ for (let i = 0; i < N; i++) {
492
+ const t = Math.max(2e-3, i / (N - 1));
493
+ const q = 1 - t;
494
+ const base = 1 - q ** 4;
495
+ const height = base ** 0.25;
496
+ const slope = q ** 3 / Math.max(1e-4, base ** 0.75);
497
+ const incident = Math.atan(slope);
498
+ const refracted = Math.asin(Math.sin(incident) / ior);
499
+ out[i] = Math.tan(incident - refracted) * thickness * (0.35 + 0.65 * height);
500
+ }
501
+ return (distance) => {
502
+ if (distance < 0 || distance >= bezel) return 0;
503
+ const f = distance / bezel * (N - 1);
504
+ const i = Math.floor(f);
505
+ const a = out[i];
506
+ const b = out[Math.min(i + 1, N - 1)];
507
+ return a + (b - a) * (f - i);
508
+ };
509
+ }
510
+ function bake(width, height, radius, shape, pad = 0) {
511
+ const W = width + pad * 2;
512
+ const H = height + pad * 2;
513
+ let density = Math.min(typeof devicePixelRatio === "number" ? devicePixelRatio : 1, 2);
514
+ while (W * H * density * density > 4e5 && density > 0.35) density *= 0.75;
515
+ const cw = Math.max(1, Math.ceil(W * density));
516
+ const ch = Math.max(1, Math.ceil(H * density));
517
+ const lens = shape.kind === "lens";
518
+ const shift = bevelProfile(shape.bezel, shape.thickness, shape.ior);
519
+ const magnify = lens ? 1 - 1 / Math.max(1, shape.zoom) : 0;
520
+ const direction = lens ? 1 : -1;
521
+ const dx = new Float32Array(cw * ch);
522
+ const dy = new Float32Array(cw * ch);
523
+ const rimA = new Float32Array(cw * ch);
524
+ const rimHue = new Float32Array(cw * ch);
525
+ const inside = new Float32Array(cw * ch);
526
+ let max = 1e-4;
527
+ const hw = width / 2;
528
+ const hh = height / 2;
529
+ const px1 = 1 / density;
530
+ for (let y = 0; y < ch; y++) {
531
+ for (let x = 0; x < cw; x++) {
532
+ const px = (x + 0.5) * W / cw - W / 2;
533
+ const py = (y + 0.5) * H / ch - H / 2;
534
+ const qx = Math.abs(px) - (hw - radius);
535
+ const qy = Math.abs(py) - (hh - radius);
536
+ const ox = Math.max(qx, 0);
537
+ const oy = Math.max(qy, 0);
538
+ const len = Math.hypot(ox, oy);
539
+ const d = radius - (len + Math.min(Math.max(qx, qy), 0));
540
+ let nx;
541
+ let ny;
542
+ if (len > 0) {
543
+ nx = ox / len * Math.sign(px);
544
+ ny = oy / len * Math.sign(py);
545
+ } else if (qx > qy) {
546
+ nx = Math.sign(px);
547
+ ny = 0;
548
+ } else {
549
+ nx = 0;
550
+ ny = Math.sign(py);
551
+ }
552
+ const i = y * cw + x;
553
+ const s = shift(d) * shape.strength * direction;
554
+ const vx = nx * s;
555
+ const vy = ny * s;
556
+ dx[i] = vx;
557
+ dy[i] = vy;
558
+ const m = Math.max(Math.abs(vx), Math.abs(vy));
559
+ if (m > max) max = m;
560
+ inside[i] = clamp(d / px1 + 0.5, 0, 1);
561
+ if (d >= -px1) {
562
+ const facing = -(nx + ny) * Math.SQRT1_2;
563
+ const light = 0.22 + 0.78 * Math.abs(facing) ** 2.2 * (facing > 0 ? 1 : 0.62);
564
+ const line = Math.exp(-(((d - 0.55) / 0.55) ** 2));
565
+ const inner = Math.exp(-((d / (shape.bezel * 0.55)) ** 2)) * 0.14;
566
+ const edgeAA = clamp(d / px1 + 1, 0, 1);
567
+ rimA[i] = clamp((line * (lens ? 0.95 : 0.7) + inner) * light * edgeAA, 0, 1);
568
+ rimHue[i] = Math.atan2(ny, nx);
569
+ }
570
+ }
571
+ }
572
+ const canvas = document.createElement("canvas");
573
+ canvas.width = cw;
574
+ canvas.height = ch;
575
+ const ctx = canvas.getContext("2d");
576
+ const field = ctx.createImageData(cw, ch);
577
+ for (let i = 0; i < cw * ch; i++) {
578
+ const o = i * 4;
579
+ field.data[o] = Math.round(127.5 + dx[i] / max * 127.5);
580
+ field.data[o + 1] = Math.round(127.5 + dy[i] / max * 127.5);
581
+ field.data[o + 2] = 128;
582
+ field.data[o + 3] = 255;
583
+ }
584
+ ctx.putImageData(field, 0, 0);
585
+ const map = canvas.toDataURL();
586
+ const reach = Math.max(W, H) / 2;
587
+ let zoomMap = "";
588
+ if (magnify) {
589
+ const ramp = ctx.createImageData(cw, ch);
590
+ for (let y = 0; y < ch; y++) {
591
+ for (let x = 0; x < cw; x++) {
592
+ const o = (y * cw + x) * 4;
593
+ const px = (x + 0.5) * W / cw - W / 2;
594
+ const py = (y + 0.5) * H / ch - H / 2;
595
+ ramp.data[o] = Math.round(127.5 - px / reach * 127.5);
596
+ ramp.data[o + 1] = Math.round(127.5 - py / reach * 127.5);
597
+ ramp.data[o + 2] = 128;
598
+ ramp.data[o + 3] = 255;
599
+ }
600
+ }
601
+ ctx.putImageData(ramp, 0, 0);
602
+ zoomMap = canvas.toDataURL();
603
+ }
604
+ const shine = ctx.createImageData(cw, ch);
605
+ for (let i = 0; i < cw * ch; i++) {
606
+ const o = i * 4;
607
+ let r = 255;
608
+ let g = 255;
609
+ let b = 255;
610
+ if (lens && shape.dispersion > 0) {
611
+ const h = rimHue[i];
612
+ const k = 0.14 * shape.dispersion;
613
+ r = 255 * (1 - k + k * (0.5 + 0.5 * Math.cos(h)));
614
+ g = 255 * (1 - k + k * (0.5 + 0.5 * Math.cos(h - 2.1)));
615
+ b = 255 * (1 - k + k * (0.5 + 0.5 * Math.cos(h + 2.1)));
616
+ }
617
+ shine.data[o] = r;
618
+ shine.data[o + 1] = g;
619
+ shine.data[o + 2] = b;
620
+ shine.data[o + 3] = Math.round(rimA[i] * 255);
621
+ }
622
+ ctx.putImageData(shine, 0, 0);
623
+ const rim = canvas.toDataURL();
624
+ const shapeMask = ctx.createImageData(cw, ch);
625
+ for (let i = 0; i < cw * ch; i++) {
626
+ const o = i * 4;
627
+ shapeMask.data[o] = shapeMask.data[o + 1] = shapeMask.data[o + 2] = 255;
628
+ shapeMask.data[o + 3] = Math.round(inside[i] * 255);
629
+ }
630
+ ctx.putImageData(shapeMask, 0, 0);
631
+ const mask = canvas.toDataURL();
632
+ const id = `lg-refract-${++counter}`;
633
+ const box = { x: 0, y: 0, width: W, height: H };
634
+ const filter = el("filter", {
635
+ id,
636
+ // Generous region: the rim samples content from beyond the glass edge.
637
+ x: -0.5,
638
+ y: -0.5,
639
+ width: 2,
640
+ height: 2,
641
+ "color-interpolation-filters": "sRGB"
642
+ });
643
+ filter.append(el("feImage", { href: map, ...box, preserveAspectRatio: "none", result: "field" }));
644
+ let source = "SourceGraphic";
645
+ if (zoomMap) {
646
+ filter.append(
647
+ el("feImage", { href: zoomMap, ...box, preserveAspectRatio: "none", result: "zoom" }),
648
+ el("feDisplacementMap", {
649
+ in: "SourceGraphic",
650
+ in2: "zoom",
651
+ scale: 2 * reach * magnify,
652
+ xChannelSelector: "R",
653
+ yChannelSelector: "G",
654
+ result: "magnified"
655
+ })
656
+ );
657
+ source = "magnified";
658
+ }
659
+ const scale = max * 2;
660
+ if (shape.dispersion > 0) {
661
+ const spread = 0.16 * shape.dispersion;
662
+ const channels = [
663
+ ["r", 1 + spread, "1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0"],
664
+ ["g", 1, "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0"],
665
+ ["b", 1 - spread, "0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0"]
666
+ ];
667
+ for (const [name, factor, matrix] of channels) {
668
+ filter.append(
669
+ el("feDisplacementMap", {
670
+ in: source,
671
+ in2: "field",
672
+ scale: scale * factor,
673
+ xChannelSelector: "R",
674
+ yChannelSelector: "G",
675
+ result: `${name}-ray`
676
+ }),
677
+ el("feColorMatrix", { in: `${name}-ray`, type: "matrix", values: matrix, result: name })
678
+ );
679
+ }
680
+ filter.append(
681
+ el("feComposite", { in: "r", in2: "g", operator: "arithmetic", k2: 1, k3: 1, result: "rg" }),
682
+ el("feComposite", { in: "rg", in2: "b", operator: "arithmetic", k2: 1, k3: 1, result: "bent" })
683
+ );
684
+ } else {
685
+ filter.append(
686
+ el("feDisplacementMap", {
687
+ in: source,
688
+ in2: "field",
689
+ scale,
690
+ xChannelSelector: "R",
691
+ yChannelSelector: "G",
692
+ result: "bent"
693
+ })
694
+ );
695
+ }
696
+ filter.append(
697
+ el("feImage", { href: mask, ...box, preserveAspectRatio: "none", result: "shape" }),
698
+ el("feComposite", { in: "bent", in2: "shape", operator: "in" })
110
699
  );
700
+ container().append(filter);
701
+ return { filter: `url(#${id})`, rim: `url("${rim}")` };
702
+ }
703
+ function resolve(shape, width, height) {
704
+ const kind = shape.kind ?? "surface";
705
+ const short = Math.min(width, height);
706
+ const lens = kind === "lens";
707
+ return {
708
+ kind,
709
+ bezel: shape.bezel ?? (lens ? short * 0.32 : clamp(short * 0.2, 5, 16)),
710
+ thickness: shape.thickness ?? (lens ? short * 0.55 : clamp(short * 0.32, 8, 26)),
711
+ ior: shape.ior ?? 1.5,
712
+ zoom: shape.zoom ?? (lens ? 1.16 : 1),
713
+ dispersion: shape.dispersion ?? (lens ? 1 : 0),
714
+ strength: shape.strength ?? 1
715
+ };
716
+ }
717
+ function glassFor(width, height, radius, shape = {}, pad = 0) {
718
+ const w = Math.round(width);
719
+ const h = Math.round(height);
720
+ const r = Math.min(w / 2, h / 2, Math.max(0, radius));
721
+ const full = resolve(shape, w, h);
722
+ const key = [w, h, Math.round(r * 2) / 2, full.kind, full.bezel.toFixed(1), full.thickness.toFixed(1), full.ior, full.zoom, full.dispersion, full.strength, pad].join("|");
723
+ let baked = cache.get(key);
724
+ if (!baked) {
725
+ baked = bake(w, h, r, full, pad);
726
+ cache.set(key, baked);
727
+ }
728
+ return baked;
729
+ }
730
+ function idle(callback) {
731
+ if (typeof requestIdleCallback === "function") {
732
+ const handle2 = requestIdleCallback(callback, { timeout: 120 });
733
+ return () => cancelIdleCallback(handle2);
734
+ }
735
+ const handle = setTimeout(callback, 16);
736
+ return () => clearTimeout(handle);
737
+ }
738
+ function cornerRadius(element, width, height) {
739
+ const value = getComputedStyle(element).borderTopLeftRadius;
740
+ const n = parseFloat(value);
741
+ if (!Number.isFinite(n)) return 0;
742
+ return value.endsWith("%") ? Math.min(width, height) * n / 100 : n;
743
+ }
744
+ function useRefraction(ref, shape = {}, enabled = true, mirror) {
745
+ const signature = JSON.stringify(shape);
746
+ (0, import_react2.useEffect)(() => {
747
+ const element = ref.current;
748
+ if (!element || !enabled) return;
749
+ const live = canRefractBackdrop();
750
+ let cancel;
751
+ let filter = "";
752
+ let pad = 0;
753
+ const fit = () => {
754
+ const width = element.offsetWidth;
755
+ const height = element.offsetHeight;
756
+ if (!width || !height) return;
757
+ const radius = cornerRadius(element, width, height);
758
+ const baked = glassFor(width, height, radius, shape);
759
+ filter = baked.filter;
760
+ if (!live && mirror?.current) pad = Math.ceil(Math.min(width, height) * 0.45 + 6);
761
+ if (live) element.style.setProperty("--lg-filter", baked.filter);
762
+ element.style.setProperty("--lg-rim", baked.rim);
763
+ };
764
+ const observer = new ResizeObserver(() => {
765
+ cancel?.();
766
+ cancel = idle(fit);
767
+ });
768
+ observer.observe(element);
769
+ fit();
770
+ const source = mirror?.current;
771
+ const unmirror = !live && source ? mirrorBackdrop(element, source, () => filter, () => pad) : void 0;
772
+ return () => {
773
+ cancel?.();
774
+ unmirror?.();
775
+ observer.disconnect();
776
+ element.style.removeProperty("--lg-filter");
777
+ element.style.removeProperty("--lg-rim");
778
+ };
779
+ }, [ref, signature, enabled, mirror]);
780
+ }
781
+
782
+ // src/engine/haptics.ts
783
+ var label = null;
784
+ var isIOS = () => typeof navigator !== "undefined" && (/iP(hone|ad|od)/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
785
+ function haptic() {
786
+ if (typeof window === "undefined") return;
787
+ if (!matchMedia("(pointer: coarse)").matches) return;
788
+ try {
789
+ if (typeof navigator.vibrate === "function" && !isIOS()) {
790
+ navigator.vibrate(8);
791
+ return;
792
+ }
793
+ if (!isIOS()) return;
794
+ if (!label?.isConnected) {
795
+ label = document.createElement("label");
796
+ label.setAttribute("aria-hidden", "true");
797
+ label.style.cssText = "position:fixed;width:1px;height:1px;overflow:hidden;opacity:0;pointer-events:none;left:-9px;top:-9px";
798
+ const input = document.createElement("input");
799
+ input.type = "checkbox";
800
+ input.setAttribute("switch", "");
801
+ input.tabIndex = -1;
802
+ label.append(input);
803
+ document.body.append(label);
804
+ }
805
+ label.click();
806
+ } catch {
807
+ }
111
808
  }
112
809
 
113
810
  // src/components/GlassButton/GlassButton.tsx
114
- var import_jsx_runtime2 = require("react/jsx-runtime");
115
- var GlassButton = import_react2.default.forwardRef(
811
+ var import_jsx_runtime = require("react/jsx-runtime");
812
+ var GlassButton = import_react3.default.forwardRef(
116
813
  ({
117
814
  intensity = 5,
118
815
  tint,
@@ -120,191 +817,74 @@ var GlassButton = import_react2.default.forwardRef(
120
817
  thickness = 1,
121
818
  size = "md",
122
819
  variant = "default",
820
+ icon,
123
821
  className,
124
822
  style,
125
823
  children,
824
+ type = "button",
825
+ onPointerDown,
126
826
  ...rest
127
- }, ref) => {
128
- const isFilterMounted = useGlassFilterMounted();
129
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
130
- const glassStyle = (0, import_react2.useMemo)(() => {
131
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
132
- const vars = {
133
- "--glass-blur": `${clampedIntensity * 2.4}px`,
134
- "--glass-border-width": `${thickness}px`,
135
- "--glass-refraction-filter": `url(#${filterId})`
136
- };
137
- if (tint) {
138
- vars["--glass-tint"] = tint;
827
+ }, forwardedRef) => {
828
+ const ref = (0, import_react3.useRef)(null);
829
+ (0, import_react3.useImperativeHandle)(forwardedRef, () => ref.current);
830
+ const level = Math.max(1, Math.min(10, intensity));
831
+ const height = size === "sm" ? 36 : size === "lg" ? 52 : 44;
832
+ usePress(ref, { disabled: rest.disabled });
833
+ useRefraction(ref, {
834
+ kind: "surface",
835
+ strength: level / 5,
836
+ bezel: Math.min(height * 0.36, 22) * Math.max(0.5, thickness)
837
+ });
838
+ const iconOnly = icon != null && (children == null || children === false);
839
+ const kind = variant === "ghost" ? "clear" : variant;
840
+ const classes = ["lg-glass", "lg-button", `lg-button--${size}`, `lg-button--${kind}`, className].filter(Boolean).join(" ");
841
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
842
+ "button",
843
+ {
844
+ ref,
845
+ type,
846
+ className: classes,
847
+ "data-liquid-glass": "",
848
+ "data-icon-only": iconOnly ? "" : void 0,
849
+ "data-shimmer": shimmer ? "" : void 0,
850
+ style: tint ? { "--lg-tint": tint, ...style } : style,
851
+ onPointerDown: (event) => {
852
+ if (!rest.disabled) haptic();
853
+ onPointerDown?.(event);
854
+ },
855
+ ...rest,
856
+ children: [
857
+ icon != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "lg-button__icon", children: icon }),
858
+ !iconOnly && children != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "lg-button__label", children })
859
+ ]
139
860
  }
140
- return vars;
141
- }, [clampedIntensity, tint, thickness]);
142
- const rootClasses = [
143
- "lg-root",
144
- "lg-button",
145
- `lg-button--${size}`,
146
- `lg-button--${variant}`,
147
- shimmer ? "lg-button--shimmer" : "",
148
- className ?? ""
149
- ].filter(Boolean).join(" ");
150
- const freq1 = 0.012 + clampedIntensity * 1e-3;
151
- const freq2 = 0.01 + clampedIntensity * 8e-4;
152
- const scale = clampedIntensity * 2;
153
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
154
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
155
- "svg",
156
- {
157
- width: "0",
158
- height: "0",
159
- style: { position: "absolute", pointerEvents: "none" },
160
- "aria-hidden": "true",
161
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
162
- "filter",
163
- {
164
- id: `liquid-glass-refract-${clampedIntensity}`,
165
- x: "-10%",
166
- y: "-10%",
167
- width: "120%",
168
- height: "120%",
169
- colorInterpolationFilters: "sRGB",
170
- children: [
171
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
172
- "feTurbulence",
173
- {
174
- type: "fractalNoise",
175
- baseFrequency: `${freq1} ${freq2}`,
176
- numOctaves: 3,
177
- seed: 42,
178
- result: "noise"
179
- }
180
- ),
181
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
- "feDisplacementMap",
183
- {
184
- in: "SourceGraphic",
185
- in2: "noise",
186
- scale,
187
- xChannelSelector: "R",
188
- yChannelSelector: "G"
189
- }
190
- )
191
- ]
192
- }
193
- ) })
194
- }
195
- ),
196
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
197
- "button",
198
- {
199
- ref,
200
- className: "lg-surface",
201
- ...rest,
202
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "lg-content", children })
203
- }
204
- ),
205
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "lg-backdrop-surface", "aria-hidden": "true" }),
206
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
207
- ] });
861
+ );
208
862
  }
209
863
  );
210
864
  GlassButton.displayName = "GlassButton";
211
865
 
212
866
  // src/components/GlassCard/GlassCard.tsx
213
- var import_react3 = __toESM(require("react"));
214
- var import_jsx_runtime3 = require("react/jsx-runtime");
215
- var GlassCard = import_react3.default.forwardRef(
216
- ({
217
- intensity = 5,
218
- tint,
219
- shimmer = true,
220
- thickness = 1,
221
- padding = "24px",
222
- radius = "20px",
223
- className,
224
- style,
225
- children,
226
- ...rest
227
- }, ref) => {
228
- const isFilterMounted = useGlassFilterMounted();
229
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
230
- const glassStyle = (0, import_react3.useMemo)(() => {
231
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
232
- const vars = {
233
- "--glass-blur": `${clampedIntensity * 2.4}px`,
234
- "--glass-border-width": `${thickness}px`,
235
- "--glass-radius": radius,
236
- "--glass-padding": padding,
237
- "--glass-refraction-filter": `url(#${filterId})`
238
- };
239
- if (tint) {
240
- vars["--glass-tint"] = tint;
241
- }
242
- return vars;
243
- }, [clampedIntensity, tint, thickness, radius, padding]);
244
- const rootClasses = [
245
- "lg-root",
246
- "lg-card",
247
- shimmer ? "lg-card--shimmer" : "",
248
- className ?? ""
249
- ].filter(Boolean).join(" ");
250
- const freq1 = 0.012 + clampedIntensity * 1e-3;
251
- const freq2 = 0.01 + clampedIntensity * 8e-4;
252
- const scale = clampedIntensity * 2;
253
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
867
+ var import_react4 = __toESM(require("react"));
868
+ var import_jsx_runtime2 = require("react/jsx-runtime");
869
+ var GlassCard = import_react4.default.forwardRef(
870
+ ({ intensity = 5, tint, shimmer: _shimmer, thickness = 1, padding = "24px", radius = "28px", variant = "regular", className, style, children, ...rest }, forwardedRef) => {
871
+ const ref = (0, import_react4.useRef)(null);
872
+ (0, import_react4.useImperativeHandle)(forwardedRef, () => ref.current);
873
+ useRefraction(ref, {
874
+ kind: "surface",
875
+ strength: Math.max(1, Math.min(10, intensity)) / 5,
876
+ bezel: 16 * Math.max(0.5, thickness),
877
+ thickness: 22 * Math.max(0.5, thickness)
878
+ });
879
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
254
880
  "div",
255
881
  {
256
882
  ref,
257
- className: rootClasses,
258
- "data-liquid-glass": true,
259
- style: { ...glassStyle, ...style },
883
+ className: ["lg-glass", "lg-card", `lg-card--${variant}`, className].filter(Boolean).join(" "),
884
+ "data-liquid-glass": "",
885
+ style: { padding, borderRadius: radius, ...tint ? { "--lg-card-tint": tint } : {}, ...style },
260
886
  ...rest,
261
- children: [
262
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
263
- "svg",
264
- {
265
- width: "0",
266
- height: "0",
267
- style: { position: "absolute", pointerEvents: "none" },
268
- "aria-hidden": "true",
269
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
270
- "filter",
271
- {
272
- id: `liquid-glass-refract-${clampedIntensity}`,
273
- x: "-10%",
274
- y: "-10%",
275
- width: "120%",
276
- height: "120%",
277
- colorInterpolationFilters: "sRGB",
278
- children: [
279
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
280
- "feTurbulence",
281
- {
282
- type: "fractalNoise",
283
- baseFrequency: `${freq1} ${freq2}`,
284
- numOctaves: 3,
285
- seed: 42,
286
- result: "noise"
287
- }
288
- ),
289
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
290
- "feDisplacementMap",
291
- {
292
- in: "SourceGraphic",
293
- in2: "noise",
294
- scale,
295
- xChannelSelector: "R",
296
- yChannelSelector: "G"
297
- }
298
- )
299
- ]
300
- }
301
- ) })
302
- }
303
- ),
304
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-surface lg-card__surface", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-content lg-card__content", children }) }),
305
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-backdrop-surface lg-card__backdrop-surface", "aria-hidden": "true" }),
306
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
307
- ]
887
+ children
308
888
  }
309
889
  );
310
890
  }
@@ -312,336 +892,963 @@ var GlassCard = import_react3.default.forwardRef(
312
892
  GlassCard.displayName = "GlassCard";
313
893
 
314
894
  // src/components/GlassInput/GlassInput.tsx
315
- var import_react4 = __toESM(require("react"));
316
- var import_jsx_runtime4 = require("react/jsx-runtime");
317
- var GlassInput = import_react4.default.forwardRef(
318
- ({
319
- intensity = 5,
320
- tint,
321
- placeholder,
322
- value,
323
- onChange,
324
- label,
325
- className,
326
- style,
327
- id: externalId,
328
- ...rest
329
- }, ref) => {
330
- const autoId = (0, import_react4.useId)();
331
- const inputId = externalId ?? autoId;
332
- const [focused, setFocused] = (0, import_react4.useState)(false);
333
- const [hasValue, setHasValue] = (0, import_react4.useState)(() => Boolean(value));
334
- const isFilterMounted = useGlassFilterMounted();
335
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
336
- const handleFocus = (0, import_react4.useCallback)(
337
- (e) => {
338
- setFocused(true);
339
- rest.onFocus?.(e);
340
- },
341
- [rest.onFocus]
342
- );
343
- const handleBlur = (0, import_react4.useCallback)(
344
- (e) => {
345
- setFocused(false);
346
- rest.onBlur?.(e);
347
- },
348
- [rest.onBlur]
349
- );
350
- const handleChange = (0, import_react4.useCallback)(
351
- (e) => {
352
- setHasValue(e.target.value.length > 0);
353
- onChange?.(e);
354
- },
355
- [onChange]
356
- );
357
- const glassStyle = (0, import_react4.useMemo)(() => {
358
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
359
- const vars = {
360
- "--glass-blur": `${clampedIntensity * 2.4}px`,
361
- "--glass-border-width": "1px",
362
- "--glass-refraction-filter": `url(#${filterId})`
363
- };
364
- if (tint) {
365
- vars["--glass-tint"] = tint;
895
+ var import_react5 = __toESM(require("react"));
896
+ var import_jsx_runtime3 = require("react/jsx-runtime");
897
+ var Magnifier = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", "aria-hidden": "true", children: [
898
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "8.5", cy: "8.5", r: "5.75" }),
899
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m13 13 4 4" })
900
+ ] });
901
+ var ClearGlyph = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: [
902
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "10", cy: "10", r: "9", fill: "currentColor" }),
903
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m7 7 6 6m0-6-6 6", stroke: "var(--lg-clear-x, #fff)", strokeWidth: 1.7, strokeLinecap: "round" })
904
+ ] });
905
+ var GlassInput = import_react5.default.forwardRef(
906
+ ({ intensity = 5, tint, label: label2, icon, trailing, onClear, className, style, value, onChange, type = "text", disabled, onFocus, onBlur, ...rest }, forwardedRef) => {
907
+ const fieldRef = (0, import_react5.useRef)(null);
908
+ const inputRef = (0, import_react5.useRef)(null);
909
+ (0, import_react5.useImperativeHandle)(forwardedRef, () => inputRef.current);
910
+ const [focused, setFocused] = (0, import_react5.useState)(false);
911
+ const [inner, setInner] = (0, import_react5.useState)("");
912
+ const current = value ?? inner;
913
+ useRefraction(fieldRef, { kind: "surface", strength: Math.max(1, Math.min(10, intensity)) / 5 });
914
+ usePress(fieldRef, { grow: 0.03, lean: 3, stretch: 0.03, disabled });
915
+ const leading = icon ?? (type === "search" ? Magnifier : null);
916
+ const clear = () => {
917
+ if (onClear) onClear();
918
+ else {
919
+ const input = inputRef.current;
920
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
921
+ setter?.call(input, "");
922
+ input.dispatchEvent(new Event("input", { bubbles: true }));
366
923
  }
367
- return vars;
368
- }, [clampedIntensity, tint]);
369
- const rootClasses = [
370
- "lg-root",
371
- "lg-input",
372
- focused ? "lg-input--focused" : "",
373
- hasValue || value ? "lg-input--has-value" : "",
374
- className ?? ""
375
- ].filter(Boolean).join(" ");
376
- const freq1 = 0.012 + clampedIntensity * 1e-3;
377
- const freq2 = 0.01 + clampedIntensity * 8e-4;
378
- const scale = clampedIntensity * 2;
379
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
380
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
381
- "svg",
382
- {
383
- width: "0",
384
- height: "0",
385
- style: { position: "absolute", pointerEvents: "none" },
386
- "aria-hidden": "true",
387
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
388
- "filter",
389
- {
390
- id: `liquid-glass-refract-${clampedIntensity}`,
391
- x: "-10%",
392
- y: "-10%",
393
- width: "120%",
394
- height: "120%",
395
- colorInterpolationFilters: "sRGB",
396
- children: [
397
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
398
- "feTurbulence",
399
- {
400
- type: "fractalNoise",
401
- baseFrequency: `${freq1} ${freq2}`,
402
- numOctaves: 3,
403
- seed: 42,
404
- result: "noise"
405
- }
406
- ),
407
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
408
- "feDisplacementMap",
409
- {
410
- in: "SourceGraphic",
411
- in2: "noise",
412
- scale,
413
- xChannelSelector: "R",
414
- yChannelSelector: "G"
415
- }
416
- )
417
- ]
418
- }
419
- ) })
420
- }
421
- ),
422
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-surface lg-input__surface", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lg-content lg-input__content", children: [
423
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { className: "lg-input__label", htmlFor: inputId, children: label }),
424
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
425
- "input",
426
- {
427
- ref,
428
- id: inputId,
429
- className: "lg-input__field",
430
- type: "text",
431
- placeholder: label ? void 0 : placeholder,
432
- value,
433
- onChange: handleChange,
434
- onFocus: handleFocus,
435
- onBlur: handleBlur,
436
- ...rest
437
- }
438
- )
439
- ] }) }),
440
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-backdrop-surface lg-input__backdrop-surface", "aria-hidden": "true" }),
441
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
442
- ] });
924
+ inputRef.current?.focus();
925
+ };
926
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
927
+ "label",
928
+ {
929
+ className: ["lg-input", className].filter(Boolean).join(" "),
930
+ "data-liquid-glass": "",
931
+ style: tint ? { "--lg-input-tint": tint, ...style } : style,
932
+ children: [
933
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lg-input__label", children: label2 }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref: fieldRef, className: "lg-glass lg-input__field", "data-focused": focused ? "" : void 0, children: [
935
+ leading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lg-input__icon", children: leading }),
936
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
937
+ "input",
938
+ {
939
+ ref: inputRef,
940
+ type,
941
+ value: current,
942
+ disabled,
943
+ onChange: (event) => {
944
+ if (value === void 0) setInner(event.target.value);
945
+ onChange?.(event);
946
+ },
947
+ onFocus: (event) => {
948
+ setFocused(true);
949
+ onFocus?.(event);
950
+ },
951
+ onBlur: (event) => {
952
+ setFocused(false);
953
+ onBlur?.(event);
954
+ },
955
+ ...rest
956
+ }
957
+ ),
958
+ current && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
959
+ "button",
960
+ {
961
+ type: "button",
962
+ className: "lg-input__clear",
963
+ "aria-label": "Clear",
964
+ onPointerDown: (event) => event.preventDefault(),
965
+ onClick: clear,
966
+ children: ClearGlyph
967
+ }
968
+ ) : trailing && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lg-input__icon lg-input__trailing", children: trailing })
969
+ ] })
970
+ ]
971
+ }
972
+ );
443
973
  }
444
974
  );
445
975
  GlassInput.displayName = "GlassInput";
446
976
 
447
977
  // src/components/GlassSheet/GlassSheet.tsx
448
- var import_react5 = require("react");
449
- var import_jsx_runtime5 = require("react/jsx-runtime");
450
- var GlassSheet = ({
451
- open,
452
- onClose,
453
- intensity = 5,
454
- tint,
455
- children
456
- }) => {
457
- const [mounted, setMounted] = (0, import_react5.useState)(open);
458
- const [visible, setVisible] = (0, import_react5.useState)(false);
459
- const sheetRef = (0, import_react5.useRef)(null);
460
- const isFilterMounted = useGlassFilterMounted();
461
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
462
- (0, import_react5.useEffect)(() => {
463
- if (open) {
464
- setMounted(true);
465
- requestAnimationFrame(() => {
466
- requestAnimationFrame(() => setVisible(true));
467
- });
468
- } else {
469
- setVisible(false);
470
- }
471
- }, [open]);
472
- const handleTransitionEnd = (0, import_react5.useCallback)(() => {
473
- if (!open) setMounted(false);
978
+ var import_react6 = require("react");
979
+ var import_react_dom = require("react-dom");
980
+ var import_jsx_runtime4 = require("react/jsx-runtime");
981
+ var OPEN = springFrom(0.42, 0.86);
982
+ var CLOSE = springFrom(0.34, 1);
983
+ var GlassSheet = ({ open, onClose, intensity = 5, tint, children, "aria-label": ariaLabel }) => {
984
+ const [mounted, setMounted] = (0, import_react6.useState)(open);
985
+ const sheetRef = (0, import_react6.useRef)(null);
986
+ const scrimRef = (0, import_react6.useRef)(null);
987
+ const progress = (0, import_react6.useRef)(null);
988
+ const closeRef = (0, import_react6.useRef)(onClose);
989
+ closeRef.current = onClose;
990
+ (0, import_react6.useEffect)(() => {
991
+ if (open) setMounted(true);
992
+ else progress.current?.set(0);
474
993
  }, [open]);
475
- (0, import_react5.useEffect)(() => {
476
- if (!open) return;
477
- const onKeyDown = (e) => {
478
- if (e.key === "Escape") onClose?.();
479
- };
480
- window.addEventListener("keydown", onKeyDown);
481
- return () => window.removeEventListener("keydown", onKeyDown);
482
- }, [open, onClose]);
483
- (0, import_react5.useEffect)(() => {
484
- if (mounted) {
485
- const prev = document.body.style.overflow;
486
- document.body.style.overflow = "hidden";
487
- return () => {
488
- document.body.style.overflow = prev;
489
- };
490
- }
994
+ useRefraction(sheetRef, { kind: "surface", strength: Math.max(1, Math.min(10, intensity)) / 5, bezel: 20, thickness: 28 }, mounted);
995
+ (0, import_react6.useEffect)(() => {
996
+ if (!mounted) return;
997
+ const sheet = sheetRef.current;
998
+ const scrim = scrimRef.current;
999
+ let height = sheet.offsetHeight || 400;
1000
+ let drag = 0;
1001
+ const paint = (p) => {
1002
+ const y = (1 - p) * (height + 24) + drag;
1003
+ sheet.style.transform = `translateY(${y}px)`;
1004
+ scrim.style.opacity = String(clamp(p, 0, 1) * clamp(1 - drag / height, 0, 1));
1005
+ };
1006
+ const spring = createSpring(0, OPEN, (p) => {
1007
+ paint(p);
1008
+ if (p <= 1e-3 && spring.target === 0) setMounted(false);
1009
+ });
1010
+ progress.current = {
1011
+ ...spring,
1012
+ set(target, instant) {
1013
+ spring.tune(target ? OPEN : CLOSE);
1014
+ spring.set(target, instant);
1015
+ }
1016
+ };
1017
+ paint(0);
1018
+ requestAnimationFrame(() => {
1019
+ height = sheet.offsetHeight || height;
1020
+ if (open) progress.current?.set(1);
1021
+ });
1022
+ let gesture = null;
1023
+ const down = (event) => {
1024
+ const target = event.target;
1025
+ if (!target.closest(".lg-sheet__grabber-zone") && sheet.scrollTop > 0) return;
1026
+ if (target.closest('input, textarea, button, a, [role="slider"], [role="switch"]')) return;
1027
+ gesture = { id: event.pointerId, y: event.clientY, t: event.timeStamp, v: 0 };
1028
+ sheet.setPointerCapture(event.pointerId);
1029
+ };
1030
+ const move = (event) => {
1031
+ if (event.pointerId !== gesture?.id) return;
1032
+ const dy = event.clientY - gesture.y;
1033
+ const dt = Math.max(1, event.timeStamp - gesture.t);
1034
+ gesture.v = (dy - drag) / dt;
1035
+ gesture.t = event.timeStamp;
1036
+ drag = dy > 0 ? dy : rubberband(dy, height, 0.3);
1037
+ paint(spring.value);
1038
+ };
1039
+ const up = (event) => {
1040
+ if (event.pointerId !== gesture?.id) return;
1041
+ const flick = gesture.v > 0.6;
1042
+ gesture = null;
1043
+ const settle = createSpring(drag, SPRINGS.snap, (value) => {
1044
+ drag = value;
1045
+ paint(spring.value);
1046
+ });
1047
+ if (flick || drag > height * 0.3) {
1048
+ settle.stop();
1049
+ const p = 1 - clamp(drag / (height + 24), 0, 1);
1050
+ drag = 0;
1051
+ spring.set(p, true);
1052
+ closeRef.current?.();
1053
+ } else {
1054
+ settle.set(0);
1055
+ }
1056
+ };
1057
+ const key = (event) => {
1058
+ if (event.key === "Escape") closeRef.current?.();
1059
+ };
1060
+ sheet.addEventListener("pointerdown", down);
1061
+ sheet.addEventListener("pointermove", move);
1062
+ sheet.addEventListener("pointerup", up);
1063
+ sheet.addEventListener("pointercancel", up);
1064
+ window.addEventListener("keydown", key);
1065
+ const overflow = document.body.style.overflow;
1066
+ document.body.style.overflow = "hidden";
1067
+ sheet.focus({ preventScroll: true });
1068
+ return () => {
1069
+ spring.stop();
1070
+ progress.current = null;
1071
+ sheet.removeEventListener("pointerdown", down);
1072
+ sheet.removeEventListener("pointermove", move);
1073
+ sheet.removeEventListener("pointerup", up);
1074
+ sheet.removeEventListener("pointercancel", up);
1075
+ window.removeEventListener("keydown", key);
1076
+ document.body.style.overflow = overflow;
1077
+ };
491
1078
  }, [mounted]);
492
- const glassStyle = (0, import_react5.useMemo)(() => {
493
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
494
- const vars = {
495
- "--glass-blur": `${clampedIntensity * 2.4}px`,
496
- "--glass-border-width": "1px",
497
- "--glass-refraction-filter": `url(#${filterId})`
1079
+ if (!mounted || typeof document === "undefined") return null;
1080
+ return (0, import_react_dom.createPortal)(
1081
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "lg-sheet-layer", "data-liquid-glass": "", children: [
1082
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: scrimRef, className: "lg-sheet__scrim", onClick: () => onClose?.(), "aria-hidden": "true" }),
1083
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1084
+ "div",
1085
+ {
1086
+ ref: sheetRef,
1087
+ role: "dialog",
1088
+ "aria-modal": "true",
1089
+ "aria-label": ariaLabel,
1090
+ tabIndex: -1,
1091
+ className: "lg-glass lg-sheet",
1092
+ style: tint ? { "--lg-card-tint": tint } : void 0,
1093
+ children: [
1094
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-sheet__grabber-zone", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "lg-sheet__grabber" }) }),
1095
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "lg-sheet__content", children })
1096
+ ]
1097
+ }
1098
+ )
1099
+ ] }),
1100
+ document.body
1101
+ );
1102
+ };
1103
+ GlassSheet.displayName = "GlassSheet";
1104
+
1105
+ // src/components/GlassNav/GlassNav.tsx
1106
+ var import_react9 = __toESM(require("react"));
1107
+
1108
+ // src/components/internal/LensTrack.tsx
1109
+ var import_react8 = require("react");
1110
+
1111
+ // src/engine/lensTrack.ts
1112
+ var import_react7 = require("react");
1113
+ function useLensTrack(refs, options) {
1114
+ const latest = (0, import_react7.useRef)(options);
1115
+ latest.current = options;
1116
+ const api = (0, import_react7.useRef)(null);
1117
+ (0, import_react7.useEffect)(() => {
1118
+ const bar = refs.bar.current;
1119
+ const lens = refs.lens.current;
1120
+ const tint = refs.tint.current;
1121
+ const row = refs.row.current;
1122
+ const glass = refs.glass.current;
1123
+ if (!bar || !lens || !tint || !row || !glass) return;
1124
+ let slot = 0;
1125
+ let height = 0;
1126
+ let pad = 0;
1127
+ let barHeight = 0;
1128
+ const state = { x: 0, lift: 0, swell: 0, squash: 0 };
1129
+ let current = latest.current.index;
1130
+ let gesture = null;
1131
+ let suppressClick = false;
1132
+ const measure = () => {
1133
+ const style = getComputedStyle(bar);
1134
+ pad = parseFloat(style.paddingLeft) || 0;
1135
+ slot = (bar.clientWidth - pad - (parseFloat(style.paddingRight) || 0)) / latest.current.count;
1136
+ height = lens.offsetHeight;
1137
+ barHeight = bar.offsetHeight;
498
1138
  };
499
- if (tint) {
500
- vars["--glass-tint"] = tint;
1139
+ const paint = () => {
1140
+ const { x: x2, lift: lift2, swell: swell2, squash } = state;
1141
+ const { overhang, spread } = latest.current;
1142
+ const liftH = barHeight + overhang - height;
1143
+ const sx = 1 + spread * lift2 + squash;
1144
+ const sy = 1 + liftH / height * lift2 - squash * 0.6;
1145
+ const transform = `translateX(${x2}px) scale(${sx}, ${sy})`;
1146
+ lens.style.transform = transform;
1147
+ tint.style.transform = transform;
1148
+ row.style.transform = `scale(${1 / sx}, ${1 / sy}) translate(${(sx - 1) * slot / 2 - x2}px, ${(sy - 1) * height / 2}px)`;
1149
+ const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2;
1150
+ bar.style.scale = `${grow}`;
1151
+ lens.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1152
+ bar.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1153
+ if (!gesture && lift2 < 0.02) delete bar.dataset.lifted;
1154
+ };
1155
+ const x = createSpring(current * slot, SPRINGS.snap, (value, velocity) => {
1156
+ state.x = value;
1157
+ state.squash = clamp(Math.abs(velocity) / 4200, 0, 0.16);
1158
+ paint();
1159
+ });
1160
+ const lift = createSpring(0, SPRINGS.lift, (value) => {
1161
+ state.lift = value;
1162
+ paint();
1163
+ });
1164
+ const swell = createSpring(0, SPRINGS.press, (value) => {
1165
+ state.swell = value;
1166
+ paint();
1167
+ });
1168
+ const place = (index, instant = false) => {
1169
+ current = index;
1170
+ if (!gesture) {
1171
+ x.tune(SPRINGS.snap);
1172
+ x.set(index * slot, instant);
1173
+ }
1174
+ };
1175
+ const position = (clientX) => {
1176
+ if (!gesture) return 0;
1177
+ const raw = gesture.anchor + clientX - gesture.startX;
1178
+ const max = slot * (latest.current.count - 1);
1179
+ if (raw < 0) return rubberband(raw, slot, 0.5);
1180
+ if (raw > max) return max + rubberband(raw - max, slot, 0.5);
1181
+ return raw;
1182
+ };
1183
+ const light = (clientX, box) => {
1184
+ glass.style.setProperty("--lg-x", `${clamp((clientX - box.left) / box.width * 100, 0, 100)}%`);
1185
+ lens.style.setProperty("--lg-x", `${clamp((clientX - box.left - pad - state.x) / slot * 100, 0, 100)}%`);
1186
+ };
1187
+ const itemAt = (event) => {
1188
+ const target = event.target.closest("[data-lg-item]");
1189
+ return target && bar.contains(target) ? Number(target.dataset.lgItem) : -1;
1190
+ };
1191
+ const onDown = (event) => {
1192
+ if (!event.isPrimary || event.button !== 0 || gesture) return;
1193
+ const index = itemAt(event);
1194
+ if (index < 0) return;
1195
+ measure();
1196
+ const box = bar.getBoundingClientRect();
1197
+ gesture = { id: event.pointerId, startX: event.clientX, anchor: index * slot, moved: false, box, hovered: index };
1198
+ suppressClick = false;
1199
+ bar.dataset.lifted = "";
1200
+ lens.dataset.pressed = "";
1201
+ light(event.clientX, box);
1202
+ haptic();
1203
+ lift.tune(SPRINGS.lift);
1204
+ lift.set(1);
1205
+ swell.tune(SPRINGS.press);
1206
+ swell.set(1);
1207
+ x.tune(SPRINGS.snap);
1208
+ x.set(index * slot);
1209
+ };
1210
+ const onMove = (event) => {
1211
+ if (event.pointerId !== gesture?.id) return;
1212
+ if (!gesture.moved && Math.abs(event.clientX - gesture.startX) > 5) {
1213
+ gesture.moved = true;
1214
+ try {
1215
+ bar.setPointerCapture(event.pointerId);
1216
+ } catch {
1217
+ }
1218
+ }
1219
+ light(event.clientX, gesture.box);
1220
+ if (!gesture.moved) return;
1221
+ const at = position(event.clientX);
1222
+ x.tune(SPRINGS.drag);
1223
+ x.set(at);
1224
+ const hovered = clamp(Math.round(at / slot), 0, latest.current.count - 1);
1225
+ if (hovered !== gesture.hovered) {
1226
+ gesture.hovered = hovered;
1227
+ haptic();
1228
+ }
1229
+ };
1230
+ const finish = (event, commit) => {
1231
+ if (event.pointerId !== gesture?.id) return;
1232
+ const { moved, box } = gesture;
1233
+ const at = moved ? position(event.clientX) : gesture.anchor;
1234
+ const index = clamp(Math.round(at / slot), 0, latest.current.count - 1);
1235
+ gesture = null;
1236
+ delete lens.dataset.pressed;
1237
+ if (bar.hasPointerCapture?.(event.pointerId)) bar.releasePointerCapture(event.pointerId);
1238
+ const inside = event.clientY >= box.top - 30 && event.clientY <= box.bottom + 30;
1239
+ lift.tune(SPRINGS.settle);
1240
+ lift.set(0);
1241
+ swell.tune(SPRINGS.release);
1242
+ swell.set(0);
1243
+ x.tune(SPRINGS.snap);
1244
+ if (commit && (moved || inside)) {
1245
+ suppressClick = true;
1246
+ current = index;
1247
+ x.set(index * slot);
1248
+ if (index !== latest.current.index) latest.current.onSelect(index);
1249
+ } else {
1250
+ x.set(current * slot);
1251
+ }
1252
+ };
1253
+ const onUp = (event) => finish(event, true);
1254
+ const onCancel = (event) => finish(event, false);
1255
+ const onClick = (event) => {
1256
+ if (suppressClick && event.detail !== 0) {
1257
+ suppressClick = false;
1258
+ event.preventDefault();
1259
+ event.stopPropagation();
1260
+ return;
1261
+ }
1262
+ const target = event.target.closest("[data-lg-item]");
1263
+ if (!target) return;
1264
+ const index = Number(target.dataset.lgItem);
1265
+ if (index !== latest.current.index) latest.current.onSelect(index);
1266
+ };
1267
+ const onKey = (event) => {
1268
+ const keys = ["ArrowLeft", "ArrowRight", "Home", "End"];
1269
+ if (!keys.includes(event.key)) return;
1270
+ event.preventDefault();
1271
+ const { count, index } = latest.current;
1272
+ const next = event.key === "Home" ? 0 : event.key === "End" ? count - 1 : (index + (event.key === "ArrowRight" ? 1 : count - 1)) % count;
1273
+ latest.current.onSelect(next);
1274
+ bar.querySelector(`[data-lg-item="${next}"]`)?.focus();
1275
+ };
1276
+ const onTouchMove = (event) => {
1277
+ if (gesture?.moved && event.cancelable) event.preventDefault();
1278
+ };
1279
+ const observer = new ResizeObserver(() => {
1280
+ measure();
1281
+ if (!gesture) x.set(current * slot, true);
1282
+ });
1283
+ measure();
1284
+ x.set(current * slot, true);
1285
+ bar.dataset.ready = "";
1286
+ observer.observe(bar);
1287
+ bar.addEventListener("pointerdown", onDown);
1288
+ window.addEventListener("pointermove", onMove);
1289
+ window.addEventListener("pointerup", onUp);
1290
+ window.addEventListener("pointercancel", onCancel);
1291
+ bar.addEventListener("click", onClick, true);
1292
+ bar.addEventListener("keydown", onKey);
1293
+ bar.addEventListener("touchmove", onTouchMove, { passive: false });
1294
+ api.current = { setIndex: place };
1295
+ return () => {
1296
+ api.current = null;
1297
+ [x, lift, swell].forEach((s) => s.stop());
1298
+ observer.disconnect();
1299
+ bar.removeEventListener("pointerdown", onDown);
1300
+ window.removeEventListener("pointermove", onMove);
1301
+ window.removeEventListener("pointerup", onUp);
1302
+ window.removeEventListener("pointercancel", onCancel);
1303
+ bar.removeEventListener("click", onClick, true);
1304
+ bar.removeEventListener("keydown", onKey);
1305
+ bar.removeEventListener("touchmove", onTouchMove);
1306
+ delete bar.dataset.ready;
1307
+ delete bar.dataset.lifted;
1308
+ };
1309
+ }, [options.count]);
1310
+ (0, import_react7.useEffect)(() => {
1311
+ api.current?.setIndex(options.index);
1312
+ }, [options.index]);
1313
+ }
1314
+
1315
+ // src/components/internal/LensTrack.tsx
1316
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1317
+ function LensTrack({
1318
+ items,
1319
+ labels,
1320
+ index,
1321
+ onChange,
1322
+ variant,
1323
+ intensity = 5,
1324
+ className,
1325
+ style,
1326
+ "aria-label": ariaLabel
1327
+ }) {
1328
+ const bar = (0, import_react8.useRef)(null);
1329
+ const glass = (0, import_react8.useRef)(null);
1330
+ const lens = (0, import_react8.useRef)(null);
1331
+ const tint = (0, import_react8.useRef)(null);
1332
+ const row = (0, import_react8.useRef)(null);
1333
+ const strength = Math.max(1, Math.min(10, intensity)) / 5;
1334
+ useRefraction(glass, { kind: "surface", strength });
1335
+ useRefraction(lens, { kind: "lens", strength, zoom: variant === "tabbar" ? 1.14 : 1.1 }, true, bar);
1336
+ const tabbar = variant === "tabbar";
1337
+ useLensTrack(
1338
+ { bar, glass, lens, tint, row },
1339
+ {
1340
+ count: items.length,
1341
+ index,
1342
+ onSelect: (next) => onChange?.(next),
1343
+ overhang: tabbar ? 8 : 14,
1344
+ spread: tabbar ? 0.22 : 0.3,
1345
+ swell: tabbar ? 10 : 22
501
1346
  }
502
- return vars;
503
- }, [clampedIntensity, tint]);
504
- const freq1 = 0.012 + clampedIntensity * 1e-3;
505
- const freq2 = 0.01 + clampedIntensity * 8e-4;
506
- const scale = clampedIntensity * 2;
507
- if (!mounted) return null;
1347
+ );
508
1348
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
509
1349
  "div",
510
1350
  {
511
- className: `lg-sheet-overlay${visible ? " lg-sheet-overlay--visible" : ""}`,
512
- onTransitionEnd: handleTransitionEnd,
513
- role: "dialog",
514
- "aria-modal": "true",
1351
+ ref: bar,
1352
+ role: "tablist",
1353
+ "aria-label": ariaLabel,
1354
+ className: ["lg-track", `lg-track--${variant}`, className].filter(Boolean).join(" "),
1355
+ "data-liquid-glass": "",
1356
+ style: { ...style, "--lg-count": items.length, "--lg-index": index },
515
1357
  children: [
516
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet-backdrop", onClick: onClose, "aria-hidden": "true" }),
517
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
518
- "div",
1358
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ref: glass, className: "lg-glass lg-track__glass", "aria-hidden": "true" }),
1359
+ items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1360
+ "button",
519
1361
  {
520
- ref: sheetRef,
521
- className: `lg-root lg-sheet${visible ? " lg-sheet--visible" : ""}`,
522
- "data-liquid-glass": true,
523
- style: glassStyle,
524
- children: [
525
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
526
- "svg",
527
- {
528
- width: "0",
529
- height: "0",
530
- style: { position: "absolute", pointerEvents: "none" },
531
- "aria-hidden": "true",
532
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
533
- "filter",
534
- {
535
- id: `liquid-glass-refract-${clampedIntensity}`,
536
- x: "-10%",
537
- y: "-10%",
538
- width: "120%",
539
- height: "120%",
540
- colorInterpolationFilters: "sRGB",
541
- children: [
542
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
543
- "feTurbulence",
544
- {
545
- type: "fractalNoise",
546
- baseFrequency: `${freq1} ${freq2}`,
547
- numOctaves: 3,
548
- seed: 42,
549
- result: "noise"
550
- }
551
- ),
552
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
553
- "feDisplacementMap",
554
- {
555
- in: "SourceGraphic",
556
- in2: "noise",
557
- scale,
558
- xChannelSelector: "R",
559
- yChannelSelector: "G"
560
- }
561
- )
562
- ]
563
- }
564
- ) })
565
- }
566
- ),
567
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "lg-surface lg-sheet__surface", children: [
568
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-sheet__handle", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-sheet__handle-bar" }) }),
569
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-content lg-sheet__content", children })
570
- ] }),
571
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-backdrop-surface lg-sheet__backdrop-surface", "aria-hidden": "true" }),
572
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg-shadow lg-sheet__shadow", "aria-hidden": "true" })
573
- ]
574
- }
575
- )
1362
+ type: "button",
1363
+ role: "tab",
1364
+ "data-lg-item": i,
1365
+ "aria-selected": i === index,
1366
+ "aria-label": labels[i],
1367
+ tabIndex: i === index ? 0 : -1,
1368
+ className: "lg-track__item",
1369
+ children: item
1370
+ },
1371
+ i
1372
+ )),
1373
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ref: tint, className: "lg-track__tint", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ref: row, className: "lg-track__row", children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-track__copy", children: item }, i)) }) }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { ref: lens, className: "lg-glass lg-track__lens", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lg-track__pill" }) })
576
1375
  ]
577
1376
  }
578
1377
  );
579
- };
580
- GlassSheet.displayName = "GlassSheet";
1378
+ }
581
1379
 
582
1380
  // src/components/GlassNav/GlassNav.tsx
583
- var import_react6 = require("react");
584
1381
  var import_jsx_runtime6 = require("react/jsx-runtime");
585
- var useIsomorphicLayoutEffect = typeof window === "undefined" ? import_react6.useEffect : import_react6.useLayoutEffect;
586
1382
  var GlassNav = ({
587
1383
  items,
588
1384
  activeIndex = 0,
589
1385
  onChange,
590
- intensity = 5
1386
+ intensity = 5,
1387
+ className,
1388
+ style,
1389
+ "aria-label": ariaLabel = "Tabs"
591
1390
  }) => {
592
- const navRef = (0, import_react6.useRef)(null);
593
- const itemRefs = (0, import_react6.useRef)([]);
594
- const isFilterMounted = useGlassFilterMounted();
595
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
596
- const [indicatorStyle, setIndicatorStyle] = (0, import_react6.useState)({});
597
- const updateIndicator = (0, import_react6.useCallback)(() => {
598
- const el = itemRefs.current[activeIndex];
599
- const parent = navRef.current;
600
- const surface = parent?.parentElement;
601
- if (!el || !parent || !surface) return;
602
- const surfaceRect = surface.getBoundingClientRect();
603
- const rect = el.getBoundingClientRect();
604
- setIndicatorStyle({
605
- width: `${rect.width}px`,
606
- height: `${rect.height}px`,
607
- transform: `translateX(${rect.left - surfaceRect.left}px)`
608
- });
609
- }, [activeIndex]);
610
- useIsomorphicLayoutEffect(() => {
611
- updateIndicator();
612
- window.addEventListener("resize", updateIndicator);
613
- return () => window.removeEventListener("resize", updateIndicator);
614
- }, [updateIndicator, items.length]);
615
- const glassStyle = (0, import_react6.useMemo)(() => {
616
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
617
- return {
618
- "--glass-blur": `${clampedIntensity * 2.4}px`,
619
- "--glass-border-width": "1px",
620
- "--glass-refraction-filter": `url(#${filterId})`
621
- };
622
- }, [clampedIntensity]);
623
- const freq1 = 0.012 + clampedIntensity * 1e-3;
624
- const freq2 = 0.01 + clampedIntensity * 8e-4;
625
- const scale = clampedIntensity * 2;
626
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lg-root lg-nav", "data-liquid-glass": true, style: glassStyle, children: [
627
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
628
- "svg",
1391
+ const hasIcons = items.some((item) => item.icon != null);
1392
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1393
+ LensTrack,
1394
+ {
1395
+ variant: "tabbar",
1396
+ className: ["lg-nav", hasIcons ? "" : "lg-track--labels-only", className].filter(Boolean).join(" "),
1397
+ style,
1398
+ "aria-label": ariaLabel,
1399
+ intensity,
1400
+ index: activeIndex,
1401
+ onChange,
1402
+ labels: items.map((item) => item.label),
1403
+ items: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react9.default.Fragment, { children: [
1404
+ item.icon != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
1405
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__label", children: item.label })
1406
+ ] }, i))
1407
+ }
1408
+ );
1409
+ };
1410
+ GlassNav.displayName = "GlassNav";
1411
+
1412
+ // src/components/GlassSegmented/GlassSegmented.tsx
1413
+ var import_react10 = __toESM(require("react"));
1414
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1415
+ var GlassSegmented = ({
1416
+ options,
1417
+ value,
1418
+ onChange,
1419
+ size = "md",
1420
+ intensity = 5,
1421
+ className,
1422
+ style,
1423
+ "aria-label": ariaLabel
1424
+ }) => {
1425
+ const normalized = options.map((option) => typeof option === "string" ? { label: option } : option);
1426
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1427
+ LensTrack,
1428
+ {
1429
+ variant: "segmented",
1430
+ className: [size === "sm" ? "lg-track--sm" : "", className].filter(Boolean).join(" "),
1431
+ style,
1432
+ "aria-label": ariaLabel,
1433
+ intensity,
1434
+ index: value,
1435
+ onChange,
1436
+ labels: normalized.map((option) => option.label),
1437
+ items: normalized.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react10.default.Fragment, { children: [
1438
+ option.icon,
1439
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: option.label })
1440
+ ] }, i))
1441
+ }
1442
+ );
1443
+ };
1444
+ GlassSegmented.displayName = "GlassSegmented";
1445
+
1446
+ // src/components/GlassSlider/GlassSlider.tsx
1447
+ var import_react11 = __toESM(require("react"));
1448
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1449
+ var GlassSlider = import_react11.default.forwardRef(
1450
+ ({
1451
+ value = 0,
1452
+ min = 0,
1453
+ max = 100,
1454
+ step: step2 = 1,
1455
+ intensity = 5,
1456
+ tint,
1457
+ shimmer: _shimmer,
1458
+ thickness: _thickness,
1459
+ showThumb = true,
1460
+ icon,
1461
+ label: label2,
1462
+ onChange,
1463
+ className,
1464
+ style,
1465
+ disabled,
1466
+ ...rest
1467
+ }, forwardedRef) => {
1468
+ const rootRef = (0, import_react11.useRef)(null);
1469
+ const inputRef = (0, import_react11.useRef)(null);
1470
+ const thumbRef = (0, import_react11.useRef)(null);
1471
+ const faceRef = (0, import_react11.useRef)(null);
1472
+ const blockRef = (0, import_react11.useRef)(null);
1473
+ (0, import_react11.useImperativeHandle)(forwardedRef, () => inputRef.current);
1474
+ const strength = Math.max(1, Math.min(10, intensity)) / 5;
1475
+ const progress = max > min ? clamp((Number(value) - min) / (max - min), 0, 1) : 0;
1476
+ useRefraction(thumbRef, { kind: "lens", zoom: 1.95, strength, dispersion: 0.6 }, showThumb, rootRef);
1477
+ useRefraction(blockRef, { kind: "surface", strength }, !showThumb);
1478
+ (0, import_react11.useEffect)(() => {
1479
+ if (!showThumb) return;
1480
+ const input2 = inputRef.current;
1481
+ const thumb = thumbRef.current;
1482
+ const face = faceRef.current;
1483
+ const root = rootRef.current;
1484
+ const v = { lift: 0, stretch: 0 };
1485
+ const paint = () => {
1486
+ const s = 0.655 + 0.345 * v.lift;
1487
+ thumb.style.scale = `${s * (1 + v.stretch)} ${s * (1 - v.stretch * 0.5)}`;
1488
+ face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
1489
+ root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
1490
+ };
1491
+ const lift = createSpring(0, SPRINGS.lift, (x) => {
1492
+ v.lift = x;
1493
+ paint();
1494
+ });
1495
+ const stretch = createSpring(0, SPRINGS.release, (x) => {
1496
+ v.stretch = x;
1497
+ paint();
1498
+ });
1499
+ paint();
1500
+ let lastX = 0;
1501
+ let lastT = 0;
1502
+ const down = (event) => {
1503
+ if (input2.disabled) return;
1504
+ lastX = event.clientX;
1505
+ lastT = event.timeStamp;
1506
+ lift.tune(SPRINGS.lift);
1507
+ lift.set(1);
1508
+ haptic();
1509
+ };
1510
+ const move = (event) => {
1511
+ if (lift.target !== 1) return;
1512
+ const dt = Math.max(1, event.timeStamp - lastT);
1513
+ const speed = Math.abs(event.clientX - lastX) / dt;
1514
+ lastX = event.clientX;
1515
+ lastT = event.timeStamp;
1516
+ stretch.tune(SPRINGS.drag);
1517
+ stretch.set(clamp(speed * 0.015, 0, 0.035));
1518
+ };
1519
+ const up = () => {
1520
+ if (lift.target === 0) return;
1521
+ lift.tune(SPRINGS.settle);
1522
+ lift.set(0);
1523
+ stretch.tune(SPRINGS.release);
1524
+ stretch.set(0);
1525
+ };
1526
+ input2.addEventListener("pointerdown", down);
1527
+ window.addEventListener("pointermove", move);
1528
+ window.addEventListener("pointerup", up);
1529
+ window.addEventListener("pointercancel", up);
1530
+ input2.addEventListener("blur", up);
1531
+ return () => {
1532
+ lift.stop();
1533
+ stretch.stop();
1534
+ input2.removeEventListener("pointerdown", down);
1535
+ window.removeEventListener("pointermove", move);
1536
+ window.removeEventListener("pointerup", up);
1537
+ window.removeEventListener("pointercancel", up);
1538
+ input2.removeEventListener("blur", up);
1539
+ };
1540
+ }, [showThumb]);
1541
+ (0, import_react11.useEffect)(() => {
1542
+ if (showThumb) return;
1543
+ const input2 = inputRef.current;
1544
+ const block = blockRef.current;
1545
+ const v = { swell: 0, over: 0 };
1546
+ const paint = () => {
1547
+ const w = block.offsetWidth || 1;
1548
+ const grow = 1 + 10 / Math.max(w, 1) * v.swell;
1549
+ const stretchX = 1 + Math.abs(v.over) / w;
1550
+ block.style.scale = `${grow * stretchX} ${grow * (1 - Math.abs(v.over) / w / 2)}`;
1551
+ block.style.translate = `${v.over / 2}px 0`;
1552
+ };
1553
+ const swell = createSpring(0, SPRINGS.press, (x) => {
1554
+ v.swell = x;
1555
+ paint();
1556
+ });
1557
+ const over = createSpring(0, SPRINGS.release, (x) => {
1558
+ v.over = x;
1559
+ paint();
1560
+ });
1561
+ let active2 = null;
1562
+ const down = (event) => {
1563
+ if (input2.disabled) return;
1564
+ active2 = { id: event.pointerId, box: block.getBoundingClientRect() };
1565
+ swell.tune(SPRINGS.press);
1566
+ swell.set(1);
1567
+ haptic();
1568
+ };
1569
+ const move = (event) => {
1570
+ if (event.pointerId !== active2?.id) return;
1571
+ const { box } = active2;
1572
+ const past = event.clientX < box.left ? event.clientX - box.left : event.clientX > box.right ? event.clientX - box.right : 0;
1573
+ over.tune(SPRINGS.drag);
1574
+ over.set(rubberband(past, 26, 0.6));
1575
+ };
1576
+ const up = (event) => {
1577
+ if (event.pointerId !== active2?.id) return;
1578
+ active2 = null;
1579
+ swell.tune(SPRINGS.release);
1580
+ swell.set(0);
1581
+ over.tune(SPRINGS.release);
1582
+ over.set(0);
1583
+ };
1584
+ input2.addEventListener("pointerdown", down);
1585
+ window.addEventListener("pointermove", move);
1586
+ window.addEventListener("pointerup", up);
1587
+ window.addEventListener("pointercancel", up);
1588
+ return () => {
1589
+ swell.stop();
1590
+ over.stop();
1591
+ input2.removeEventListener("pointerdown", down);
1592
+ window.removeEventListener("pointermove", move);
1593
+ window.removeEventListener("pointerup", up);
1594
+ window.removeEventListener("pointercancel", up);
1595
+ };
1596
+ }, [showThumb]);
1597
+ const input = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1598
+ "input",
1599
+ {
1600
+ ref: inputRef,
1601
+ type: "range",
1602
+ min,
1603
+ max,
1604
+ step: step2,
1605
+ value,
1606
+ disabled,
1607
+ "aria-label": rest["aria-label"] ?? label2,
1608
+ onChange: (event) => onChange?.(Number(event.currentTarget.value)),
1609
+ onKeyDown: () => rootRef.current?.setAttribute("data-keyboard", ""),
1610
+ onPointerDown: () => rootRef.current?.removeAttribute("data-keyboard"),
1611
+ className: "lg-slider__input",
1612
+ ...rest
1613
+ }
1614
+ );
1615
+ const vars = { "--lg-progress": progress, ...tint ? { "--lg-slider-fill": tint } : {}, ...style };
1616
+ if (!showThumb) {
1617
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1618
+ "div",
1619
+ {
1620
+ ref: rootRef,
1621
+ className: ["lg-slider", "lg-slider--block", className].filter(Boolean).join(" "),
1622
+ "data-liquid-glass": "",
1623
+ style: vars,
1624
+ children: [
1625
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: blockRef, className: "lg-glass lg-slider__block", children: [
1626
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "lg-slider__block-content", "aria-hidden": "true", children: [
1627
+ icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__icon", children: icon }),
1628
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__label", children: label2 }),
1629
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__value", children: Number(value) })
1630
+ ] }),
1631
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__block-fill", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "lg-slider__block-content lg-slider__block-content--lit", children: [
1632
+ icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__icon", children: icon }),
1633
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__label", children: label2 }),
1634
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__value", children: Number(value) })
1635
+ ] }) })
1636
+ ] }),
1637
+ input
1638
+ ]
1639
+ }
1640
+ );
1641
+ }
1642
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rootRef, className: ["lg-slider", className].filter(Boolean).join(" "), "data-liquid-glass": "", style: vars, children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__rail", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__fill" }) }),
1644
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "lg-slider__thumb-slot", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { ref: thumbRef, className: "lg-glass lg-slider__thumb", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { ref: faceRef, className: "lg-slider__face" }) }) }),
1645
+ input
1646
+ ] });
1647
+ }
1648
+ );
1649
+ GlassSlider.displayName = "GlassSlider";
1650
+
1651
+ // src/components/GlassSwitch/GlassSwitch.tsx
1652
+ var import_react12 = __toESM(require("react"));
1653
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1654
+ var REST = 0.655;
1655
+ var TRAVEL = 22;
1656
+ var GlassSwitch = import_react12.default.forwardRef(
1657
+ ({ checked: checkedProp, defaultChecked = false, onChange, tint, intensity = 5, className, style, disabled, ...rest }, forwardedRef) => {
1658
+ const ref = (0, import_react12.useRef)(null);
1659
+ const thumbRef = (0, import_react12.useRef)(null);
1660
+ const fillRef = (0, import_react12.useRef)(null);
1661
+ const faceRef = (0, import_react12.useRef)(null);
1662
+ (0, import_react12.useImperativeHandle)(forwardedRef, () => ref.current);
1663
+ const [inner, setInner] = (0, import_react12.useState)(defaultChecked);
1664
+ const controlled = checkedProp !== void 0;
1665
+ const checked = controlled ? checkedProp : inner;
1666
+ const latest = (0, import_react12.useRef)({ checked, set: (_) => {
1667
+ }, disabled });
1668
+ latest.current = {
1669
+ checked,
1670
+ disabled,
1671
+ set: (next) => {
1672
+ if (!controlled) setInner(next);
1673
+ onChange?.(next);
1674
+ }
1675
+ };
1676
+ const sync = (0, import_react12.useRef)(null);
1677
+ useRefraction(thumbRef, { kind: "lens", zoom: 1.45, strength: Math.max(1, Math.min(10, intensity)) / 5 }, true, ref);
1678
+ (0, import_react12.useEffect)(() => {
1679
+ const el2 = ref.current;
1680
+ const thumb = thumbRef.current;
1681
+ const fill = fillRef.current;
1682
+ const face = faceRef.current;
1683
+ const v = { x: checked ? 1 : 0, lift: 0, stretch: 0 };
1684
+ const paint = () => {
1685
+ const s = REST + (1 - REST) * v.lift;
1686
+ const sx = s * (1 + v.stretch);
1687
+ const sy = s * (1 - v.stretch * 0.5);
1688
+ thumb.style.transform = `translate(${v.x * TRAVEL}px, -50%) scale(${sx}, ${sy})`;
1689
+ const l = clamp(v.lift, 0, 1);
1690
+ face.style.opacity = String(1 - l * 0.92);
1691
+ el2.style.setProperty("--lg-lift", String(l));
1692
+ };
1693
+ const position = createSpring(v.x, SPRINGS.snap, (value, velocity) => {
1694
+ v.x = value;
1695
+ v.stretch = clamp(Math.abs(velocity) / 40, 0, 0.14);
1696
+ paint();
1697
+ });
1698
+ const lift = createSpring(0, SPRINGS.lift, (value) => {
1699
+ v.lift = value;
1700
+ paint();
1701
+ });
1702
+ const color = createSpring(checked ? 1 : 0, SPRINGS.fade, (value) => {
1703
+ fill.style.opacity = String(clamp(value, 0, 1));
1704
+ });
1705
+ fill.style.opacity = checked ? "1" : "0";
1706
+ paint();
1707
+ sync.current = (value) => {
1708
+ position.tune(SPRINGS.snap);
1709
+ position.set(value ? 1 : 0);
1710
+ color.set(value ? 1 : 0);
1711
+ };
1712
+ let gesture = null;
1713
+ let dropTimer = 0;
1714
+ let ignoreClick = false;
1715
+ const drop = (delay) => {
1716
+ clearTimeout(dropTimer);
1717
+ dropTimer = window.setTimeout(() => {
1718
+ lift.tune(SPRINGS.settle);
1719
+ lift.set(0);
1720
+ }, delay);
1721
+ };
1722
+ const down = (event) => {
1723
+ if (!event.isPrimary || event.button !== 0 || latest.current.disabled) return;
1724
+ clearTimeout(dropTimer);
1725
+ gesture = { id: event.pointerId, x: event.clientX, from: latest.current.checked ? 1 : 0, moved: false, at: performance.now() };
1726
+ try {
1727
+ el2.setPointerCapture(event.pointerId);
1728
+ } catch {
1729
+ }
1730
+ lift.tune(SPRINGS.lift);
1731
+ lift.set(1);
1732
+ haptic();
1733
+ };
1734
+ const move = (event) => {
1735
+ if (event.pointerId !== gesture?.id) return;
1736
+ const dx = event.clientX - gesture.x;
1737
+ if (!gesture.moved && Math.abs(dx) < 3) return;
1738
+ gesture.moved = true;
1739
+ const raw = gesture.from + dx / TRAVEL;
1740
+ const over = raw < 0 ? rubberband(raw * TRAVEL, TRAVEL, 0.6) / TRAVEL : raw > 1 ? 1 + rubberband((raw - 1) * TRAVEL, TRAVEL, 0.6) / TRAVEL : raw;
1741
+ position.tune(SPRINGS.drag);
1742
+ position.set(over);
1743
+ const on = raw > 0.5;
1744
+ if (color.target === 1 !== on) haptic();
1745
+ color.set(on ? 1 : 0);
1746
+ };
1747
+ const up = (event) => {
1748
+ if (event.pointerId !== gesture?.id) return;
1749
+ const { from, x, moved, at } = gesture;
1750
+ gesture = null;
1751
+ ignoreClick = true;
1752
+ const next = moved ? from + (event.clientX - x) / TRAVEL > 0.5 : !latest.current.checked;
1753
+ position.tune(SPRINGS.snap);
1754
+ position.set(next ? 1 : 0);
1755
+ color.set(next ? 1 : 0);
1756
+ if (next !== latest.current.checked) latest.current.set(next);
1757
+ drop(moved ? 0 : Math.max(0, 200 - (performance.now() - at)));
1758
+ };
1759
+ const cancel = (event) => {
1760
+ if (event.pointerId !== gesture?.id) return;
1761
+ gesture = null;
1762
+ sync.current?.(latest.current.checked);
1763
+ drop(0);
1764
+ };
1765
+ const click = (event) => {
1766
+ if (ignoreClick) {
1767
+ ignoreClick = false;
1768
+ return;
1769
+ }
1770
+ if (latest.current.disabled) return;
1771
+ event.preventDefault();
1772
+ const next = !latest.current.checked;
1773
+ lift.set(1);
1774
+ drop(220);
1775
+ latest.current.set(next);
1776
+ sync.current?.(next);
1777
+ };
1778
+ el2.addEventListener("pointerdown", down);
1779
+ el2.addEventListener("pointermove", move);
1780
+ el2.addEventListener("pointerup", up);
1781
+ el2.addEventListener("pointercancel", cancel);
1782
+ el2.addEventListener("click", click);
1783
+ return () => {
1784
+ clearTimeout(dropTimer);
1785
+ [position, lift, color].forEach((s) => s.stop());
1786
+ el2.removeEventListener("pointerdown", down);
1787
+ el2.removeEventListener("pointermove", move);
1788
+ el2.removeEventListener("pointerup", up);
1789
+ el2.removeEventListener("pointercancel", cancel);
1790
+ el2.removeEventListener("click", click);
1791
+ };
1792
+ }, []);
1793
+ (0, import_react12.useEffect)(() => {
1794
+ sync.current?.(checked);
1795
+ }, [checked]);
1796
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1797
+ "button",
629
1798
  {
630
- width: "0",
631
- height: "0",
632
- style: { position: "absolute", pointerEvents: "none" },
633
- "aria-hidden": "true",
634
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1799
+ ref,
1800
+ type: "button",
1801
+ role: "switch",
1802
+ "aria-checked": checked,
1803
+ disabled,
1804
+ className: ["lg-switch", className].filter(Boolean).join(" "),
1805
+ "data-liquid-glass": "",
1806
+ style: tint ? { "--lg-switch-on": tint, ...style } : style,
1807
+ ...rest,
1808
+ children: [
1809
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref: fillRef, className: "lg-switch__fill", "aria-hidden": "true" }),
1810
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref: thumbRef, className: "lg-glass lg-switch__thumb", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref: faceRef, className: "lg-switch__face" }) })
1811
+ ]
1812
+ }
1813
+ );
1814
+ }
1815
+ );
1816
+ GlassSwitch.displayName = "GlassSwitch";
1817
+
1818
+ // src/filters/LiquidGlassFilter.tsx
1819
+ var import_react13 = require("react");
1820
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1821
+ var GlassFilterContext = (0, import_react13.createContext)(false);
1822
+ function LiquidGlassFilter({ children }) {
1823
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(GlassFilterContext.Provider, { value: true, children: [
1824
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GlassFilterSVG, {}),
1825
+ children
1826
+ ] });
1827
+ }
1828
+ function GlassFilterSVG() {
1829
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1830
+ "svg",
1831
+ {
1832
+ width: "0",
1833
+ height: "0",
1834
+ style: { position: "absolute", pointerEvents: "none" },
1835
+ "aria-hidden": "true",
1836
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("defs", { children: Array.from({ length: 10 }, (_, i) => {
1837
+ const level = i + 1;
1838
+ const scale = level * 2;
1839
+ const freq1 = 0.012 + level * 1e-3;
1840
+ const freq2 = 0.01 + level * 8e-4;
1841
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
635
1842
  "filter",
636
1843
  {
637
- id: `liquid-glass-refract-${clampedIntensity}`,
1844
+ id: `liquid-glass-refract-${level}`,
638
1845
  x: "-10%",
639
1846
  y: "-10%",
640
1847
  width: "120%",
641
1848
  height: "120%",
642
1849
  colorInterpolationFilters: "sRGB",
643
1850
  children: [
644
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1851
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
645
1852
  "feTurbulence",
646
1853
  {
647
1854
  type: "fractalNoise",
@@ -651,7 +1858,7 @@ var GlassNav = ({
651
1858
  result: "noise"
652
1859
  }
653
1860
  ),
654
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1861
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
655
1862
  "feDisplacementMap",
656
1863
  {
657
1864
  in: "SourceGraphic",
@@ -662,169 +1869,16 @@ var GlassNav = ({
662
1869
  }
663
1870
  )
664
1871
  ]
665
- }
666
- ) })
667
- }
668
- ),
669
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "lg-surface lg-nav__surface", children: [
670
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-nav__indicator", style: indicatorStyle, "aria-hidden": "true" }),
671
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("nav", { ref: navRef, className: "lg-content lg-nav__content", role: "tablist", children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
672
- "button",
673
- {
674
- ref: (el) => {
675
- itemRefs.current[i] = el;
676
1872
  },
677
- role: "tab",
678
- "aria-selected": i === activeIndex,
679
- className: `lg-nav__item${i === activeIndex ? " lg-nav__item--active" : ""}`,
680
- onClick: () => onChange?.(i),
681
- type: "button",
682
- children: [
683
- item.icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__icon", children: item.icon }),
684
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "lg-nav__label", children: item.label })
685
- ]
686
- },
687
- i
688
- )) })
689
- ] }),
690
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-backdrop-surface lg-nav__backdrop-surface", "aria-hidden": "true" }),
691
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" })
692
- ] });
693
- };
694
- GlassNav.displayName = "GlassNav";
695
-
696
- // src/components/GlassSlider/GlassSlider.tsx
697
- var import_react7 = __toESM(require("react"));
698
- var import_jsx_runtime7 = require("react/jsx-runtime");
699
- var GlassSlider = import_react7.default.forwardRef(
700
- ({
701
- intensity = 5,
702
- tint,
703
- shimmer = true,
704
- thickness = 1,
705
- showThumb = true,
706
- icon,
707
- label,
708
- value = 0,
709
- min = 0,
710
- max = 100,
711
- onChange,
712
- className,
713
- style,
714
- ...rest
715
- }, ref) => {
716
- const isFilterMounted = useGlassFilterMounted();
717
- const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
718
- const numValue = Number(value);
719
- const numMin = Number(min);
720
- const numMax = Number(max);
721
- const percentage = numMax > numMin ? (numValue - numMin) / (numMax - numMin) * 100 : 0;
722
- const ratio = numMax > numMin ? (numValue - numMin) / (numMax - numMin) : 0;
723
- const glassStyle = (0, import_react7.useMemo)(() => {
724
- const filterId = `liquid-glass-refract-${clampedIntensity}`;
725
- const vars = {
726
- "--glass-blur": `${clampedIntensity * 2.4}px`,
727
- "--glass-border-width": `${thickness}px`,
728
- "--glass-refraction-filter": `url(#${filterId})`,
729
- "--slider-percentage": `${percentage}%`,
730
- "--slider-ratio": ratio
731
- };
732
- if (tint) {
733
- vars["--glass-tint"] = tint;
734
- }
735
- return vars;
736
- }, [clampedIntensity, tint, thickness, percentage, ratio]);
737
- const rootClasses = [
738
- "lg-root",
739
- "lg-slider",
740
- shimmer ? "lg-slider--shimmer" : "",
741
- showThumb ? "lg-slider--with-thumb" : "lg-slider--no-thumb",
742
- className ?? ""
743
- ].filter(Boolean).join(" ");
744
- const handleChange = (e) => {
745
- if (onChange) {
746
- onChange(Number(e.target.value));
747
- }
748
- };
749
- const freq1 = 0.012 + clampedIntensity * 1e-3;
750
- const freq2 = 0.01 + clampedIntensity * 8e-4;
751
- const scale = clampedIntensity * 2;
752
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: rootClasses, "data-liquid-glass": true, style: { ...glassStyle, ...style }, children: [
753
- !isFilterMounted && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
754
- "svg",
755
- {
756
- width: "0",
757
- height: "0",
758
- style: { position: "absolute", pointerEvents: "none" },
759
- "aria-hidden": "true",
760
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
761
- "filter",
762
- {
763
- id: `liquid-glass-refract-${clampedIntensity}`,
764
- x: "-10%",
765
- y: "-10%",
766
- width: "120%",
767
- height: "120%",
768
- colorInterpolationFilters: "sRGB",
769
- children: [
770
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
771
- "feTurbulence",
772
- {
773
- type: "fractalNoise",
774
- baseFrequency: `${freq1} ${freq2}`,
775
- numOctaves: 3,
776
- seed: 42,
777
- result: "noise"
778
- }
779
- ),
780
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
781
- "feDisplacementMap",
782
- {
783
- in: "SourceGraphic",
784
- in2: "noise",
785
- scale,
786
- xChannelSelector: "R",
787
- yChannelSelector: "G"
788
- }
789
- )
790
- ]
791
- }
792
- ) })
793
- }
794
- ),
795
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "lg-slider-track", children: [
796
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-backdrop-surface", "aria-hidden": "true" }),
797
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { position: "absolute", inset: 0, overflow: "hidden", borderRadius: "inherit", zIndex: 2, pointerEvents: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-slider-fill", "aria-hidden": "true" }) }),
798
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-shadow", "aria-hidden": "true" }),
799
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "lg-slider-content", children: [
800
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
801
- icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-icon", children: icon }),
802
- label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-label", children: label })
803
- ] }),
804
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "lg-slider-value-text", children: numValue })
805
- ] }),
806
- showThumb && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "lg-slider-thumb", "aria-hidden": "true" }),
807
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
808
- "input",
809
- {
810
- type: "range",
811
- ref,
812
- min,
813
- max,
814
- value,
815
- onChange: handleChange,
816
- className: "lg-slider-input",
817
- ...rest
818
- }
819
- )
820
- ] })
821
- ] });
822
- }
823
- );
824
- GlassSlider.displayName = "GlassSlider";
1873
+ level
1874
+ );
1875
+ }) })
1876
+ }
1877
+ );
1878
+ }
825
1879
 
826
1880
  // src/hooks/useGlassEffect.ts
827
- var import_react8 = require("react");
1881
+ var import_react14 = require("react");
828
1882
  function parseTintColor(tint) {
829
1883
  const defaults = { h: 0, s: 0, l: 100, a: 0.1 };
830
1884
  if (!tint) return defaults;
@@ -876,7 +1930,7 @@ function useGlassEffect(options = {}) {
876
1930
  thickness,
877
1931
  blur
878
1932
  } = options;
879
- return (0, import_react8.useMemo)(() => {
1933
+ return (0, import_react14.useMemo)(() => {
880
1934
  const clampedIntensity = Math.max(1, Math.min(10, Math.round(intensity)));
881
1935
  const filterId = `liquid-glass-refract-${clampedIntensity}`;
882
1936
  const style = {
@@ -901,21 +1955,21 @@ function useGlassEffect(options = {}) {
901
1955
  }
902
1956
 
903
1957
  // src/hooks/useGlassAnimation.ts
904
- var import_react9 = require("react");
1958
+ var import_react15 = require("react");
905
1959
  function useGlassAnimation() {
906
- const [isHovered, setIsHovered] = (0, import_react9.useState)(false);
907
- const [isPressed, setIsPressed] = (0, import_react9.useState)(false);
908
- const [isFocused, setIsFocused] = (0, import_react9.useState)(false);
1960
+ const [isHovered, setIsHovered] = (0, import_react15.useState)(false);
1961
+ const [isPressed, setIsPressed] = (0, import_react15.useState)(false);
1962
+ const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
909
1963
  const handlers = {
910
- onPointerEnter: (0, import_react9.useCallback)(() => setIsHovered(true), []),
911
- onPointerLeave: (0, import_react9.useCallback)(() => {
1964
+ onPointerEnter: (0, import_react15.useCallback)(() => setIsHovered(true), []),
1965
+ onPointerLeave: (0, import_react15.useCallback)(() => {
912
1966
  setIsHovered(false);
913
1967
  setIsPressed(false);
914
1968
  }, []),
915
- onPointerDown: (0, import_react9.useCallback)(() => setIsPressed(true), []),
916
- onPointerUp: (0, import_react9.useCallback)(() => setIsPressed(false), []),
917
- onFocus: (0, import_react9.useCallback)(() => setIsFocused(true), []),
918
- onBlur: (0, import_react9.useCallback)(() => setIsFocused(false), [])
1969
+ onPointerDown: (0, import_react15.useCallback)(() => setIsPressed(true), []),
1970
+ onPointerUp: (0, import_react15.useCallback)(() => setIsPressed(false), []),
1971
+ onFocus: (0, import_react15.useCallback)(() => setIsFocused(true), []),
1972
+ onBlur: (0, import_react15.useCallback)(() => setIsFocused(false), [])
919
1973
  };
920
1974
  return { isHovered, isPressed, isFocused, handlers };
921
1975
  }
@@ -925,10 +1979,19 @@ function useGlassAnimation() {
925
1979
  GlassCard,
926
1980
  GlassInput,
927
1981
  GlassNav,
1982
+ GlassSegmented,
928
1983
  GlassSheet,
929
1984
  GlassSlider,
1985
+ GlassSwitch,
930
1986
  LiquidGlassFilter,
1987
+ SPRINGS,
1988
+ canRefractBackdrop,
1989
+ createSpring,
1990
+ haptic,
1991
+ springFrom,
931
1992
  useGlassAnimation,
932
- useGlassEffect
1993
+ useGlassEffect,
1994
+ usePress,
1995
+ useRefraction
933
1996
  });
934
1997
  //# sourceMappingURL=index.js.map