@pieai/swimmer-ui-kit 3.0.0 → 3.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.
@@ -0,0 +1,923 @@
1
+ "use client";
2
+ import { a as e, s as t, t as n, v as r, y as i } from "./LiquidGroup-RTK_Uvgw.js";
3
+ import { createElement as a, forwardRef as o, useCallback as s, useEffect as c, useId as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
4
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ //#region src/liquid/forms.ts
6
+ var _ = {
7
+ set: {
8
+ kind: "body",
9
+ summary: "A liquid body firms up and stops being liquid.",
10
+ group: r,
11
+ groupEngaged: {
12
+ blur: 0,
13
+ blob: 0,
14
+ gloss: 0
15
+ },
16
+ item: {
17
+ effect: "morph",
18
+ morph: {
19
+ shape: !0,
20
+ speed: 1.2,
21
+ bounce: .12,
22
+ contentBlur: 0
23
+ },
24
+ transition: "snappy"
25
+ }
26
+ },
27
+ press: {
28
+ kind: "body",
29
+ summary: "A control that squashes under a press and rebounds past its rest shape.",
30
+ group: r,
31
+ item: {
32
+ effect: "morph",
33
+ morph: {
34
+ shape: !0,
35
+ speed: 1,
36
+ bounce: .35,
37
+ contentBlur: 0
38
+ },
39
+ transition: "wobbly"
40
+ }
41
+ },
42
+ swell: {
43
+ kind: "body",
44
+ summary: "A body grows to be noticed, without being touched.",
45
+ group: r,
46
+ item: {
47
+ effect: "morph",
48
+ morph: {
49
+ shape: !0,
50
+ speed: .7,
51
+ bounce: .4,
52
+ contentBlur: 0
53
+ },
54
+ transition: "wobbly"
55
+ }
56
+ },
57
+ settle: {
58
+ kind: "body",
59
+ summary: "Something arrives, overshoots, and comes to rest.",
60
+ group: r,
61
+ item: {
62
+ effect: "morph",
63
+ morph: {
64
+ shape: !0,
65
+ speed: .9,
66
+ bounce: .55,
67
+ contentBlur: 0
68
+ },
69
+ transition: "wobbly"
70
+ }
71
+ },
72
+ fill: {
73
+ kind: "body",
74
+ summary: "A level rises and holds, the way a poured liquid settles.",
75
+ group: r,
76
+ item: {
77
+ effect: "morph",
78
+ morph: {
79
+ shape: !0,
80
+ speed: .9,
81
+ bounce: .08,
82
+ contentBlur: 0
83
+ },
84
+ transition: "smooth"
85
+ }
86
+ },
87
+ reach: {
88
+ kind: "body",
89
+ summary: "A body stretches toward something and thins as it goes.",
90
+ group: r,
91
+ item: {
92
+ effect: "morph",
93
+ morph: {
94
+ shape: !0,
95
+ speed: 1,
96
+ bounce: .15,
97
+ contentBlur: 0
98
+ },
99
+ transition: "smooth"
100
+ }
101
+ },
102
+ ripple: {
103
+ kind: "body",
104
+ summary: "A shudder crosses the body and dies out, and nothing breaks.",
105
+ group: r,
106
+ item: {
107
+ effect: "morph",
108
+ morph: {
109
+ shape: !0,
110
+ speed: 1.6,
111
+ bounce: .5,
112
+ contentBlur: 0
113
+ },
114
+ transition: "wobbly"
115
+ }
116
+ },
117
+ drain: {
118
+ kind: "body",
119
+ summary: "A shape loses its boundary and goes.",
120
+ group: r,
121
+ item: { transition: "smooth" }
122
+ },
123
+ follow: {
124
+ kind: "group",
125
+ summary: "A single blob travels to whichever item is active.",
126
+ group: {
127
+ ...r,
128
+ blur: 6
129
+ },
130
+ item: {
131
+ effect: "morph",
132
+ morph: {
133
+ shape: !0,
134
+ speed: 1.1,
135
+ bounce: .15,
136
+ contentBlur: 0
137
+ },
138
+ transition: "smooth"
139
+ }
140
+ },
141
+ merge: {
142
+ kind: "group",
143
+ summary: "Neighbouring shapes reach for each other and fuse into one body.",
144
+ group: {
145
+ ...r,
146
+ blur: 10
147
+ },
148
+ item: {
149
+ effect: "morph",
150
+ morph: {
151
+ shape: !0,
152
+ speed: .8,
153
+ bounce: .2,
154
+ contentBlur: 0
155
+ },
156
+ transition: "smooth"
157
+ }
158
+ },
159
+ split: {
160
+ kind: "group",
161
+ summary: "One body pulls into two, and the neck between them thins and breaks.",
162
+ group: {
163
+ ...r,
164
+ blur: 10
165
+ },
166
+ item: {
167
+ effect: "morph",
168
+ morph: {
169
+ shape: !0,
170
+ speed: .9,
171
+ bounce: .3,
172
+ contentBlur: 0
173
+ },
174
+ transition: "smooth"
175
+ }
176
+ },
177
+ bead: {
178
+ kind: "group",
179
+ summary: "A scatter of small droplets that can find each other.",
180
+ group: {
181
+ ...r,
182
+ blur: 8
183
+ },
184
+ item: {
185
+ effect: "morph",
186
+ morph: {
187
+ shape: !0,
188
+ speed: 1,
189
+ bounce: .45,
190
+ contentBlur: 0
191
+ },
192
+ transition: "wobbly"
193
+ }
194
+ }
195
+ }, v = Object.keys(_);
196
+ function y(e, t) {
197
+ return {
198
+ ..._[e].group,
199
+ ...t
200
+ };
201
+ }
202
+ function b(e, t) {
203
+ let n = _[e].item;
204
+ return {
205
+ ...n,
206
+ ...t,
207
+ ...n.morph || t?.morph ? { morph: {
208
+ ...n.morph,
209
+ ...t?.morph
210
+ } } : {}
211
+ };
212
+ }
213
+ //#endregion
214
+ //#region src/liquid/LiquidSurface/LiquidSurface.tsx
215
+ var x = {
216
+ set: {
217
+ scale: .99,
218
+ scaleY: .99,
219
+ y: 0
220
+ },
221
+ press: {
222
+ scale: 1.06,
223
+ scaleY: .87,
224
+ y: 3
225
+ },
226
+ swell: {
227
+ scale: 1.07,
228
+ scaleY: 1.07,
229
+ y: 0
230
+ },
231
+ settle: {
232
+ scale: 1,
233
+ scaleY: 1,
234
+ y: 0
235
+ },
236
+ fill: {
237
+ scale: 1,
238
+ scaleY: 1,
239
+ y: 0
240
+ },
241
+ reach: {
242
+ scale: 1.26,
243
+ scaleY: .88,
244
+ x: 12,
245
+ y: 0
246
+ },
247
+ ripple: {
248
+ scale: 1.04,
249
+ scaleY: .96,
250
+ y: 0
251
+ },
252
+ drain: {
253
+ scale: 1.08,
254
+ scaleY: .84,
255
+ y: 4
256
+ },
257
+ follow: {
258
+ scale: 1,
259
+ scaleY: 1,
260
+ y: 0
261
+ },
262
+ merge: {
263
+ scale: 1,
264
+ scaleY: 1,
265
+ y: 0
266
+ },
267
+ split: {
268
+ scale: 1,
269
+ scaleY: 1,
270
+ y: 0
271
+ },
272
+ bead: {
273
+ scale: 1,
274
+ scaleY: 1,
275
+ y: 0
276
+ }
277
+ }, S = { settle: {
278
+ scale: .94,
279
+ scaleY: 1.08,
280
+ y: -8
281
+ } }, C = {
282
+ scale: 1.04,
283
+ scaleY: 1.04,
284
+ y: 0
285
+ }, w = 600, ee = {
286
+ duration: w,
287
+ ease: "ease-in-out"
288
+ };
289
+ function te(e, t, n) {
290
+ let [r, i] = p(!1), [a, o] = p(t), [s, l] = p(!1);
291
+ return a !== t && (o(t), a && l(!0)), c(() => {
292
+ if (!e) return;
293
+ let t = window.setInterval(() => i((e) => !e), w);
294
+ return () => window.clearInterval(t);
295
+ }, [e]), c(() => {
296
+ if (!s) return;
297
+ let e = window.setTimeout(() => l(!1), n);
298
+ return () => window.clearTimeout(e);
299
+ }, [s, n]), {
300
+ swollen: e && r,
301
+ rebounding: s
302
+ };
303
+ }
304
+ var T = /* @__PURE__ */ new Set();
305
+ function E(e) {
306
+ T.has(e) || (T.add(e), console.warn(`LiquidSurface cannot express the '${e}' form: it describes a relationship between sibling items, not one body. Arrange the items in a <LiquidGroup> with explicit group props instead; LiquidSurface will render a body that never moves.`));
307
+ }
308
+ function D({ children: r, form: i = "press", active: a = !1, breathing: o = !1, fill: s = "var(--game-ui-liquid-surface-fill, var(--game-ui-surface-raised))", stroke: c, shadow: l, gloss: u, outline: f, radius: p = 999, className: m, style: v }) {
309
+ let w = e(), T = a && !w, D = d(() => y(i, T ? _[i].groupEngaged : void 0), [i, T]), O = d(() => b(i), [i]);
310
+ _[i].kind === "group" && E(i);
311
+ let k = o && !T && !w, A = te(k, T, t(O.transition).duration), j = T ? x[i] : A.swollen ? C : S[i] ?? {
312
+ scale: 1,
313
+ scaleY: 1,
314
+ y: 0
315
+ }, M = k && !A.rebounding ? ee : O.transition, N = l ?? D.shadow, P = f ? {
316
+ amplitude: f.amplitude,
317
+ lobes: f.lobes ?? D.lobes
318
+ } : {
319
+ amplitude: D.blob,
320
+ lobes: D.lobes
321
+ };
322
+ return /* @__PURE__ */ g("span", {
323
+ className: ["game-ui-liquid-surface", m].filter(Boolean).join(" "),
324
+ "data-liquid-form": i,
325
+ "data-liquid-active": T ? "true" : "false",
326
+ "data-liquid-breathing": k ? "true" : void 0,
327
+ style: v,
328
+ children: [/* @__PURE__ */ h(n, {
329
+ "aria-hidden": "true",
330
+ blur: D.blur,
331
+ className: "game-ui-liquid-surface__body",
332
+ contrast: D.contrast,
333
+ gloss: u ?? D.gloss,
334
+ fill: s,
335
+ filterPadding: Math.max(D.filterPadding, Math.ceil(P.amplitude) + 8),
336
+ motion: w ? "reduced" : "auto",
337
+ ...N === void 0 ? {} : { shadow: N },
338
+ ...c === void 0 ? {} : { stroke: c },
339
+ children: /* @__PURE__ */ h(n.Item, {
340
+ ...P.amplitude > 0 ? { blob: P } : {},
341
+ className: "game-ui-liquid-surface__shape",
342
+ ...O.effect === void 0 ? {} : { effect: O.effect },
343
+ ...O.morph === void 0 ? {} : { morph: O.morph },
344
+ radius: p,
345
+ scale: j.scale,
346
+ scaleY: j.scaleY,
347
+ ...M === void 0 ? {} : { transition: M },
348
+ ...j.x === void 0 ? {} : { x: j.x },
349
+ y: j.y,
350
+ children: /* @__PURE__ */ h("span", { className: "game-ui-liquid-surface__fill" })
351
+ })
352
+ }), /* @__PURE__ */ h("span", {
353
+ className: "game-ui-liquid-surface__content",
354
+ children: r
355
+ })]
356
+ });
357
+ }
358
+ //#endregion
359
+ //#region src/feedback/sound/interactionSound.ts
360
+ var O = null, k = !1;
361
+ function A(e) {
362
+ return typeof e != "number" || !Number.isFinite(e) ? 1 : Math.min(1, Math.max(0, e));
363
+ }
364
+ function j() {
365
+ k || typeof document > "u" || (document.addEventListener("visibilitychange", () => {
366
+ document.visibilityState === "hidden" && O?.state === "running" && O.suspend();
367
+ }), k = !0);
368
+ }
369
+ function M() {
370
+ return typeof window > "u" || window.AudioContext === void 0 ? null : (j(), O ??= new window.AudioContext(), O);
371
+ }
372
+ function N(e) {
373
+ let t = /* @__PURE__ */ new WeakMap();
374
+ return {
375
+ createGain: () => {
376
+ let n = e.createGain(), r = {
377
+ connect: (e) => {
378
+ e instanceof AudioNode && n.connect(e);
379
+ },
380
+ gain: n.gain
381
+ };
382
+ return t.set(r, n), r;
383
+ },
384
+ createOscillator: () => {
385
+ let n = e.createOscillator();
386
+ return {
387
+ connect: (e) => {
388
+ let r = t.get(e);
389
+ r && n.connect(r);
390
+ },
391
+ frequency: n.frequency,
392
+ start: (e) => n.start(e),
393
+ stop: (e) => n.stop(e),
394
+ get type() {
395
+ return n.type;
396
+ },
397
+ set type(e) {
398
+ n.type = e;
399
+ }
400
+ };
401
+ },
402
+ currentTime: e.currentTime,
403
+ destination: e.destination,
404
+ resume: () => e.resume(),
405
+ state: e.state,
406
+ suspend: () => e.suspend()
407
+ };
408
+ }
409
+ function P(e, t = {}) {
410
+ if (t.enabled === !1) return !1;
411
+ let n = .06 * A(t.masterVolume) * A(t.sfxVolume);
412
+ if (n <= 0) return !1;
413
+ e.state === "suspended" && e.resume();
414
+ let r = e.currentTime, i = e.createOscillator(), a = e.createGain();
415
+ return i.type = "triangle", i.frequency.setValueAtTime(420, r), i.frequency.exponentialRampToValueAtTime(620, r + .045), a.gain.setValueAtTime(1e-4, r), a.gain.exponentialRampToValueAtTime(n, r + .008), a.gain.exponentialRampToValueAtTime(1e-4, r + .055), i.connect(a), a.connect(e.destination), i.start(r), i.stop(r + .055), !0;
416
+ }
417
+ function F(e = {}) {
418
+ let t = M();
419
+ return t ? P(N(t), e) : !1;
420
+ }
421
+ function ne(e, t, n = {}) {
422
+ if (n.enabled === !1) return !1;
423
+ let r = .05 * A(n.masterVolume) * A(n.sfxVolume);
424
+ if (r <= 0) return !1;
425
+ e.state === "suspended" && e.resume();
426
+ let i = e.currentTime, a = (t, n, r, i, a, o) => {
427
+ let s = e.createOscillator(), c = e.createGain();
428
+ s.type = t, s.frequency.setValueAtTime(n, i), s.frequency.exponentialRampToValueAtTime(r, i + a), c.gain.setValueAtTime(1e-4, i), c.gain.exponentialRampToValueAtTime(o, i + .01), c.gain.exponentialRampToValueAtTime(1e-4, i + a), s.connect(c), c.connect(e.destination), s.start(i), s.stop(i + a);
429
+ };
430
+ return a("triangle", 900, 260, i, .09, r), (t === "legendary" ? [880, 1320] : t === "rare" ? [990] : []).forEach((e, t) => a("sine", e, e, i + .08 + t * .09, .35, r * .8)), !0;
431
+ }
432
+ function re(e, t = {}) {
433
+ let n = M();
434
+ return n ? ne(N(n), e, t) : !1;
435
+ }
436
+ function I(e, t) {
437
+ let n = !1, r = null, i = null, a = !1, o = 0, s, c = !1, l = () => {}, u = () => e.matches(":disabled,[aria-disabled=\"true\"]") || !!e.querySelector(":scope > input:disabled"), d = () => {
438
+ o++, r = null, i = null, c = !1, clearTimeout(s), s = void 0, l(), l = () => {}, n && (n = !1, t(!1));
439
+ }, f = (e) => {
440
+ c || (r = null, i = null, l(), l = () => {}, e.defaultPrevented || s === void 0 ? d() : c = !0);
441
+ }, p = () => {
442
+ if (n) {
443
+ c = !1, m();
444
+ return;
445
+ }
446
+ n = !0, t(!0), s = setTimeout(() => {
447
+ s = void 0, c && d();
448
+ }, 140), m();
449
+ }, m = () => {
450
+ l();
451
+ let t = (e) => {
452
+ (r === null || e.pointerId === r) && f(e);
453
+ }, n = (e) => {
454
+ (r === null || e.pointerId === r) && d();
455
+ }, a = (e) => {
456
+ e.key === i ? f(e) : e.key === "Escape" && d();
457
+ }, o = () => {
458
+ document.hidden && d();
459
+ }, s = new MutationObserver(() => {
460
+ u() && d();
461
+ });
462
+ for (let t = e; t; t = t.parentElement) (t === e || t.tagName === "FIELDSET") && s.observe(t, {
463
+ attributes: !0,
464
+ attributeFilter: ["disabled", "aria-disabled"]
465
+ });
466
+ window.addEventListener("pointerup", t), window.addEventListener("pointercancel", n), window.addEventListener("keyup", a), window.addEventListener("blur", d), document.addEventListener("visibilitychange", o), l = () => {
467
+ s.disconnect(), window.removeEventListener("pointerup", t), window.removeEventListener("pointercancel", n), window.removeEventListener("keyup", a), window.removeEventListener("blur", d), document.removeEventListener("visibilitychange", o);
468
+ };
469
+ }, h = (t) => {
470
+ if (t.button !== 0 || u()) return;
471
+ let n = ++o;
472
+ r = t.pointerId, queueMicrotask(() => {
473
+ !a && n === o && !t.defaultPrevented && !u() && e.isConnected ? p() : n === o && (r = null);
474
+ });
475
+ }, g = (e) => {
476
+ (r === null || e.pointerId === r) && f(e);
477
+ }, _ = (e) => {
478
+ (r === null || e.pointerId === r) && d();
479
+ }, v = () => {
480
+ c || d();
481
+ }, y = (t) => {
482
+ if (t.key === "Escape") {
483
+ d();
484
+ return;
485
+ }
486
+ if (t.repeat || t.key !== " " && t.key !== "Enter" || u() || e.tagName === "LABEL" && t.key === "Enter" || e.tagName === "A" && t.key === " ") return;
487
+ let n = ++o;
488
+ queueMicrotask(() => {
489
+ !a && n === o && !t.defaultPrevented && !u() && e.isConnected && (i = t.key, p());
490
+ });
491
+ }, b = (e) => {
492
+ e.key === i ? f(e) : d();
493
+ }, x = (t) => {
494
+ c || (r === null || t.relatedTarget instanceof Node && !e.contains(t.relatedTarget)) && d();
495
+ };
496
+ return e.addEventListener("pointerdown", h), e.addEventListener("pointerup", g), e.addEventListener("pointercancel", _), e.addEventListener("pointerleave", v), e.addEventListener("lostpointercapture", v), e.addEventListener("keydown", y), e.addEventListener("keyup", b), e.addEventListener("blur", x, !0), () => {
497
+ a = !0, d(), e.removeEventListener("pointerdown", h), e.removeEventListener("pointerleave", v), e.removeEventListener("pointerup", g), e.removeEventListener("pointercancel", _), e.removeEventListener("lostpointercapture", v), e.removeEventListener("keydown", y), e.removeEventListener("keyup", b), e.removeEventListener("blur", x, !0);
498
+ };
499
+ }
500
+ //#endregion
501
+ //#region src/liquid/LiquidPressSurface/LiquidPressSurface.tsx
502
+ function ie({ children: e, control: t, controlIdentity: n, enabled: r, static: a = !1, fullWidth: o = !1, pending: s = !1 }) {
503
+ let [c, l] = p(!1);
504
+ return u(() => {
505
+ if (l(!1), !r || a || !t.current) return;
506
+ let e = !0, n = I(t.current, (t) => {
507
+ e && l(t);
508
+ });
509
+ return () => {
510
+ e = !1, n();
511
+ };
512
+ }, [
513
+ t,
514
+ n,
515
+ r,
516
+ a
517
+ ]), /* @__PURE__ */ g("span", {
518
+ className: "game-ui-button-frame",
519
+ "data-liquid": r ? "true" : void 0,
520
+ "data-full-width": o ? "true" : void 0,
521
+ children: [r ? /* @__PURE__ */ h(D, {
522
+ active: c && !a,
523
+ breathing: s && !a,
524
+ form: "press",
525
+ fill: i,
526
+ className: "game-ui-cta-decoration",
527
+ children: null
528
+ }, "decoration") : null, e]
529
+ });
530
+ }
531
+ //#endregion
532
+ //#region src/controls/DropletSurface/geometry.ts
533
+ var L = (e, t) => Number.isFinite(e) ? e : t, R = (e) => Math.round(e * 1e3) / 1e3, z = 1.4;
534
+ function B(e) {
535
+ let t = 2166136261;
536
+ for (let n of e) t = Math.imul(t ^ n.charCodeAt(0), 16777619);
537
+ return (t >>> 0) / 4294967296 * Math.PI * 2;
538
+ }
539
+ function V(e, t, n) {
540
+ let r = Math.max(1, L(e, 1)), i = Math.max(1, L(t, 1)), a = Math.max(.5, Math.min(L(n, i / 2), r / 2, i / 2)), o = Math.max(0, r - 2 * a), s = Math.max(0, i - 2 * a), c = Math.PI * a / 2, l = [
541
+ o,
542
+ c,
543
+ s,
544
+ c,
545
+ o,
546
+ c,
547
+ s,
548
+ c
549
+ ], u = l.reduce((e, t) => e + t, 0), d = Math.min(224, Math.max(48, Math.ceil(u / 7))), f = [];
550
+ for (let e = 0; e < d; e++) {
551
+ let t = e / d, n = u * t, o = 0;
552
+ for (; o < 7 && n >= l[o];) n -= l[o++];
553
+ let s = 0, c = 0, p = 0, m = 0;
554
+ if (o === 0) s = a + n, c = 0, m = -1;
555
+ else if (o === 2) s = r, c = a + n, p = 1;
556
+ else if (o === 4) s = r - a - n, c = i, m = 1;
557
+ else if (o === 6) s = 0, c = i - a - n, p = -1;
558
+ else {
559
+ let e = (o - 3) * Math.PI / 4 + n / a, t = o < 4 ? r - a : a, l = o === 1 || o === 7 ? a : i - a;
560
+ p = Math.cos(e), m = Math.sin(e), s = t + a * p, c = l + a * m;
561
+ }
562
+ f.push({
563
+ x: s,
564
+ y: c,
565
+ nx: p,
566
+ ny: m,
567
+ u: t
568
+ });
569
+ }
570
+ return {
571
+ width: r,
572
+ height: i,
573
+ frequency: Math.max(2, Math.round(u / 110)),
574
+ points: f
575
+ };
576
+ }
577
+ function H(e, t, n = 0, r = 0, i = 0) {
578
+ let a = Math.max(0, Math.min(z, L(t, 0), Math.min(e.width, e.height) * .1)), o = L(n, 0), s = L(r, 0), c = L(i, 0), l = e.points.map((t) => {
579
+ let n = Math.PI * 2 * t.u, r = a * (.67 * Math.sin(n * e.frequency + s + o) + .33 * Math.sin(n * (e.frequency + 1) - s * .7 - o * .55));
580
+ return {
581
+ x: t.x + t.nx * r + c,
582
+ y: t.y + t.ny * r + c
583
+ };
584
+ }), u = (e) => l[(e + l.length) % l.length], d = u(0), f = `M${R(d.x)} ${R(d.y)}`;
585
+ for (let e = 0; e < l.length; e++) {
586
+ let t = u(e - 1), n = u(e), r = u(e + 1), i = u(e + 2);
587
+ f += `C${R(n.x + (r.x - t.x) / 6)} ${R(n.y + (r.y - t.y) / 6)} ${R(r.x - (i.x - n.x) / 6)} ${R(r.y - (i.y - n.y) / 6)} ${R(r.x)} ${R(r.y)}`;
588
+ }
589
+ return `${f}Z`;
590
+ }
591
+ //#endregion
592
+ //#region src/controls/DropletSurface/spring.ts
593
+ var U = [
594
+ "x",
595
+ "y",
596
+ "amplitude",
597
+ "phase"
598
+ ], W = () => ({
599
+ x: 0,
600
+ y: 0,
601
+ amplitude: 0,
602
+ phase: 0
603
+ }), G = (e) => ({
604
+ x: 1,
605
+ y: 1,
606
+ amplitude: e,
607
+ phase: 0
608
+ }), K = (e) => ({
609
+ x: 1.09,
610
+ y: .8,
611
+ amplitude: e * 1.75 + .65,
612
+ phase: .8
613
+ });
614
+ function ae(e) {
615
+ return {
616
+ value: G(e),
617
+ velocity: W(),
618
+ target: G(e)
619
+ };
620
+ }
621
+ function q(e, t) {
622
+ e.value = { ...t }, e.target = { ...t }, e.velocity = W();
623
+ }
624
+ function oe(e, t) {
625
+ let n = Math.min(.064, Math.max(0, Number.isFinite(t) ? t : 0));
626
+ for (; n > 0;) {
627
+ let t = Math.min(1 / 120, n);
628
+ for (let n of U) e.velocity[n] += (320 * (e.target[n] - e.value[n]) - 14 * e.velocity[n]) * t, e.value[n] += e.velocity[n] * t;
629
+ n -= t;
630
+ }
631
+ let r = U.some((t) => Math.abs(e.value[t] - e.target[t]) > 8e-4 || Math.abs(e.velocity[t]) > .008);
632
+ return r || q(e, e.target), r;
633
+ }
634
+ //#endregion
635
+ //#region src/controls/DropletSurface/controller.ts
636
+ var J = (e, t) => {
637
+ let n = Number.parseFloat(e);
638
+ return Number.isFinite(n) ? n : t;
639
+ };
640
+ function se(e, t, n, r, i = t, a = z) {
641
+ let o = e.querySelector("path"), s = e.querySelector("g"), c = ae(1.4), l, u = 1.4, d = 10, f = 0, p, m = !1, h = !1, g = "", _ = () => {
642
+ if (h || !l) return;
643
+ let { x: e, y: t, phase: r, amplitude: i } = c.value;
644
+ o.setAttribute("d", H(l, i, r, n, d));
645
+ let a = d + l.width / 2, u = d + l.height / 2;
646
+ s.setAttribute("transform", `translate(${a} ${u}) scale(${e.toFixed(5)} ${t.toFixed(5)}) translate(${-a} ${-u})`);
647
+ }, v = () => {
648
+ p !== void 0 && cancelAnimationFrame(p), p = void 0;
649
+ }, y = () => {
650
+ let n = getComputedStyle(t), i = (e) => {
651
+ let r = e === "width" ? ["Left", "Right"] : ["Top", "Bottom"], i = n.boxSizing === "border-box" ? 0 : r.reduce((e, t) => e + J(n.getPropertyValue(`padding-${t.toLowerCase()}`), 0) + J(n.getPropertyValue(`border-${t.toLowerCase()}-width`), 0), 0);
652
+ return J(n[e], e === "width" ? t.offsetWidth : t.offsetHeight) + i;
653
+ }, o = i("width"), s = i("height");
654
+ if (o <= 0 || s <= 0) return;
655
+ let f = J(n.getPropertyValue("--game-ui-droplet-radius"), Math.min(o, s) / 2), p = Math.max(0, Math.min(z, Number.isFinite(a) ? Math.max(0, a) : z, J(n.getPropertyValue("--game-ui-droplet-wobble"), z))), h = `${o}|${s}|${f}|${p}`;
656
+ if (h === g) return;
657
+ g = h, u = p, l = V(o, s, f), d = Math.ceil(o * .025 + p * 3 + 6), e.setAttribute("width", String(o + 2 * d)), e.setAttribute("height", String(s + 2 * d)), e.setAttribute("viewBox", `0 0 ${o + 2 * d} ${s + 2 * d}`), e.style.left = `${-d}px`, e.style.top = `${-d}px`, e.style.width = `${o + d * 2}px`, e.style.height = `${s + d * 2}px`;
658
+ let v = m && r ? K(u) : G(u);
659
+ q(c, v), e.dataset.ready = "true", _();
660
+ }, b = (e) => {
661
+ if (p = void 0, h || !t.isConnected) return;
662
+ if (document.hidden) {
663
+ q(c, G(u)), m = !1, _();
664
+ return;
665
+ }
666
+ let n = oe(c, f ? (e - f) / 1e3 : 1 / 60);
667
+ f = e, _(), n && (p = requestAnimationFrame(b));
668
+ }, x = (t) => {
669
+ if (!h) {
670
+ if (y(), m = t && r, e.dataset.pressed = String(m), c.target = m ? K(u) : G(u), !r || document.hidden || i.matches(":disabled,[aria-disabled=\"true\"]")) {
671
+ v(), q(c, G(u)), _();
672
+ return;
673
+ }
674
+ p === void 0 && (f = 0, p = requestAnimationFrame(b));
675
+ }
676
+ };
677
+ y();
678
+ let S = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(y);
679
+ S?.observe(t);
680
+ let C = r ? I(i, x) : () => {};
681
+ return () => {
682
+ h = !0, v(), C(), S?.disconnect(), delete e.dataset.ready, delete e.dataset.pressed;
683
+ };
684
+ }
685
+ //#endregion
686
+ //#region src/controls/DropletSurface/DropletSurface.tsx
687
+ function Y({ static: t = !1, pressTarget: n, maxWobble: r = 1.4 }) {
688
+ let i = l(), a = f(null), o = e();
689
+ return u(() => {
690
+ let e = a.current, s = e?.parentElement;
691
+ if (!e || !(s instanceof HTMLElement)) return;
692
+ let c = !1, l, u = () => {
693
+ c || (l = se(e, s, B(i), !o && !t, n?.current ?? s, r));
694
+ };
695
+ return n ? queueMicrotask(u) : u(), () => {
696
+ c = !0, l?.();
697
+ };
698
+ }, [
699
+ i,
700
+ o,
701
+ t,
702
+ n,
703
+ r
704
+ ]), /* @__PURE__ */ h("svg", {
705
+ ref: a,
706
+ className: "game-ui-droplet",
707
+ "aria-hidden": "true",
708
+ focusable: "false",
709
+ children: /* @__PURE__ */ h("g", { children: /* @__PURE__ */ h("path", { vectorEffect: "non-scaling-stroke" }) })
710
+ });
711
+ }
712
+ function X() {
713
+ return /* @__PURE__ */ h("span", {
714
+ className: "game-ui-selection-mark",
715
+ "aria-hidden": "true",
716
+ children: "✓"
717
+ });
718
+ }
719
+ //#endregion
720
+ //#region src/tokens/hue.ts
721
+ function Z(e = "sky", t = !1) {
722
+ return t ? {
723
+ "--hue": "var(--game-ui-danger)",
724
+ "--game-ui-hue-ink": "var(--game-ui-control-danger-ink)"
725
+ } : { "--hue": `var(--game-ui-hue-${e})` };
726
+ }
727
+ //#endregion
728
+ //#region src/controls/NativeAction/NativeAction.tsx
729
+ function Q(e, t) {
730
+ return s((n) => {
731
+ t && (t.current = n);
732
+ let r = typeof e == "function" ? e(n) : void 0;
733
+ if (e && typeof e != "function" && (e.current = n), n) return () => {
734
+ t && (t.current = null), typeof r == "function" ? r() : typeof e == "function" ? e(null) : e && (e.current = null);
735
+ };
736
+ }, [e, t]);
737
+ }
738
+ var $ = o(function(e, t) {
739
+ let n = Q(t);
740
+ if (e.href !== void 0) {
741
+ let { href: t, linkComponent: r, disabled: i = !1, target: a, rel: o, tabIndex: s, onClick: c, onKeyDown: l, onActivate: u, ...d } = e, f = {
742
+ ...d,
743
+ target: a,
744
+ rel: a === "_blank" ? [...new Set(`${o ?? ""} noopener noreferrer`.trim().split(/\s+/))].join(" ") : o,
745
+ "aria-disabled": i ? !0 : d["aria-disabled"],
746
+ role: i ? "link" : d.role,
747
+ tabIndex: i ? void 0 : s,
748
+ onClick: (e) => {
749
+ if (i) {
750
+ e.preventDefault(), e.stopPropagation();
751
+ return;
752
+ }
753
+ u?.(), c?.(e);
754
+ },
755
+ onKeyDown: (e) => {
756
+ if (i) {
757
+ e.preventDefault();
758
+ return;
759
+ }
760
+ l?.(e);
761
+ }
762
+ };
763
+ return r && !i ? /* @__PURE__ */ h(r, {
764
+ ...f,
765
+ href: t,
766
+ ref: n
767
+ }) : /* @__PURE__ */ h("a", {
768
+ ...f,
769
+ href: i ? void 0 : t,
770
+ ref: n
771
+ });
772
+ }
773
+ let { href: r, linkComponent: i, onActivate: a, onClick: o, type: s = "button", ...c } = e;
774
+ return /* @__PURE__ */ h("button", {
775
+ ...c,
776
+ type: s,
777
+ ref: n,
778
+ onClick: (e) => {
779
+ c.disabled || (a?.(), o?.(e));
780
+ }
781
+ });
782
+ }), ce = o(function({ children: e, className: t, fullWidth: n = !1, hue: r, pending: i = !1, sound: o = !1, static: s = !1, variant: c = "secondary", size: l = "md", style: u, ...d }, p) {
783
+ let m = f(null), g = Q(p, m), _ = d["data-game-ui-control"] === "liquid-presence", v = c === "primary" && !d.disabled && !_, y = [
784
+ "game-ui-button",
785
+ `game-ui-button--${c}`,
786
+ n && "game-ui-button--full-width",
787
+ s && "game-ui-button--static",
788
+ t
789
+ ].filter(Boolean).join(" ");
790
+ return /* @__PURE__ */ h(ie, {
791
+ control: m,
792
+ controlIdentity: d.href === void 0 ? "button" : d.linkComponent ?? "a",
793
+ enabled: v,
794
+ static: s,
795
+ fullWidth: n,
796
+ pending: i,
797
+ children: /* @__PURE__ */ a($, {
798
+ ...d,
799
+ key: "control",
800
+ ref: g,
801
+ className: y,
802
+ "aria-busy": i ? !0 : d["aria-busy"],
803
+ onActivate: () => {
804
+ o && F(o);
805
+ },
806
+ "data-game-ui-size": l,
807
+ "data-game-ui-pending": i ? "true" : void 0,
808
+ "data-game-ui-paint": "",
809
+ "data-game-ui-cta": v ? "true" : void 0,
810
+ "data-game-ui-meaning": c === "danger" || c === "success" ? "true" : void 0,
811
+ "data-game-ui-danger": c === "danger" ? "true" : void 0,
812
+ style: {
813
+ ...Z(r ?? (c === "success" ? "leaf" : "sky")),
814
+ ...u
815
+ }
816
+ }, !v && !_ ? /* @__PURE__ */ h(Y, { static: s }) : null, e, d["aria-pressed"] === void 0 ? null : /* @__PURE__ */ h(X, {}))
817
+ });
818
+ });
819
+ //#endregion
820
+ //#region src/controls/GameTabs/GameTabs.tsx
821
+ function le({ activeId: e, id: t, onSelect: n, tabs: r, hue: i, orientation: a = "horizontal", "aria-label": o, "aria-labelledby": s }) {
822
+ let c = l(), u = t ?? c;
823
+ return /* @__PURE__ */ h("div", {
824
+ className: "game-ui-tabs",
825
+ onKeyDown: (t) => {
826
+ if (!n || r.length === 0) return;
827
+ let i = Math.max(0, r.findIndex((t) => t.id === e)), o;
828
+ switch (a === "vertical" ? {
829
+ ArrowUp: "ArrowLeft",
830
+ ArrowDown: "ArrowRight",
831
+ ArrowLeft: "",
832
+ ArrowRight: ""
833
+ }[t.key] ?? t.key : t.key) {
834
+ case "ArrowLeft":
835
+ o = (i - 1 + r.length) % r.length;
836
+ break;
837
+ case "ArrowRight":
838
+ o = (i + 1) % r.length;
839
+ break;
840
+ case "Home":
841
+ o = 0;
842
+ break;
843
+ case "End":
844
+ o = r.length - 1;
845
+ break;
846
+ default: return;
847
+ }
848
+ t.preventDefault();
849
+ let s = r[o];
850
+ s && (s.id !== e && n(s.id), t.currentTarget.querySelectorAll("[role=\"tab\"]")[o]?.focus());
851
+ },
852
+ role: "tablist",
853
+ "aria-orientation": a === "vertical" ? "vertical" : void 0,
854
+ "aria-label": o,
855
+ "aria-labelledby": s,
856
+ children: r.map((t) => /* @__PURE__ */ g("button", {
857
+ "aria-controls": t.panelId,
858
+ "aria-selected": t.id === e,
859
+ className: "game-ui-tab",
860
+ style: Z(t.hue ?? i),
861
+ id: `${u}-${t.id}`,
862
+ onClick: n ? () => n(t.id) : void 0,
863
+ role: "tab",
864
+ tabIndex: t.id === e ? 0 : -1,
865
+ type: "button",
866
+ "data-game-ui-paint": "",
867
+ children: [
868
+ /* @__PURE__ */ h(Y, {}),
869
+ /* @__PURE__ */ h("span", {
870
+ className: "game-ui-tab-label",
871
+ children: t.label
872
+ }),
873
+ /* @__PURE__ */ h(X, {})
874
+ ]
875
+ }, t.id))
876
+ });
877
+ }
878
+ //#endregion
879
+ //#region src/feedback/GameBadge/GameBadge.tsx
880
+ function ue({ children: e, className: t, tone: n = "neutral" }) {
881
+ return /* @__PURE__ */ g("span", {
882
+ className: ["game-ui-badge", t].filter(Boolean).join(" "),
883
+ "data-badge-tone": n,
884
+ "data-game-ui-paint": "",
885
+ "data-game-ui-meaning": n !== "neutral" && n !== "danger" ? "true" : void 0,
886
+ "data-game-ui-danger": n === "danger" ? "true" : void 0,
887
+ style: Z(n === "success" ? "leaf" : n === "warning" ? "sun" : "sky"),
888
+ children: [/* @__PURE__ */ h(Y, {
889
+ static: !0,
890
+ maxWobble: 1
891
+ }), e]
892
+ });
893
+ }
894
+ //#endregion
895
+ //#region src/game/GameAvatar/GameAvatar.tsx
896
+ function de(e) {
897
+ let t = e.trim().split(/\s+/).filter(Boolean);
898
+ return t.length === 0 ? "?" : t.slice(0, 2).map((e) => e[0] ?? "").join("").toUpperCase();
899
+ }
900
+ function fe({ className: e, name: t, size: n = "md", src: r, status: i = "none", surface: a = "flat" }) {
901
+ return /* @__PURE__ */ g("span", {
902
+ className: ["game-ui-avatar", e].filter(Boolean).join(" "),
903
+ "data-avatar-size": n,
904
+ "data-avatar-status": i,
905
+ "data-game-ui-surface": a === "plaque" ? "plaque" : void 0,
906
+ children: [r ? /* @__PURE__ */ h("img", {
907
+ alt: t,
908
+ src: r
909
+ }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
910
+ "aria-hidden": "true",
911
+ className: "game-ui-avatar-initials",
912
+ children: de(t)
913
+ }), /* @__PURE__ */ h("span", {
914
+ className: "game-ui-sr-only",
915
+ children: t
916
+ })] }), i === "none" ? null : /* @__PURE__ */ h("span", {
917
+ "aria-hidden": "true",
918
+ className: "game-ui-avatar-status"
919
+ })]
920
+ });
921
+ }
922
+ //#endregion
923
+ export { v as _, $ as a, X as c, B as d, re as f, _ as g, D as h, ce as i, V as l, P as m, ue as n, Z as o, F as p, le as r, Y as s, fe as t, H as u, y as v, b as y };