@pieai/swimmer-ui-kit 2.9.0 → 2.10.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.
@@ -1,12 +1,12 @@
1
- import { _ as e, d as t, h as n, i as r, m as i, n as a, t as o } from "./reducedMotion-C7O9ls34.js";
2
- import { useEffect as s, useId as c, useRef as l, useState as u } from "react";
3
- import { createPortal as d } from "react-dom";
4
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
5
- import { autoUpdate as h, computePosition as g, flip as _, offset as v, shift as y } from "@floating-ui/react";
6
- function b(e, t, n) {
1
+ import { _ as e, c as t, d as n, h as r, i, m as a, n as o, t as s } from "./reducedMotion-C7O9ls34.js";
2
+ import { useEffect as c, useId as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
3
+ import { createPortal as p } from "react-dom";
4
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ import { FloatingPortal as _, autoUpdate as v, computePosition as y, flip as b, hide as x, offset as S, shift as C, size as w } from "@floating-ui/react";
6
+ function T(e, t, n) {
7
7
  return Number.isFinite(e) ? Math.max(t, Math.min(n, e)) : t;
8
8
  }
9
- function x(e) {
9
+ function E(e) {
10
10
  return !!(e && [
11
11
  e.x,
12
12
  e.y,
@@ -14,23 +14,23 @@ function x(e) {
14
14
  e.height
15
15
  ].every(Number.isFinite) && e.width > 0 && e.height > 0);
16
16
  }
17
- function S(e, t) {
18
- return x(e) && e.x + e.width > t.x && e.y + e.height > t.y && e.x < t.x + t.width && e.y < t.y + t.height;
17
+ function D(e, t) {
18
+ return E(e) && e.x + e.width > t.x && e.y + e.height > t.y && e.x < t.x + t.width && e.y < t.y + t.height;
19
19
  }
20
- function C(e) {
20
+ function O(e) {
21
21
  return {
22
22
  x: e.x + e.width / 2,
23
23
  y: e.y + e.height / 2
24
24
  };
25
25
  }
26
- function w(e, t) {
26
+ function k(e, t) {
27
27
  let n = Math.hypot(t.x - e.x, t.y - e.y) || 1;
28
28
  return {
29
29
  x: (t.x - e.x) / n,
30
30
  y: (t.y - e.y) / n
31
31
  };
32
32
  }
33
- function ee(e, t) {
33
+ function A(e, t) {
34
34
  let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y);
35
35
  return {
36
36
  x: n,
@@ -39,19 +39,19 @@ function ee(e, t) {
39
39
  height: Math.max(0, Math.min(e.y + e.height, t.y + t.height) - r)
40
40
  };
41
41
  }
42
- function te(e, t) {
43
- let n = e.y + e.height + 88 < t.y + t.height, r = n ? "bottom" : "top", i = Math.max(t.x + 18, e.x), a = Math.min(t.x + t.width - 18, e.x + e.width), o = b(Math.max(0, a - i) * .58, 36, 84);
42
+ function ee(e, t) {
43
+ let n = e.y + e.height + 88 < t.y + t.height, r = n ? "bottom" : "top", i = Math.max(t.x + 18, e.x), a = Math.min(t.x + t.width - 18, e.x + e.width), o = T(Math.max(0, a - i) * .58, 36, 84);
44
44
  return {
45
- x: b((i + a) / 2, t.x + o / 2 + 8, t.x + t.width - o / 2 - 8),
46
- y: b(n ? e.y + e.height + 10 : e.y - 10, t.y + 18, t.y + t.height - 18),
45
+ x: T((i + a) / 2, t.x + o / 2 + 8, t.x + t.width - o / 2 - 8),
46
+ y: T(n ? e.y + e.height + 10 : e.y - 10, t.y + 18, t.y + t.height - 18),
47
47
  side: r,
48
48
  width: o
49
49
  };
50
50
  }
51
- function T(e, t, n, r) {
52
- let i = b(n, 0, 1), a = w(e, t), o = Math.min(86, Math.hypot(t.x - e.x, t.y - e.y) * .2), s = {
53
- x: b((e.x + t.x) / 2 + a.y * o, r.x + 16, r.x + r.width - 16),
54
- y: b((e.y + t.y) / 2 - a.x * o, r.y + 16, r.y + r.height - 16)
51
+ function j(e, t, n, r) {
52
+ let i = T(n, 0, 1), a = k(e, t), o = Math.min(86, Math.hypot(t.x - e.x, t.y - e.y) * .2), s = {
53
+ x: T((e.x + t.x) / 2 + a.y * o, r.x + 16, r.x + r.width - 16),
54
+ y: T((e.y + t.y) / 2 - a.x * o, r.y + 16, r.y + r.height - 16)
55
55
  }, c = 2 * (1 - i) * (s.x - e.x) + 2 * i * (t.x - s.x), l = 2 * (1 - i) * (s.y - e.y) + 2 * i * (t.y - s.y);
56
56
  return {
57
57
  x: (1 - i) ** 2 * e.x + 2 * (1 - i) * i * s.x + i ** 2 * t.x,
@@ -59,45 +59,71 @@ function T(e, t, n, r) {
59
59
  angle: Math.atan2(l, c) * 180 / Math.PI
60
60
  };
61
61
  }
62
- function E(e = 0, t = 0, n = 0) {
63
- let i = 66 * Math.sqrt(1 - .075 * b(n, 0, 1));
64
- return r(80 - i, 80 - i, i * 2, i * 2, [
65
- i,
66
- i,
67
- i,
68
- i
62
+ function M(e = 0, t = 0, n = 0, r = 1, a = 0) {
63
+ let o = T(a, 0, 1), s = 66 * Math.sqrt(1 - .075 * T(n, 0, 1)) - o * 2.4;
64
+ return i(80 - s, 80 - s, s * 2, s * 2, [
65
+ s,
66
+ s,
67
+ s,
68
+ s
69
69
  ], {
70
- amplitude: 3.5 + b(t, 0, 1) * 9,
70
+ amplitude: (3.5 + o * 9 + T(t, 0, 1) * 9) * T(r, .15, 1.25),
71
71
  lobes: 3,
72
72
  seed: 17,
73
73
  phase: e
74
74
  });
75
75
  }
76
- function D(e, t, n = 20) {
77
- let i = b(t, 0, 1), a = b(n, 6, 48), o = a + (e - a) * i, s = a + (8 - a) * i;
78
- return r(-o / 2, -s / 2, o, s, [
76
+ function N(e, t, n = 20) {
77
+ let r = T(t, 0, 1), a = T(n, 6, 48), o = a + (e - a) * r, s = a + (8 - a) * r;
78
+ return i(-o / 2, -s / 2, o, s, [
79
79
  s / 2,
80
80
  s / 2,
81
81
  s / 2,
82
82
  s / 2
83
83
  ], {
84
84
  amplitude: 2.2,
85
- phase: i * Math.PI,
85
+ phase: r * Math.PI,
86
86
  seed: 17,
87
87
  lobes: 3
88
88
  });
89
89
  }
90
90
  //#endregion
91
+ //#region src/liquidAmbientClock.ts
92
+ var P = /* @__PURE__ */ new Map(), F, I, L = !1;
93
+ function R() {
94
+ if (L || I !== void 0 || (clearTimeout(F), F = void 0, !P.size)) return;
95
+ let e = Math.min(...[...P.values()].map((e) => e.at));
96
+ F = setTimeout(() => {
97
+ F = void 0, I = requestAnimationFrame((e) => {
98
+ I = void 0, L = !0;
99
+ try {
100
+ for (let [t, n] of [...P]) n.at > e + 1 || !P.has(t) || (P.delete(t), n.paint(e));
101
+ } finally {
102
+ L = !1, R();
103
+ }
104
+ });
105
+ }, Math.max(0, e - performance.now()));
106
+ }
107
+ function te(e, t = 1e3 / 12) {
108
+ let n = Symbol();
109
+ return P.set(n, {
110
+ at: performance.now() + t,
111
+ paint: e
112
+ }), R(), () => {
113
+ P.delete(n), !P.size && I !== void 0 && (cancelAnimationFrame(I), I = void 0), R();
114
+ };
115
+ }
116
+ //#endregion
91
117
  //#region src/liquidPresenceMotion.ts
92
- var O = a("cubic-bezier(0.45, 0, 0.2, 1)");
118
+ var z = o("cubic-bezier(0.45, 0, 0.2, 1)");
93
119
  function ne(e) {
94
120
  let { source: t, destination: n, viewport: r, returning: i = !1, from: a, origin: o } = e, s = o?.seat == null ? 0 : 180;
95
121
  if (s && e.elapsed < s) return {
96
122
  ...o,
97
123
  phase: "gather",
98
- seat: o.seat * (1 - O(b(e.elapsed / s, 0, 1)))
124
+ seat: o.seat * (1 - z(T(e.elapsed / s, 0, 1)))
99
125
  };
100
- let c = Math.max(0, e.elapsed - s), l = C(t), u = w(l, n), d = Math.atan2(u.y, u.x) * 180 / Math.PI, f = t.width / 160, p = {
126
+ let c = Math.max(0, e.elapsed - s), l = O(t), u = k(l, n), d = Math.atan2(u.y, u.x) * 180 / Math.PI, f = t.width / 160, p = {
101
127
  x: l.x + u.x * 112 * f,
102
128
  y: l.y + u.y * 112 * f
103
129
  }, m = {
@@ -112,7 +138,7 @@ function ne(e) {
112
138
  };
113
139
  if (i) {
114
140
  if (o?.bud) {
115
- let e = O(b(c / 320, 0, 1)), t = o.bud.x + (80 - o.bud.x) * e, n = o.bud.y + (80 - o.bud.y) * e;
141
+ let e = z(T(c / 320, 0, 1)), t = o.bud.x + (80 - o.bud.x) * e, n = o.bud.y + (80 - o.bud.y) * e;
116
142
  return {
117
143
  ...m,
118
144
  phase: e < 1 ? "merge" : "still",
@@ -128,9 +154,9 @@ function ne(e) {
128
154
  } : null
129
155
  };
130
156
  }
131
- let e = b(c / 620, 0, 1);
157
+ let e = T(c / 620, 0, 1);
132
158
  if (e < 1) {
133
- let t = T(a ?? n, p, O(e), r);
159
+ let t = j(a ?? n, p, z(e), r);
134
160
  return {
135
161
  ...m,
136
162
  phase: "return",
@@ -140,11 +166,11 @@ function ne(e) {
140
166
  stretch: 1 + .3 * Math.sin(e * Math.PI)
141
167
  };
142
168
  }
143
- let t = b((c - 620) / 420, 0, 1), i = 112 - 78 * O(t);
169
+ let t = T((c - 620) / 420, 0, 1), i = 112 - 78 * z(t);
144
170
  return {
145
171
  ...m,
146
172
  phase: t < 1 ? "merge" : "still",
147
- separation: 1 - O(t),
173
+ separation: 1 - z(t),
148
174
  point: {
149
175
  x: l.x + u.x * i * f,
150
176
  y: l.y + u.y * i * f
@@ -152,13 +178,13 @@ function ne(e) {
152
178
  bud: t < 1 ? {
153
179
  x: 80 + u.x * i,
154
180
  y: 80 + u.y * i,
155
- radius: 16 * (1 - .65 * O(t))
181
+ radius: 16 * (1 - .65 * z(t))
156
182
  } : null
157
183
  };
158
184
  }
159
185
  let h = o?.phase === "split" ? o.bud : null, g = h ? o.separation : 0, _ = h ? Math.max(180, 460 * (1 - g)) : a ? 0 : 460;
160
186
  if (c < _) {
161
- let e = O(c / _), t = 42 + 70 * e, n = h ? h.x + (80 + u.x * 112 - h.x) * e : 80 + u.x * t, r = h ? h.y + (80 + u.y * 112 - h.y) * e : 80 + u.y * t, i = h?.radius ?? 16 * .55;
187
+ let e = z(c / _), t = 42 + 70 * e, n = h ? h.x + (80 + u.x * 112 - h.x) * e : 80 + u.x * t, r = h ? h.y + (80 + u.y * 112 - h.y) * e : 80 + u.y * t, i = h?.radius ?? 16 * .55;
162
188
  return {
163
189
  ...m,
164
190
  phase: "split",
@@ -174,66 +200,66 @@ function ne(e) {
174
200
  }
175
201
  };
176
202
  }
177
- let v = a ?? p, y = 560 + Math.min(260, Math.hypot(n.x - v.x, n.y - v.y) * .26), x = b((c - _) / y, 0, 1);
178
- if (x < 1) {
179
- let e = T(v, n, O(x), r);
203
+ let v = a ?? p, y = 560 + Math.min(260, Math.hypot(n.x - v.x, n.y - v.y) * .26), b = T((c - _) / y, 0, 1);
204
+ if (b < 1) {
205
+ let e = j(v, n, z(b), r);
180
206
  return {
181
207
  ...m,
182
208
  phase: "flight",
183
209
  separation: 1,
184
210
  point: e,
185
211
  angle: e.angle,
186
- stretch: 1 + .35 * Math.sin(x * Math.PI)
212
+ stretch: 1 + .35 * Math.sin(b * Math.PI)
187
213
  };
188
214
  }
189
- let S = b((c - _ - y) / 380, 0, 1);
215
+ let x = T((c - _ - y) / 380, 0, 1);
190
216
  return {
191
217
  ...m,
192
- phase: S < 1 ? "land" : "dock",
218
+ phase: x < 1 ? "land" : "dock",
193
219
  separation: 1,
194
220
  point: n,
195
- seat: O(S)
221
+ seat: z(x)
196
222
  };
197
223
  }
198
224
  //#endregion
199
225
  //#region src/liquidPresencePaint.ts
200
- function k(e, t) {
226
+ function B(e, t) {
201
227
  e.toggleAttribute("hidden", !t);
202
228
  let n = e.style, r = t ? "" : "none";
203
229
  n.display !== r && (n.display = r);
204
230
  }
205
- var A = (e, t, n) => {
231
+ var V = (e, t, n) => {
206
232
  let r = String(n);
207
233
  e.getAttribute(t) !== r && e.setAttribute(t, r);
208
234
  };
209
- function j(e, t, n) {
235
+ function H(e, t, n) {
210
236
  let r = e.overlay.getBoundingClientRect(), i = r.width / (e.overlay.clientWidth || r.width || 1) || 1, a = r.height / (e.overlay.clientHeight || r.height || 1) || 1;
211
237
  return {
212
238
  x: (t - r.x) / i,
213
239
  y: (n - r.y) / a
214
240
  };
215
241
  }
216
- function re(e, t, n, r, i = 0) {
217
- A(e.source, "data-liquid-phase", t.phase), A(e.overlay, "data-liquid-phase", t.phase), A(e.body, "d", E(r, i, t.separation));
218
- let a = t.bud ? Math.sin(t.separation * Math.PI) * .045 : 0;
219
- A(e.body, "transform", `translate(${((t.bud?.x ?? 80) - 80) * a} ${((t.bud?.y ?? 80) - 80) * a})`), k(e.bud, !!t.bud), t.bud && (A(e.bud, "cx", t.bud.x), A(e.bud, "cy", t.bud.y), A(e.bud, "r", t.bud.radius));
220
- let o = t.phase === "flight" || t.phase === "return";
221
- k(e.flight, o);
222
- let s = j(e, t.point.x, t.point.y);
223
- if (o) {
242
+ function re(e, t, n, r, i = 0, a = 1, o = !1, s = 0) {
243
+ V(e.source, "data-liquid-phase", t.phase), V(e.overlay, "data-liquid-phase", t.phase), V(e.body, "d", M(r, i, t.separation, a, s));
244
+ let c = t.bud ? Math.sin(t.separation * Math.PI) * .045 : 0;
245
+ V(e.body, "transform", `translate(${((t.bud?.x ?? 80) - 80) * c} ${((t.bud?.y ?? 80) - 80) * c})`), B(e.bud, !!t.bud), t.bud && (V(e.bud, "cx", t.bud.x), V(e.bud, "cy", t.bud.y), V(e.bud, "r", t.bud.radius));
246
+ let l = t.phase === "flight" || t.phase === "return";
247
+ B(e.flight, l);
248
+ let u = H(e, t.point.x, t.point.y);
249
+ if (l) {
224
250
  let n = t.diameter / 32;
225
- e.flight.style.transform = `translate(${s.x - 48}px, ${s.y - 36}px)`, A(e.flightBody, "transform", `rotate(${t.angle}) scale(${n * t.stretch} ${n / Math.sqrt(t.stretch)})`), A(e.trail, "opacity", Math.min(.8, (t.stretch - 1) * 3));
251
+ e.flight.style.transform = `translate(${u.x - 48}px, ${u.y - 36}px)`, V(e.flightBody, "transform", `rotate(${t.angle}) scale(${n * t.stretch} ${n / Math.sqrt(t.stretch)})`), V(e.trail, "opacity", Math.min(.8, (t.stretch - 1) * 3));
226
252
  }
227
- k(e.seat, t.seat !== null), t.seat !== null && (e.seat.style.transform = `translate(${s.x - 56}px, ${s.y - 28}px)`, A(e.seatBody, "d", D(t.seatWidth ?? n, t.seat, t.diameter))), k(e.label, t.phase !== "gather" && t.seat !== null && t.seat > .45);
253
+ B(e.seat, t.seat !== null), t.seat !== null && (e.seat.style.transform = `translate(${u.x - 56}px, ${u.y - 28}px)`, V(e.seatBody, "d", N(t.seatWidth ?? n, t.seat, t.diameter))), B(e.label, o || t.phase !== "gather" && t.seat !== null && t.seat > .45);
228
254
  }
229
255
  function ie(e, t, n, r) {
230
256
  e.satellites.forEach((e, i) => {
231
- if (k(e, n), !n) return;
257
+ if (B(e, n), !n) return;
232
258
  let a = t * .7 + i * Math.PI * 2 / 3, o = 63 + Math.max(0, Math.sin(t * 1.6 + i * 2)) * (16 + r * 12);
233
- A(e, "cx", 80 + Math.cos(a) * o), A(e, "cy", 80 + Math.sin(a) * o), A(e, "r", 7 + i * 1.5);
259
+ V(e, "cx", 80 + Math.cos(a) * o), V(e, "cy", 80 + Math.sin(a) * o), V(e, "r", 7 + i * 1.5);
234
260
  });
235
261
  }
236
- function M() {
262
+ function U() {
237
263
  let e = window.visualViewport;
238
264
  return {
239
265
  x: e?.offsetLeft ?? 0,
@@ -244,23 +270,23 @@ function M() {
244
270
  }
245
271
  //#endregion
246
272
  //#region src/liquidPresenceTracking.ts
247
- function N(e) {
273
+ function ae(e) {
248
274
  try {
249
275
  let t = e.contextElement;
250
276
  if (t && t.ownerDocument !== document || t && (!t.isConnected || t.closest("[hidden], [inert]")) || t && getComputedStyle(t).visibility === "hidden") return null;
251
277
  let n = document.querySelector("dialog:modal");
252
278
  if (n && (!t || !n.contains(t))) return null;
253
279
  let r = e.getRect();
254
- return x(r) && S(r, M()) ? r : null;
280
+ return E(r) && D(r, U()) ? r : null;
255
281
  } catch {
256
282
  return null;
257
283
  }
258
284
  }
259
- function ae(e, t, n, r) {
285
+ function oe(e, t, n, r) {
260
286
  let i = t.contextElement, a = {
261
287
  ...i ? { contextElement: i } : {},
262
288
  getBoundingClientRect: () => {
263
- let e = N(t) ?? {
289
+ let e = ae(t) ?? {
264
290
  x: 0,
265
291
  y: 0,
266
292
  width: 0,
@@ -297,7 +323,7 @@ function ae(e, t, n, r) {
297
323
  attributeFilter: ["open", "inert"]
298
324
  });
299
325
  let l = () => {}, u = !1, d = /* @__PURE__ */ new Map(), f = (e) => {
300
- l(), u = e, l = h(i ?? a, n, r, { animationFrame: !i || e });
326
+ l(), u = e, l = v(i ?? a, n, r, { animationFrame: !i || e });
301
327
  }, p = (e) => {
302
328
  if (!(e.target instanceof Element) || !o.has(e.target)) return;
303
329
  let t = "propertyName" in e ? String(e.propertyName) : "animationName" in e ? String(e.animationName) : e.type, n = d.get(e.target) ?? /* @__PURE__ */ new Set();
@@ -318,53 +344,65 @@ function ae(e, t, n, r) {
318
344
  }
319
345
  //#endregion
320
346
  //#region src/useLiquidPresenceMotion.ts
321
- function P(t, r, a, o) {
322
- let c = l(a);
323
- c.current = a;
324
- let u = l(null), d = l(null), f = l(null), p = l(0), m = l(() => {});
325
- s(() => {
326
- let a = t.current, o = r.current;
327
- if (!a || !o) return;
328
- let s = {
329
- source: a,
347
+ function W(t, n, i, o) {
348
+ let s = d(i);
349
+ s.current = i;
350
+ let l = !!i.guideContent, u = d(null), f = d(null), p = d(null), m = d(0), h = d(+(i.idleMotion === "breathe")), g = d(() => {});
351
+ c(() => {
352
+ let i = t.current, o = n.current;
353
+ if (!i || !o) return;
354
+ let c = {
355
+ source: i,
330
356
  overlay: o,
331
- body: a.querySelector("[data-presence-body]"),
332
- bud: a.querySelector("[data-presence-bud]"),
333
- satellites: [...a.querySelectorAll("[data-presence-satellite]")],
357
+ body: i.querySelector("[data-presence-body]"),
358
+ bud: i.querySelector("[data-presence-bud]"),
359
+ satellites: [...i.querySelectorAll("[data-presence-satellite]")],
334
360
  flight: o.querySelector(".game-ui-liquid-presence-flight"),
335
361
  flightBody: o.querySelector("[data-presence-flight-body]"),
336
362
  trail: o.querySelector("[data-presence-trail]"),
337
363
  seat: o.querySelector(".game-ui-liquid-presence-seat"),
338
364
  seatBody: o.querySelector("[data-presence-seat-body]"),
339
365
  label: o.querySelector(".game-ui-liquid-presence-label")
340
- }, l = c.current.target ?? null;
341
- l || (d.current = null), l?.key === d.current && (l = null);
342
- let h = u.current, x = !l && !!(h && h.phase !== "still"), w = h && [
366
+ }, l = s.current.target ?? null;
367
+ l || (f.current = null), l?.key === f.current && (l = null);
368
+ let d = u.current, _ = !l && !!(d && d.phase !== "still"), v = d && [
343
369
  "flight",
344
370
  "dock",
345
371
  "land",
346
372
  "gather",
347
373
  "return"
348
- ].includes(h.phase) ? h.point : void 0, T = h?.point ?? C(a.getBoundingClientRect()), E = h?.seatWidth ?? 48, D = h ?? void 0, O = a.getBoundingClientRect(), A = performance.now(), j = null, P = !0, F = !1, I = !0, L = 0, R = p.current, z = performance.now(), B = 0, V = 0, H = () => {}, U, W = () => {
349
- F && n(), F = !1;
350
- }, G = (e) => {
374
+ ].includes(d.phase) ? d.point : void 0, x = d?.point ?? O(i.getBoundingClientRect()), E = d?.seatWidth ?? 48, k = d ?? void 0, j = i.getBoundingClientRect(), M = performance.now(), N = null, P = () => {}, F = !0, I = !1, L = !1, R = !0, z = 0, V = m.current, H = performance.now(), W = 0, G = 0, K = null, q = () => {}, J, Y = () => {
375
+ I && r(), I = !1;
376
+ }, X = (e) => {
351
377
  if (l) {
352
- d.current = l.key, l = null, x = !!(u.current && u.current.phase !== "still"), D = u.current ?? void 0, w = u.current?.point, T = w ?? T, A = performance.now(), H(), clearTimeout(U), V++, k(s.label, !1);
378
+ f.current = l.key, l = null, _ = !!(u.current && u.current.phase !== "still"), k = u.current ?? void 0, v = u.current?.point, x = v ?? x, M = performance.now(), q(), clearTimeout(J), G++, B(c.label, !1);
353
379
  try {
354
- c.current.onDismiss?.(e);
380
+ s.current.onDismiss?.(e);
355
381
  } catch {}
356
- Z();
382
+ $();
383
+ }
384
+ }, se = () => {
385
+ if (!l) return null;
386
+ let e = c.label.style.pointerEvents;
387
+ s.current.guideContent && (c.label.style.pointerEvents = "none");
388
+ try {
389
+ return ae(s.current.target?.key === l.key ? s.current.target : l);
390
+ } finally {
391
+ c.label.style.pointerEvents = e;
357
392
  }
358
- }, K = () => l ? N(c.current.target?.key === l.key ? c.current.target : l) : null, q = () => {
393
+ }, Z = () => {
359
394
  if (!l) return;
360
- let e = K();
395
+ let e = se();
361
396
  if (!e) {
362
- G("unavailable");
397
+ X("unavailable");
363
398
  return;
364
399
  }
365
- let t = te(e, M()), n = ee(e, M());
366
- T = t, E = t.width;
367
- let r = {
400
+ let t = ee(e, U()), n = A(e, U()), r = (e) => T(e === "top" ? n.y - 10 : n.y + n.height + 10, U().y + 18, U().y + U().height - 18);
401
+ x = {
402
+ x: t.x,
403
+ y: r(K ?? t.side)
404
+ }, E = t.width;
405
+ let i = {
368
406
  ...l.contextElement ? { contextElement: l.contextElement } : {},
369
407
  getBoundingClientRect: () => ({
370
408
  ...n,
@@ -373,135 +411,173 @@ function P(t, r, a, o) {
373
411
  bottom: n.y + n.height,
374
412
  right: n.x + n.width
375
413
  })
376
- }, i = ++V;
377
- g(r, s.label, {
414
+ }, a = ++G, o = s.current.guideSize === "expanded";
415
+ o || (c.label.style.maxHeight = ""), s.current.guideContent && !c.label.style.transform && (c.label.style.visibility = "hidden", B(c.label, !0)), y(i, c.label, {
378
416
  strategy: "absolute",
379
- placement: t.side,
417
+ placement: o && U().width >= 900 ? "right" : t.side,
380
418
  middleware: [
381
- v(26),
382
- _(),
383
- y({
419
+ S(26),
420
+ b({
384
421
  padding: 16,
385
- crossAxis: !0
386
- })
422
+ ...o && U().width >= 900 ? { fallbackPlacements: [
423
+ "left",
424
+ "bottom",
425
+ "top"
426
+ ] } : {}
427
+ }),
428
+ C({
429
+ padding: 16,
430
+ crossAxis: !o
431
+ }),
432
+ ...o ? [w({
433
+ padding: 16,
434
+ apply({ availableHeight: e, elements: t }) {
435
+ let n = `${Math.max(0, Math.min(560, U().height * .65, e))}px`;
436
+ t.floating.style.maxHeight !== n && (t.floating.style.maxHeight = n);
437
+ }
438
+ })] : []
387
439
  ]
388
- }).then(({ x: e, y: t }) => {
389
- P && i === V && (s.label.style.transform = `translate(${e}px, ${t}px)`);
440
+ }).then(({ x: e, y: n, placement: i }) => {
441
+ if (F && a === G) {
442
+ c.label.style.transform = `translate(${e}px, ${n}px)`, c.label.style.visibility = "", K = i.startsWith("top") ? "top" : i.startsWith("bottom") ? "bottom" : t.side;
443
+ let a = r(K);
444
+ x.y !== a && (x = {
445
+ x: t.x,
446
+ y: a
447
+ }, $());
448
+ }
390
449
  }).catch(() => {});
391
- }, J = () => [
450
+ }, Q = () => [
392
451
  "connecting",
393
452
  "listening",
394
453
  "thinking",
395
454
  "speaking",
396
455
  "working"
397
- ].includes(c.current.activity ?? "idle"), oe = () => {
398
- if (c.current.reducedMotion || c.current.activity === "disabled" || document.hidden || !I || !S(a.getBoundingClientRect(), M())) return !1;
456
+ ].includes(s.current.activity ?? "idle"), ce = () => s.current.idleMotion === "breathe" && (s.current.activity ?? "idle") === "idle", le = () => {
457
+ if (L = !1, s.current.reducedMotion || s.current.activity === "disabled" || document.hidden || !R || !D(i.getBoundingClientRect(), U())) return !1;
399
458
  let t = document.querySelector("dialog:modal");
400
- if (t && !t.contains(a)) return !1;
459
+ if (t && !t.contains(i)) return !1;
401
460
  let n = l?.contextElement?.closest("dialog") ?? null;
402
- if (l && a.closest("dialog") !== n) return !1;
403
- let r = 13184 + (a.getBoundingClientRect().width * 2) ** 2, o = i();
404
- return o.maxAnimatedGroups === 0 || r > o.maxFilterArea ? (W(), !1) : (F ||= e(r), F);
461
+ if (l && i.closest("dialog") !== n) return !1;
462
+ let r = 13184 + (i.getBoundingClientRect().width * 2) ** 2, o = a();
463
+ return o.maxAnimatedGroups === 0 || r > o.maxFilterArea ? (Y(), !1) : !(l || _ || Q()) && ce() && !I && o.activeGroups > 0 ? (L = !0, !1) : (I ||= e(r), I);
405
464
  };
406
- function Y(e) {
407
- if (!P || document.hidden) return;
408
- let t = s.source.getBoundingClientRect();
409
- if (!s.source.isConnected || s.source.closest("[hidden], [inert]") || t.width <= 0 || t.height <= 0) {
410
- x = !1, u.current = null, G("unavailable"), k(s.label, !1), k(s.flight, !1), k(s.seat, !1), W();
465
+ function ue(e) {
466
+ if (!F || document.hidden) return;
467
+ let t = c.source.getBoundingClientRect();
468
+ if (!c.source.isConnected || c.source.closest("[hidden], [inert]") || t.width <= 0 || t.height <= 0) {
469
+ _ = !1, u.current = null, X("unavailable"), B(c.label, !1), B(c.flight, !1), B(c.seat, !1), Y();
411
470
  return;
412
471
  }
413
- if (l && !K()) {
414
- G("unavailable");
472
+ if (l && !se()) {
473
+ X("unavailable");
415
474
  return;
416
475
  }
417
- let n = oe(), r = ne({
418
- elapsed: e - A,
419
- source: x ? t : O,
420
- destination: T,
421
- viewport: M(),
422
- returning: x,
423
- ...w ? { from: w } : {},
424
- ...D ? { origin: D } : {}
476
+ let n = le(), r = ne({
477
+ elapsed: e - M,
478
+ source: _ ? t : j,
479
+ destination: x,
480
+ viewport: U(),
481
+ returning: _,
482
+ ...v ? { from: v } : {},
483
+ ...k ? { origin: k } : {}
425
484
  });
426
- !l && !x && (r = {
485
+ !l && !_ && (r = {
427
486
  ...r,
428
487
  phase: "still",
429
488
  separation: 0,
430
489
  bud: null,
431
490
  seat: null
432
- }), (!n || l && f.current === l.key) && (r = {
491
+ }), (!n || l && p.current === l.key) && (r = {
433
492
  ...r,
434
493
  phase: l ? "dock" : "still",
435
- point: T,
494
+ point: x,
436
495
  bud: null,
437
496
  seat: l ? 1 : null,
438
497
  separation: +!!l
439
- }), x && r.phase === "still" && (x = !1), l && r.phase === "dock" && (f.current = l.key);
440
- let i = !["still", "dock"].includes(r.phase), a = c.current.levelRef?.current, o = Math.max(0, Math.min(64, e - z));
441
- z = e;
442
- let d = typeof a == "number" ? b(a, 0, 1) : 0;
443
- B += (d - B) * (1 - Math.exp(-o / (d > B ? 65 : 140))), n && (i || J()) && (R += o * .00105), p.current = R;
444
- let m = n && J() && !i ? .14 + B * .75 : i ? .2 : 0, h = s.label.hasAttribute("hidden");
445
- re(s, r, E, R, m), ie(s, R, n && c.current.activity === "speaking" && r.phase === "still", B);
446
- let g = n && (i || J()) ? "animated" : "static";
447
- s.source.dataset.liquidMotion !== g && (s.source.dataset.liquidMotion = g), u.current = {
498
+ }), _ && r.phase === "still" && (_ = !1), l && r.phase === "dock" && (p.current = l.key);
499
+ let i = !["still", "dock"].includes(r.phase), a = s.current.levelRef?.current, o = !i && ce(), d = Math.max(0, Math.min(160, e - H));
500
+ H = e;
501
+ let f = typeof a == "number" ? T(a, 0, 1) : 0;
502
+ W += (f - W) * (1 - Math.exp(-d / (f > W ? 65 : 140)));
503
+ let g = T(s.current.motionSpeed ?? 1, .5, 1.5), y = T(s.current.motionIntensity ?? 1, .25, 1.25);
504
+ n && (i || Q() || o) && (V += d * (o ? 84e-5 : .00105) * g), m.current = V, n && (i || Q() || o) && (h.current += (+!!o - h.current) * (1 - Math.exp(-d / 500)));
505
+ let b = n && Q() && !i ? .14 + W * .75 : i ? .2 : 0, S = c.label.hasAttribute("hidden");
506
+ re(c, r, E, V, b, y, !!(s.current.guideContent && l), h.current), ie(c, V, n && s.current.splashes !== !1 && s.current.activity === "speaking" && r.phase === "still", W);
507
+ let C = n && (i || Q()) ? "animated" : n && o ? "ambient" : "static";
508
+ c.source.dataset.liquidMotion !== C && (c.source.dataset.liquidMotion = C), u.current = {
448
509
  ...r,
449
- seatWidth: r.phase === "gather" ? D?.seatWidth ?? E : E
450
- }, l && h && !s.label.hasAttribute("hidden") && q(), n && (i || J()) ? j = requestAnimationFrame(X) : W();
510
+ seatWidth: r.phase === "gather" ? k?.seatWidth ?? E : E
511
+ }, l && S && !c.label.hasAttribute("hidden") && Z(), n && (i || Q()) ? N = requestAnimationFrame(de) : (Y(), o && (n || L) && (P = te(() => {
512
+ P = () => {}, F && !document.hidden && R && de(performance.now());
513
+ }, L ? 250 : 1e3 / 12)));
451
514
  }
452
- function X(e) {
453
- if (j = null, !P || document.hidden) {
454
- W();
515
+ function de(e) {
516
+ if (N = null, !F || document.hidden) {
517
+ Y();
455
518
  return;
456
519
  }
457
- if ((u.current?.phase === "still" || u.current?.phase === "dock") && e - L < 32) {
458
- j = requestAnimationFrame(X);
520
+ if ((u.current?.phase === "still" || u.current?.phase === "dock") && e - z < 32) {
521
+ N = requestAnimationFrame(de);
459
522
  return;
460
523
  }
461
- L = e, Y(e);
524
+ z = e, ue(e);
462
525
  }
463
- function Z() {
464
- !P || j !== null || document.hidden || Y(performance.now());
526
+ function $() {
527
+ !F || N !== null || document.hidden || (P(), P = () => {}, ue(performance.now()));
465
528
  }
466
- m.current = Z;
467
- let Q = () => {
468
- if (H(), H = () => {}, !l || document.hidden) return;
469
- let e = ae(s.source, l, s.label, () => {
470
- q(), Z();
529
+ g.current = $;
530
+ let fe = () => {
531
+ if (q(), q = () => {}, !l || document.hidden) return;
532
+ let e = oe(c.source, l, c.label, () => {
533
+ Z(), $();
471
534
  });
472
- H = e, l || e();
535
+ q = e, l || e();
473
536
  };
474
- l && (s.label.textContent = l.label.slice(0, 240), q(), l && (Q(), l && (U = setTimeout(() => G("expired"), 12e3))));
475
- let $ = (e) => {
476
- e.key === "Escape" && G("dismissed");
477
- }, se = (e) => {
478
- l?.contextElement && e.target instanceof Node && l.contextElement.contains(e.target) && G("dismissed");
479
- }, ce = () => {
480
- document.hidden ? (j !== null && cancelAnimationFrame(j), j = null, H(), V++, W()) : (z = performance.now(), Q(), Z());
481
- }, le = typeof IntersectionObserver > "u" ? null : new IntersectionObserver((e) => {
482
- I = e[0]?.isIntersecting ?? !0, I || (j !== null && cancelAnimationFrame(j), j = null, W()), Z();
537
+ l && (Z(), l && (fe(), l && !s.current.guideContent && (J = setTimeout(() => X("expired"), 12e3))));
538
+ let pe = (e) => {
539
+ if (e.key === "Escape" && !e.isComposing && l) {
540
+ if (s.current.guideContent && e.target instanceof Node && c.label.contains(e.target)) return;
541
+ let t = document.querySelector("dialog:modal");
542
+ if (t && !t.contains(c.label)) return;
543
+ s.current.guideContent && e.preventDefault(), X("dismissed");
544
+ }
545
+ }, me = (e) => {
546
+ s.current.dismissOnTargetClick !== !1 && l?.contextElement && e.target instanceof Node && l.contextElement.contains(e.target) && X("dismissed");
547
+ }, he = () => {
548
+ document.hidden ? (P(), P = () => {}, N !== null && cancelAnimationFrame(N), N = null, q(), G++, Y()) : (H = performance.now(), fe(), $());
549
+ }, ge = typeof IntersectionObserver > "u" ? null : new IntersectionObserver((e) => {
550
+ R = e[0]?.isIntersecting ?? !0, R || (P(), P = () => {}, N !== null && cancelAnimationFrame(N), N = null, Y()), $();
483
551
  });
484
- return le?.observe(a), document.addEventListener("keydown", $), document.addEventListener("click", se), document.addEventListener("visibilitychange", ce), Z(), () => {
485
- P = !1, m.current = () => {}, V++, j !== null && cancelAnimationFrame(j), clearTimeout(U), H(), le?.disconnect(), W(), document.removeEventListener("keydown", $), document.removeEventListener("click", se), document.removeEventListener("visibilitychange", ce);
552
+ return ge?.observe(i), document.addEventListener("keydown", pe, !0), document.addEventListener("click", me), document.addEventListener("visibilitychange", he), document.addEventListener("close", $, !0), document.addEventListener("toggle", $, !0), $(), () => {
553
+ F = !1, g.current = () => {}, G++, N !== null && cancelAnimationFrame(N), clearTimeout(J), P(), q(), ge?.disconnect(), Y(), document.removeEventListener("keydown", pe, !0), document.removeEventListener("click", me), document.removeEventListener("visibilitychange", he), document.removeEventListener("close", $, !0), document.removeEventListener("toggle", $, !0);
486
554
  };
487
555
  }, [
488
556
  t,
489
- r,
557
+ n,
490
558
  o,
491
- a.target?.key,
492
- a.reducedMotion,
493
- a.size
494
- ]), s(() => m.current(), [a.activity]);
559
+ i.target?.key,
560
+ i.reducedMotion,
561
+ i.size,
562
+ i.guideSize,
563
+ l
564
+ ]), c(() => g.current(), [
565
+ i.activity,
566
+ i.idleMotion,
567
+ i.motionSpeed,
568
+ i.motionIntensity,
569
+ i.splashes
570
+ ]);
495
571
  }
496
572
  //#endregion
497
573
  //#region src/LiquidPresence.tsx
498
- function F(e) {
499
- let n = o() || e.reducedMotion === !0, r = b(e.size ?? 64, 32, 224), i = `presence-${c().replace(/[^a-zA-Z0-9_-]/g, "")}`, a = l(null), h = l(null), [g, _] = u(null);
500
- s(() => {
574
+ function G(e) {
575
+ let t = s() || e.reducedMotion === !0, r = T(e.size ?? 64, 32, 224), i = `presence-${l().replace(/[^a-zA-Z0-9_-]/g, "")}`, a = d(null), o = d(null), [u, _] = f(null);
576
+ c(() => {
501
577
  let t = e.target?.contextElement?.closest("dialog");
502
578
  _(t ?? a.current?.closest("dialog") ?? document.body);
503
- }, [e.target?.contextElement]), s(() => {
504
- let e = a.current, t = h.current;
579
+ }, [e.target?.contextElement]), c(() => {
580
+ let e = a.current, t = o.current;
505
581
  if (!e || !t) return;
506
582
  let n = [
507
583
  "--liquid-presence-from",
@@ -512,7 +588,16 @@ function F(e) {
512
588
  "--game-ui-text",
513
589
  "--game-ui-font-body",
514
590
  "--game-ui-radius-control",
515
- "--game-ui-shadow-button"
591
+ "--game-ui-shadow-button",
592
+ "--game-ui-surface-raised",
593
+ "--game-ui-text-muted",
594
+ "--game-ui-border-subtle",
595
+ "--game-ui-border-ink",
596
+ "--game-ui-disabled",
597
+ "--game-ui-button-lip-ink",
598
+ "--game-ui-accent",
599
+ "--game-ui-accent-bright",
600
+ "--game-ui-accent-contrast"
516
601
  ], r = () => {
517
602
  let r = getComputedStyle(e);
518
603
  for (let e of n) {
@@ -532,11 +617,11 @@ function F(e) {
532
617
  return r(), window.addEventListener("resize", r, { passive: !0 }), () => {
533
618
  i.disconnect(), window.removeEventListener("resize", r);
534
619
  };
535
- }, [g]), P(a, h, {
620
+ }, [u]), W(a, o, {
536
621
  ...e,
537
622
  size: r,
538
- reducedMotion: n
539
- }, g);
623
+ reducedMotion: t
624
+ }, u);
540
625
  let v = {
541
626
  width: r,
542
627
  height: r,
@@ -546,26 +631,26 @@ function F(e) {
546
631
  "--liquid-presence-from": "var(--game-ui-warning)",
547
632
  "--liquid-presence-to": "var(--game-ui-warning)"
548
633
  } : {}
549
- }, y = (e, n) => /* @__PURE__ */ m("defs", { children: [/* @__PURE__ */ m("linearGradient", {
634
+ }, y = (e, t) => /* @__PURE__ */ g("defs", { children: [/* @__PURE__ */ g("linearGradient", {
550
635
  id: `${i}-${e}-fill`,
551
636
  gradientUnits: "userSpaceOnUse",
552
637
  x1: e === "core" ? 24 : -24,
553
638
  y1: e === "core" ? 16 : -18,
554
639
  x2: e === "core" ? 136 : 24,
555
640
  y2: e === "core" ? 146 : 18,
556
- children: [/* @__PURE__ */ p("stop", {
641
+ children: [/* @__PURE__ */ h("stop", {
557
642
  offset: "0",
558
643
  stopColor: "var(--liquid-presence-from, var(--game-ui-secondary))"
559
- }), /* @__PURE__ */ p("stop", {
644
+ }), /* @__PURE__ */ h("stop", {
560
645
  offset: "1",
561
646
  stopColor: "var(--liquid-presence-to, var(--game-ui-secondary))"
562
647
  })]
563
- }), /* @__PURE__ */ p("filter", {
648
+ }), /* @__PURE__ */ h("filter", {
564
649
  id: `${i}-${e}-goo`,
565
650
  filterUnits: "userSpaceOnUse",
566
- ...n,
651
+ ...t,
567
652
  colorInterpolationFilters: "sRGB",
568
- children: /* @__PURE__ */ p(t, {
653
+ children: /* @__PURE__ */ h(n, {
569
654
  blur: e === "core" ? 5 : 2,
570
655
  contrast: 18,
571
656
  gloss: 3.5,
@@ -574,13 +659,13 @@ function F(e) {
574
659
  waviness: 0
575
660
  })
576
661
  })] });
577
- return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", {
662
+ return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
578
663
  ref: a,
579
664
  className: `game-ui-liquid-presence ${e.className ?? ""}`,
580
665
  style: v,
581
666
  "data-activity": e.activity ?? "idle",
582
667
  "aria-hidden": "true",
583
- children: /* @__PURE__ */ m("svg", {
668
+ children: /* @__PURE__ */ g("svg", {
584
669
  viewBox: "0 0 160 160",
585
670
  focusable: "false",
586
671
  children: [y("core", {
@@ -588,15 +673,15 @@ function F(e) {
588
673
  y: -80,
589
674
  width: 320,
590
675
  height: 320
591
- }), /* @__PURE__ */ m("g", {
676
+ }), /* @__PURE__ */ g("g", {
592
677
  fill: `url(#${i}-core-fill)`,
593
678
  filter: `url(#${i}-core-goo)`,
594
679
  children: [
595
- /* @__PURE__ */ p("path", {
680
+ /* @__PURE__ */ h("path", {
596
681
  "data-presence-body": "",
597
- d: E()
682
+ d: M()
598
683
  }),
599
- /* @__PURE__ */ p("circle", {
684
+ /* @__PURE__ */ h("circle", {
600
685
  "data-presence-bud": "",
601
686
  cx: "80",
602
687
  cy: "80",
@@ -607,7 +692,7 @@ function F(e) {
607
692
  0,
608
693
  1,
609
694
  2
610
- ].map((e) => /* @__PURE__ */ p("circle", {
695
+ ].map((e) => /* @__PURE__ */ h("circle", {
611
696
  "data-presence-satellite": "",
612
697
  cx: "80",
613
698
  cy: "80",
@@ -617,8 +702,8 @@ function F(e) {
617
702
  ]
618
703
  })]
619
704
  })
620
- }), g && d(/* @__PURE__ */ m("div", {
621
- ref: h,
705
+ }), u && p(/* @__PURE__ */ g("div", {
706
+ ref: o,
622
707
  className: "game-ui-liquid-presence-overlay",
623
708
  style: {
624
709
  ...v,
@@ -627,7 +712,7 @@ function F(e) {
627
712
  },
628
713
  "data-presence-overlay": "",
629
714
  children: [
630
- /* @__PURE__ */ m("svg", {
715
+ /* @__PURE__ */ g("svg", {
631
716
  className: "game-ui-liquid-presence-flight",
632
717
  viewBox: "-48 -36 96 72",
633
718
  "aria-hidden": "true",
@@ -638,18 +723,18 @@ function F(e) {
638
723
  y: -36,
639
724
  width: 96,
640
725
  height: 72
641
- }), /* @__PURE__ */ p("g", {
726
+ }), /* @__PURE__ */ h("g", {
642
727
  fill: `url(#${i}-flight-fill)`,
643
728
  filter: `url(#${i}-flight-goo)`,
644
- children: /* @__PURE__ */ m("g", {
729
+ children: /* @__PURE__ */ g("g", {
645
730
  "data-presence-flight-body": "",
646
- children: [/* @__PURE__ */ p("circle", { r: "16" }), /* @__PURE__ */ m("g", {
731
+ children: [/* @__PURE__ */ h("circle", { r: "16" }), /* @__PURE__ */ g("g", {
647
732
  "data-presence-trail": "",
648
- children: [/* @__PURE__ */ p("circle", {
733
+ children: [/* @__PURE__ */ h("circle", {
649
734
  cx: "-27",
650
735
  cy: "5",
651
736
  r: "4.5"
652
- }), /* @__PURE__ */ p("circle", {
737
+ }), /* @__PURE__ */ h("circle", {
653
738
  cx: "-36",
654
739
  cy: "8",
655
740
  r: "2.5"
@@ -658,7 +743,7 @@ function F(e) {
658
743
  })
659
744
  })]
660
745
  }),
661
- /* @__PURE__ */ m("svg", {
746
+ /* @__PURE__ */ g("svg", {
662
747
  className: "game-ui-liquid-presence-seat",
663
748
  viewBox: "-56 -28 112 56",
664
749
  "aria-hidden": "true",
@@ -669,21 +754,452 @@ function F(e) {
669
754
  y: -28,
670
755
  width: 112,
671
756
  height: 56
672
- }), /* @__PURE__ */ p("path", {
757
+ }), /* @__PURE__ */ h("path", {
673
758
  "data-presence-seat-body": "",
674
- d: D(48, 1),
759
+ d: N(48, 1),
675
760
  fill: `url(#${i}-seat-fill)`,
676
761
  filter: `url(#${i}-seat-goo)`
677
762
  })]
678
763
  }),
679
- /* @__PURE__ */ p("span", {
680
- className: "game-ui-liquid-presence-label",
681
- role: "status",
682
- "aria-atomic": "true",
683
- hidden: !0
764
+ /* @__PURE__ */ h("div", {
765
+ className: `game-ui-liquid-presence-label${e.guideContent ? " game-ui-liquid-presence-label--guide" : ""}${e.guideContent && e.guideSize === "expanded" ? " game-ui-liquid-presence-label--expanded" : ""}`,
766
+ role: e.guideContent ? void 0 : "status",
767
+ "aria-atomic": !e.guideContent || void 0,
768
+ onClick: e.guideContent ? (e) => e.stopPropagation() : void 0,
769
+ onPointerDown: e.guideContent ? (e) => e.stopPropagation() : void 0,
770
+ onKeyDown: e.guideContent ? (e) => {
771
+ e.stopPropagation(), e.key === "Escape" && e.preventDefault();
772
+ } : void 0,
773
+ hidden: !0,
774
+ children: e.guideContent ?? e.target?.label.slice(0, 240)
684
775
  })
685
776
  ]
686
- }), g)] });
777
+ }), u)] });
778
+ }
779
+ //#endregion
780
+ //#region src/liquidRevealGeometry.ts
781
+ function K(e, n, r, a = 0, o = 1) {
782
+ let s = Math.max(44, e), c = Math.max(44, n), l = Math.min(28, (s - 12) / 2, (c - 12) / 2), u = i(6, 6, s - 12, c - 12, [
783
+ l,
784
+ l,
785
+ l,
786
+ l
787
+ ], {
788
+ amplitude: (r ? 8 : 11) * Math.min(1.25, Math.max(.25, Number.isFinite(o) ? o : 1)),
789
+ lobes: 3,
790
+ seed: 17,
791
+ phase: a
792
+ }), d = Math.max(0, l - 2.5);
793
+ return {
794
+ outline: u,
795
+ ribbon: `${u} ${t(8.5, 8.5, s - 17, c - 17, [
796
+ d,
797
+ d,
798
+ d,
799
+ d
800
+ ])}`
801
+ };
802
+ }
803
+ //#endregion
804
+ //#region src/useLiquidRevealAmbient.ts
805
+ function q(t, n, i, o, s, l = 1, u = 1) {
806
+ let f = d(0);
807
+ return c(() => {
808
+ let c = t.current;
809
+ if (!c || !n || !i || !o) {
810
+ c && (c.dataset.revealAmbient = "static");
811
+ return;
812
+ }
813
+ let d = !0, p = !0, m = performance.now(), h = () => {}, g = c.querySelector("[data-reveal-outline]"), _ = c.querySelector("[data-reveal-body]"), v = c.querySelector("[data-reveal-ribbon]"), y = (i + 24) * (o + 24), b = (t) => {
814
+ if (!d || !p || document.hidden) return;
815
+ let n = Math.min(160, Math.max(0, t - m));
816
+ m = t;
817
+ let x = document.querySelector("dialog:modal"), S = x && !x.contains(c) || ["drawing", "preparing"].includes(c.dataset.revealMotion ?? ""), C = a();
818
+ if (S || C.activeGroups > 0 || !e(y)) {
819
+ c.dataset.revealAmbient = "paused", h = te(b, 250);
820
+ return;
821
+ }
822
+ try {
823
+ f.current += n * Math.PI * 2 * u / 1e4;
824
+ let e = K(i, o, s, f.current, l);
825
+ g?.setAttribute("d", e.outline), _?.setAttribute("d", e.outline), v?.setAttribute("d", e.ribbon), c.dataset.revealAmbient = "flowing";
826
+ } finally {
827
+ r();
828
+ }
829
+ h = te(b);
830
+ }, x = () => {
831
+ h(), m = performance.now(), c.dataset.revealAmbient = "paused", p && !document.hidden && (h = te(b));
832
+ }, S = typeof IntersectionObserver > "u" ? null : new IntersectionObserver((e) => {
833
+ p = e[0]?.isIntersecting ?? !1, x();
834
+ });
835
+ return S?.observe(c), document.addEventListener("visibilitychange", x), x(), () => {
836
+ d = !1, h(), S?.disconnect(), document.removeEventListener("visibilitychange", x), c.dataset.revealAmbient = "static";
837
+ };
838
+ }, [
839
+ t,
840
+ n,
841
+ i,
842
+ o,
843
+ s,
844
+ l,
845
+ u
846
+ ]), f;
847
+ }
848
+ //#endregion
849
+ //#region src/liquidRevealEntranceGeometry.ts
850
+ var J = (e) => {
851
+ let t = Math.min(1, Math.max(0, e));
852
+ return t * t * t * (10 + t * (-15 + 6 * t));
853
+ };
854
+ function Y(e, t, n, r, a, o, s = 1) {
855
+ let c = K(e, t, n, 0, s).outline;
856
+ return Array.from({ length: 49 }, (l, u) => {
857
+ let d = u / 48, f = J((d - .08) / .34), p = j(r, a, f, o), m = J((d - .39) / .46), h = J((d - .47) / .46), g = J((d - .3) / .14) * (1 - m), _ = 8 + 20 * J(d / .15) + 10 * g, v = 1 + Math.sin(f * Math.PI) * .35, y = a.x - r.x, b = a.y - r.y, x = Math.abs(y) > Math.abs(b), S = _ * (x ? v : 1 / Math.sqrt(v)), C = _ * (x ? 1 / Math.sqrt(v) : v), w = S + (e - 12 - S) * m, T = C + (t - 12 - C) * h, E = (p.x - S / 2) * (1 - m) + 6 * m, D = (p.y - C / 2) * (1 - h) + 6 * h, O = Math.min(w / 2, T / 2, 28 + 12 * (1 - h));
858
+ return {
859
+ d: `path("${d >= .95 ? c : i(E, D, w, T, [
860
+ O,
861
+ O,
862
+ O,
863
+ O
864
+ ], {
865
+ amplitude: 1.2 + ((n ? 8 : 11) * s - 1.2) * h,
866
+ seed: 17,
867
+ lobes: 3,
868
+ phase: 0
869
+ })}")`,
870
+ offset: d
871
+ };
872
+ });
873
+ }
874
+ //#endregion
875
+ //#region src/useLiquidRevealEntrance.ts
876
+ function X(t, n, i, a, o, s, c, l, f = 1) {
877
+ let p = d(null);
878
+ u(() => {
879
+ let u = t.current;
880
+ if (!u) return;
881
+ if (!n || s || u.contains(document.activeElement) || window.matchMedia("(forced-colors: active)").matches) {
882
+ p.current = i, u.dataset.revealMotion = "static";
883
+ return;
884
+ }
885
+ if (p.current === i || (u.dataset.revealMotion = "preparing", !a || !o)) return;
886
+ let d = !0, m = !1, h = !1, g = 0, _ = 0, v = [], y = () => {
887
+ v.forEach((e) => e.cancel()), v.length = 0, m && r(), m = !1, u.dataset.revealMotion = h ? "settled" : "static";
888
+ }, b = () => {
889
+ if (!d) return;
890
+ if (getComputedStyle(u).visibility === "hidden") {
891
+ if (++_ < 12) {
892
+ g = requestAnimationFrame(b);
893
+ return;
894
+ }
895
+ y();
896
+ return;
897
+ }
898
+ let t = n.current?.getBoundingClientRect(), r = u.getBoundingClientRect(), s = u.querySelector("[data-reveal-body]"), x = u.querySelector("[data-reveal-material]"), S = u.querySelector(".game-ui-liquid-reveal-content");
899
+ if (p.current = i, u.contains(document.activeElement) || !t || !E(t) || document.hidden || typeof u.animate != "function" || !e((a + 24) * (o + 24))) {
900
+ y();
901
+ return;
902
+ }
903
+ m = !0, h = !0, u.dataset.revealMotion = "drawing";
904
+ let C = r.width / a || 1, w = r.height / o || 1, T = {
905
+ x: (t.x + t.width / 2 - r.x) / C,
906
+ y: (t.y + t.height / 2 - r.y) / w
907
+ }, D = {
908
+ x: Math.min(a - 28, Math.max(28, T.x)),
909
+ y: T.y > o / 2 ? o - 28 : 28
910
+ }, O = {
911
+ x: -r.x / C,
912
+ y: -r.y / w,
913
+ width: innerWidth / C,
914
+ height: innerHeight / w
915
+ };
916
+ if (c && s && CSS.supports("d", "path(\"M0 0L1 1Z\")")) {
917
+ let e = Y(a, o, l, T, D, O, f);
918
+ v.push(s.animate(e, {
919
+ duration: 720,
920
+ fill: "both",
921
+ easing: "linear"
922
+ })), x && v.push(x.animate([
923
+ { opacity: 0 },
924
+ {
925
+ opacity: 0,
926
+ offset: .93
927
+ },
928
+ { opacity: 1 }
929
+ ], {
930
+ duration: 720,
931
+ fill: "both"
932
+ })), S && v.push(S.animate([
933
+ { opacity: 0 },
934
+ {
935
+ opacity: 0,
936
+ offset: .78
937
+ },
938
+ {
939
+ opacity: 1,
940
+ offset: .98
941
+ },
942
+ { opacity: 1 }
943
+ ], {
944
+ duration: 720,
945
+ fill: "both"
946
+ }));
947
+ } else x && v.push(x.animate([{ opacity: .2 }, { opacity: 1 }], { duration: 180 }));
948
+ let k = n.current?.querySelector(".game-ui-liquid-presence > svg");
949
+ k && v.push(k.animate([
950
+ { transform: "scale(1)" },
951
+ {
952
+ transform: "scale(1.05, .9)",
953
+ offset: .22
954
+ },
955
+ {
956
+ transform: "scale(.96, 1.04)",
957
+ offset: .5
958
+ },
959
+ { transform: "scale(1)" }
960
+ ], {
961
+ duration: 440,
962
+ easing: "ease-in-out"
963
+ })), Promise.all(v.map((e) => e.finished)).then(y, y);
964
+ };
965
+ g = requestAnimationFrame(b);
966
+ let x = () => {
967
+ cancelAnimationFrame(g), y();
968
+ }, S = () => {
969
+ document.hidden && x();
970
+ };
971
+ return u.addEventListener("focusin", x), u.addEventListener("pointerdown", x, !0), document.addEventListener("visibilitychange", S), window.addEventListener("resize", x), window.addEventListener("scroll", x, !0), () => {
972
+ d = !1, x(), u.removeEventListener("focusin", x), u.removeEventListener("pointerdown", x, !0), document.removeEventListener("visibilitychange", S), window.removeEventListener("resize", x), window.removeEventListener("scroll", x, !0);
973
+ };
974
+ }, [
975
+ t,
976
+ n,
977
+ i,
978
+ a,
979
+ o,
980
+ s,
981
+ c,
982
+ l,
983
+ f
984
+ ]);
985
+ }
986
+ //#endregion
987
+ //#region src/LiquidReveal.tsx
988
+ function se({ children: e, source: t, revealKey: r = "initial", variant: i = "content", surface: o = "dark", reducedMotion: c, idleMotion: p = "still", colorFrom: m, colorTo: _, motionIntensity: v = 1, motionSpeed: y = 1, className: b = "" }) {
989
+ let x = s() || c === !0, S = T(v, .25, 1.25), C = T(y, .5, 1.5), w = d(null), [E, D] = f({
990
+ width: 0,
991
+ height: 0
992
+ }), O = `liquid-reveal-${l().replace(/[^a-zA-Z0-9_-]/g, "")}`;
993
+ u(() => {
994
+ let e = w.current;
995
+ if (!e) return;
996
+ let t = () => {
997
+ let t = e.clientWidth, n = e.clientHeight;
998
+ D((e) => e.width === t && e.height === n ? e : {
999
+ width: t,
1000
+ height: n
1001
+ });
1002
+ };
1003
+ t();
1004
+ let n = new ResizeObserver(t);
1005
+ return n.observe(e), () => n.disconnect();
1006
+ }, []), X(w, t, r, E.width, E.height, x, o === "material", i === "input", S);
1007
+ let k = Math.max(44, E.width), A = Math.max(44, E.height), ee = q(w, !x && p === "breathe", E.width, E.height, i === "input", S, C), j = K(k, A, i === "input", ee.current, S), M = (k + 24) * (A + 24) <= a().maxFilterArea;
1008
+ return /* @__PURE__ */ g("div", {
1009
+ ref: w,
1010
+ className: `game-ui-liquid-reveal ${b}`,
1011
+ style: {
1012
+ ...m ? { "--liquid-presence-from": m } : {},
1013
+ ..._ ? { "--liquid-presence-to": _ } : {}
1014
+ },
1015
+ "data-reveal-variant": i,
1016
+ "data-reveal-surface": o,
1017
+ "data-reveal-filter": M ? "volume" : "flat",
1018
+ children: [/* @__PURE__ */ h("div", {
1019
+ className: "game-ui-liquid-reveal-content",
1020
+ children: e
1021
+ }), E.width > 0 && /* @__PURE__ */ g("svg", {
1022
+ className: "game-ui-liquid-reveal-ink",
1023
+ width: k,
1024
+ height: A,
1025
+ viewBox: `0 0 ${k} ${A}`,
1026
+ "aria-hidden": "true",
1027
+ focusable: "false",
1028
+ children: [
1029
+ /* @__PURE__ */ g("defs", { children: [/* @__PURE__ */ g("linearGradient", {
1030
+ id: `${O}-fill`,
1031
+ x1: "0",
1032
+ y1: "0",
1033
+ x2: "1",
1034
+ y2: "1",
1035
+ children: [/* @__PURE__ */ h("stop", {
1036
+ offset: "0",
1037
+ stopColor: "var(--liquid-presence-from, var(--game-ui-secondary))"
1038
+ }), /* @__PURE__ */ h("stop", {
1039
+ offset: "1",
1040
+ stopColor: "var(--liquid-presence-to, var(--game-ui-secondary))"
1041
+ })]
1042
+ }), /* @__PURE__ */ h("filter", {
1043
+ id: `${O}-finish`,
1044
+ x: "-12",
1045
+ y: "-12",
1046
+ width: k + 24,
1047
+ height: A + 24,
1048
+ filterUnits: "userSpaceOnUse",
1049
+ colorInterpolationFilters: "sRGB",
1050
+ children: /* @__PURE__ */ h(n, {
1051
+ blur: 1.2,
1052
+ contrast: 18,
1053
+ gloss: 3.5,
1054
+ shadows: [],
1055
+ stroke: null,
1056
+ waviness: 0
1057
+ })
1058
+ })] }),
1059
+ o === "material" && /* @__PURE__ */ h("path", {
1060
+ "data-reveal-body": "",
1061
+ d: j.outline,
1062
+ fill: `url(#${O}-fill)`
1063
+ }),
1064
+ /* @__PURE__ */ g("g", {
1065
+ "data-reveal-material": "",
1066
+ filter: M ? `url(#${O}-finish)` : void 0,
1067
+ children: [/* @__PURE__ */ h("path", {
1068
+ "data-reveal-ribbon": "",
1069
+ d: j.ribbon,
1070
+ fillRule: "evenodd",
1071
+ fill: `url(#${O}-fill)`
1072
+ }), /* @__PURE__ */ h("path", {
1073
+ "data-reveal-outline": "",
1074
+ d: j.outline,
1075
+ pathLength: "1",
1076
+ fill: "none",
1077
+ stroke: `url(#${O}-fill)`,
1078
+ strokeWidth: "1.2",
1079
+ strokeLinecap: "round"
1080
+ })]
1081
+ })
1082
+ ]
1083
+ })]
1084
+ });
1085
+ }
1086
+ //#endregion
1087
+ //#region src/LiquidAnchor.tsx
1088
+ function Z({ source: e, children: t, placement: n = "top-end", onBoundsChange: r }) {
1089
+ let [i, a] = f(null), o = d(r);
1090
+ o.current = r;
1091
+ let [s, c] = f(null);
1092
+ return u(() => {
1093
+ c(e.current?.closest("dialog") ?? document.body);
1094
+ }, [e]), u(() => {
1095
+ let t = e.current, r = i;
1096
+ if (!t || !r) return;
1097
+ let a = !0, s = 0, c = null, l = null, u = () => {
1098
+ let e = getComputedStyle(t);
1099
+ for (let t of Array.from(e)) if (t.startsWith("--game-ui-") || t.startsWith("--liquid-presence-")) {
1100
+ let n = e.getPropertyValue(t);
1101
+ r.style.getPropertyValue(t) !== n && r.style.setProperty(t, n);
1102
+ }
1103
+ let n = t.querySelector(".game-ui-liquid-presence");
1104
+ if (n) {
1105
+ let e = getComputedStyle(n);
1106
+ for (let t of ["--liquid-presence-from", "--liquid-presence-to"]) r.style.setProperty(t, e.getPropertyValue(t));
1107
+ }
1108
+ }, d = () => {
1109
+ let e = ++s, i = t.getBoundingClientRect(), u = document.querySelector("dialog:modal");
1110
+ if (c !== u && (l?.disconnect(), l = null, c = u, u && !u.contains(t) && !r.contains(u) && (l = new MutationObserver(() => {
1111
+ (!u.isConnected || !u.matches(":modal")) && d();
1112
+ }), l.observe(u, {
1113
+ attributes: !0,
1114
+ attributeFilter: ["open"]
1115
+ }), u.parentNode && l.observe(u.parentNode, { childList: !0 }))), !t.isConnected || t.closest("[hidden], [inert], [aria-hidden=\"true\"]") || typeof t.checkVisibility == "function" && !t.checkVisibility({
1116
+ opacityProperty: !0,
1117
+ visibilityProperty: !0
1118
+ }) || i.width <= 0 || i.height <= 0 || u && !u.contains(t) && !r.contains(u)) {
1119
+ r.style.visibility = "hidden", o.current?.(null);
1120
+ return;
1121
+ }
1122
+ y(t, r, {
1123
+ strategy: "fixed",
1124
+ placement: n,
1125
+ middleware: [
1126
+ S(14),
1127
+ b({ padding: 12 }),
1128
+ C({
1129
+ padding: 12,
1130
+ crossAxis: !0
1131
+ }),
1132
+ w({
1133
+ padding: 12,
1134
+ apply({ availableHeight: e, availableWidth: t }) {
1135
+ r.dataset.liquidCompact = e < 500 ? "true" : "false", r.style.setProperty("--liquid-outlet-height", `${Math.max(0, e)}px`), r.style.maxWidth = `${Math.max(0, t)}px`;
1136
+ }
1137
+ }),
1138
+ x({ strategy: "referenceHidden" })
1139
+ ]
1140
+ }).then(({ x: t, y: n, middlewareData: i }) => {
1141
+ if (!a || e !== s) return;
1142
+ if (i.hide?.referenceHidden) {
1143
+ r.style.visibility = "hidden", o.current?.(null);
1144
+ return;
1145
+ }
1146
+ r.style.left = `${t}px`, r.style.top = `${n}px`, r.style.visibility = "visible";
1147
+ let c = r.getBoundingClientRect();
1148
+ o.current?.({
1149
+ x: c.x,
1150
+ y: c.y,
1151
+ width: c.width,
1152
+ height: c.height
1153
+ });
1154
+ }).catch(() => {
1155
+ !a || e !== s || (r.style.visibility = "hidden", o.current?.(null));
1156
+ });
1157
+ };
1158
+ u();
1159
+ let f = v(t, r, d), p = new MutationObserver(() => {
1160
+ u(), d();
1161
+ });
1162
+ for (let e = t; e; e = e.parentElement) p.observe(e, {
1163
+ attributes: !0,
1164
+ attributeFilter: [
1165
+ "class",
1166
+ "style",
1167
+ "data-game-ui-theme",
1168
+ "hidden",
1169
+ "inert",
1170
+ "aria-hidden"
1171
+ ]
1172
+ });
1173
+ let m = t.querySelector(".game-ui-liquid-presence");
1174
+ return m && p.observe(m, {
1175
+ attributes: !0,
1176
+ attributeFilter: [
1177
+ "class",
1178
+ "style",
1179
+ "data-activity"
1180
+ ]
1181
+ }), document.addEventListener("toggle", d, !0), document.addEventListener("close", d, !0), () => {
1182
+ a = !1, s++, f(), p.disconnect(), l?.disconnect(), document.removeEventListener("toggle", d, !0), document.removeEventListener("close", d, !0), o.current?.(null);
1183
+ };
1184
+ }, [
1185
+ i,
1186
+ n,
1187
+ e
1188
+ ]), s ? /* @__PURE__ */ h(_, {
1189
+ root: s,
1190
+ preserveTabOrder: !1,
1191
+ children: /* @__PURE__ */ h("div", {
1192
+ ref: a,
1193
+ className: "game-ui-liquid-anchor",
1194
+ style: {
1195
+ position: "fixed",
1196
+ top: 0,
1197
+ left: 0,
1198
+ visibility: "hidden"
1199
+ },
1200
+ children: t
1201
+ })
1202
+ }) : null;
687
1203
  }
688
1204
  //#endregion
689
- export { F as LiquidPresence };
1205
+ export { Z as LiquidAnchor, G as LiquidPresence, se as LiquidReveal };