@ssgoi/core 7.2.0 → 7.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/animation/animation.d.ts +21 -0
  2. package/dist/animation/animation.d.ts.map +1 -1
  3. package/dist/animation/host-animation.d.ts +28 -19
  4. package/dist/animation/host-animation.d.ts.map +1 -1
  5. package/dist/animation/multi-animation.d.ts +13 -2
  6. package/dist/animation/multi-animation.d.ts.map +1 -1
  7. package/dist/animation/web-animation.d.ts +69 -3
  8. package/dist/animation/web-animation.d.ts.map +1 -1
  9. package/dist/animation/web-presentation.d.ts +25 -0
  10. package/dist/animation/web-presentation.d.ts.map +1 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1206 -1184
  15. package/dist/internal.cjs +1 -1
  16. package/dist/internal.js +924 -631
  17. package/dist/{page-motion-MEazegOU.js → page-motion-CoPTk-Gd.js} +1 -1
  18. package/dist/{page-motion-DF3fFkOw.cjs → page-motion-Dhj3UfzO.cjs} +1 -1
  19. package/dist/provider-BLf6XeXT.js +291 -0
  20. package/dist/provider-JDtJ5Jzf.cjs +1 -0
  21. package/dist/retain-opacity-BFlsDhI7.cjs +1 -0
  22. package/dist/retain-opacity-Dvv9gi8-.js +1141 -0
  23. package/dist/runtime/index.d.ts +1 -0
  24. package/dist/runtime/index.d.ts.map +1 -1
  25. package/dist/runtime/motion-matching.d.ts +31 -0
  26. package/dist/runtime/motion-matching.d.ts.map +1 -0
  27. package/dist/runtime/timeline.d.ts +6 -2
  28. package/dist/runtime/timeline.d.ts.map +1 -1
  29. package/dist/runtime.cjs +1 -1
  30. package/dist/runtime.js +29 -25
  31. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  32. package/dist/transitions/blind/transition.d.ts.map +1 -1
  33. package/dist/transitions/crossfade.d.ts +1 -6
  34. package/dist/transitions/crossfade.d.ts.map +1 -1
  35. package/dist/transitions/film/transition.d.ts.map +1 -1
  36. package/dist/transitions/hero/in-place.d.ts +5 -2
  37. package/dist/transitions/hero/in-place.d.ts.map +1 -1
  38. package/dist/transitions/hero/provider/chrome/fade.d.ts.map +1 -1
  39. package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
  40. package/dist/transitions/hero/transition.d.ts.map +1 -1
  41. package/dist/transitions/hero/types.d.ts +2 -1
  42. package/dist/transitions/hero/types.d.ts.map +1 -1
  43. package/dist/transitions/shared-visibility.d.ts +2 -0
  44. package/dist/transitions/shared-visibility.d.ts.map +1 -0
  45. package/dist/transitions/sheet/transition.d.ts.map +1 -1
  46. package/dist/transitions/zoom/crossfade.d.ts.map +1 -1
  47. package/dist/transitions/zoom/provider/blur.d.ts.map +1 -1
  48. package/dist/transitions/zoom/transition.d.ts.map +1 -1
  49. package/dist/transitions/zoom/types.d.ts +2 -1
  50. package/dist/transitions/zoom/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +4 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/utils/index.d.ts +1 -0
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/retain-opacity.d.ts +7 -0
  56. package/dist/utils/retain-opacity.d.ts.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/multi-animation-Du9W3ZS_.js +0 -503
  59. package/dist/multi-animation-hDUcfD7W.cjs +0 -1
  60. package/dist/provider-Cea0Pfm1.js +0 -232
  61. package/dist/provider-D9Q2URox.cjs +0 -1
@@ -0,0 +1,1141 @@
1
+ var ht = Object.defineProperty;
2
+ var ct = (s, r, t) => r in s ? ht(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
3
+ var h = (s, r, t) => ct(s, typeof r != "symbol" ? r + "" : r, t);
4
+ import { A as ut, c as K, a as dt, r as pt, i as ft, s as mt, I as gt } from "./provider-BLf6XeXT.js";
5
+ const D = {
6
+ reason: "finished",
7
+ owns: () => !0
8
+ };
9
+ class st extends ut {
10
+ constructor() {
11
+ super(...arguments);
12
+ h(this, "_startCondition");
13
+ /** Resource cleanup is separate from successfully reaching the authored goal. */
14
+ h(this, "onDispose");
15
+ /** A composite retains child resources until all participating motion settles. */
16
+ h(this, "deferDisposal", !1);
17
+ }
18
+ /** Custom wrappers can expose their web tracks without host type checks. */
19
+ getMotionTracks() {
20
+ return [];
21
+ }
22
+ /** Validate authored scheduling before a host transfers ownership. */
23
+ validate() {
24
+ }
25
+ /** Opaque custom drivers retain the explicit legacy finish-on-interrupt fallback. */
26
+ get supportsInterruption() {
27
+ return !1;
28
+ }
29
+ /** Invalidate execution without disposing its retained resources. */
30
+ stop() {
31
+ this.pause();
32
+ }
33
+ /** Stop without seeking to an endpoint. Built-in drivers override this. */
34
+ cancel(t) {
35
+ var e;
36
+ this.isComplete || this.complete(), (e = this.onDispose) == null || e.call(this, t);
37
+ }
38
+ /** Scheduling metadata read by the parent immediately before playback. */
39
+ get startCondition() {
40
+ return this._startCondition;
41
+ }
42
+ /** Retune this animation before playback; omitted values stay unchanged. */
43
+ set(t) {
44
+ if (t.startAt) {
45
+ const { after: e, at: i } = t.startAt;
46
+ if (e === this)
47
+ throw new Error("An animation cannot start after itself");
48
+ if (i !== "settled" && (!Number.isFinite(i) || i < 0 || i > 1))
49
+ throw new Error("startAt.at must be a progress from 0 to 1 or settled");
50
+ }
51
+ if (t.integrator !== void 0) {
52
+ if (typeof t.integrator.step != "function" || typeof t.integrator.isSettled != "function")
53
+ throw new Error("An integrator must implement step and isSettled");
54
+ this.setIntegrator(t.integrator);
55
+ }
56
+ return t.startAt !== void 0 && (this._startCondition = t.startAt ? { ...t.startAt } : void 0), this;
57
+ }
58
+ /** Custom drivers can opt into physics editing by implementing this method. */
59
+ setIntegrator(t) {
60
+ throw new Error("This animation does not support replacing its integrator");
61
+ }
62
+ }
63
+ function yt(s) {
64
+ return new Promise((r) => {
65
+ requestAnimationFrame(() => {
66
+ requestAnimationFrame(() => {
67
+ r();
68
+ });
69
+ });
70
+ });
71
+ }
72
+ const H = [1, 0, 0, 1, 0, 0], it = (s, r) => [
73
+ s[0] * r[0] + s[2] * r[1],
74
+ s[1] * r[0] + s[3] * r[1],
75
+ s[0] * r[2] + s[2] * r[3],
76
+ s[1] * r[2] + s[3] * r[3],
77
+ s[0] * r[4] + s[2] * r[5] + s[4],
78
+ s[1] * r[4] + s[3] * r[5] + s[5]
79
+ ];
80
+ function G(s) {
81
+ const r = s[0] * s[3] - s[1] * s[2];
82
+ return Math.abs(r) < 1e-10 ? null : [
83
+ s[3] / r,
84
+ -s[1] / r,
85
+ -s[2] / r,
86
+ s[0] / r,
87
+ (s[2] * s[5] - s[3] * s[4]) / r,
88
+ (s[1] * s[4] - s[0] * s[5]) / r
89
+ ];
90
+ }
91
+ const I = (s, r) => [1, 0, 0, 1, s, r], U = (s, r) => [s, 0, 0, r, 0, 0];
92
+ function vt(s, r, t) {
93
+ if (!s || s === "none") return [...H];
94
+ let e = [...H];
95
+ const i = /([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;
96
+ let o = "";
97
+ for (const c of s.matchAll(i)) {
98
+ o += c[0];
99
+ const d = c[1].toLowerCase(), u = c[2].trim().split(/\s*,\s*|\s+/);
100
+ if (u.some(
101
+ (n) => !/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(
102
+ n
103
+ )
104
+ ))
105
+ return null;
106
+ const p = u.map(Number.parseFloat);
107
+ if (p.some((n) => !Number.isFinite(n))) return null;
108
+ const g = (n, y) => {
109
+ var l;
110
+ return p[n] * ((l = u[n]) != null && l.endsWith("%") ? y / 100 : 1);
111
+ }, f = (n) => {
112
+ var y, l;
113
+ return p[n] * ((y = u[n]) != null && y.endsWith("rad") ? 1 : (l = u[n]) != null && l.endsWith("turn") ? 2 * Math.PI : Math.PI / 180);
114
+ };
115
+ let a;
116
+ if (d === "matrix" && p.length === 6) a = p;
117
+ else if (d === "translate" || d === "translate3d") {
118
+ if (d === "translate3d" && p[2] !== 0) return null;
119
+ a = I(g(0, r), u[1] ? g(1, t) : 0);
120
+ } else if (d === "translatex") a = I(g(0, r), 0);
121
+ else if (d === "translatey") a = I(0, g(0, t));
122
+ else if (d === "translatez" && p[0] === 0) a = [...H];
123
+ else if (d === "scale") a = U(p[0], p[1] ?? p[0]);
124
+ else if (d === "scalex") a = U(p[0], 1);
125
+ else if (d === "scaley") a = U(1, p[0]);
126
+ else if (d === "rotate" || d === "rotatez") {
127
+ const n = f(0);
128
+ a = [Math.cos(n), Math.sin(n), -Math.sin(n), Math.cos(n), 0, 0];
129
+ } else return null;
130
+ e = it(e, a);
131
+ }
132
+ return o.replace(/\s/g, "") === s.replace(/\s/g, "") ? e : null;
133
+ }
134
+ function J(s, r) {
135
+ return { schema: s, value: r, velocity: r.map(() => 0) };
136
+ }
137
+ const Q = /[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi, A = (s) => [
138
+ s[0],
139
+ s[2],
140
+ s[4],
141
+ s[1],
142
+ s[3],
143
+ s[5],
144
+ 0,
145
+ 0,
146
+ 1
147
+ ];
148
+ function B(s, r) {
149
+ return Array.from({ length: 9 }, (t, e) => {
150
+ const i = Math.floor(e / 3), o = e % 3;
151
+ return s[i * 3] * r[o] + s[i * 3 + 1] * r[o + 3] + s[i * 3 + 2] * r[o + 6];
152
+ });
153
+ }
154
+ function rt(s) {
155
+ return Math.abs(s[8]) < 1e-8 || !s.every(Number.isFinite) ? null : s.map((r) => r / s[8]);
156
+ }
157
+ function tt(s, r, t) {
158
+ const e = vt(s, r, t);
159
+ if (e) return A(e);
160
+ if (typeof DOMMatrix > "u") return null;
161
+ const i = s.replace(
162
+ /(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,
163
+ (o, c, d) => {
164
+ const u = d.split(/\s*,\s*|\s+/).map((p, g) => {
165
+ if (!p.endsWith("%")) return p;
166
+ const f = c.toLowerCase() === "translatey" || g === 1 ? t : r;
167
+ return `${Number.parseFloat(p) * f / 100}px`;
168
+ });
169
+ return `${c}(${u.join(",")})`;
170
+ }
171
+ );
172
+ try {
173
+ const o = new DOMMatrix(i);
174
+ return rt([
175
+ o.m11,
176
+ o.m21,
177
+ o.m41,
178
+ o.m12,
179
+ o.m22,
180
+ o.m42,
181
+ o.m14,
182
+ o.m24,
183
+ o.m44
184
+ ]);
185
+ } catch {
186
+ return null;
187
+ }
188
+ }
189
+ const et = "viewport-plane-v1";
190
+ function L(s) {
191
+ var C;
192
+ const r = s.offsetWidth || 1, t = s.offsetHeight || 1, e = typeof getComputedStyle == "function" ? getComputedStyle(s) : null, i = ((e == null ? void 0 : e.transformOrigin) || `${r / 2}px ${t / 2}px`).split(" "), o = Number.parseFloat(i[0]) || 0, c = Number.parseFloat(i[1]) || 0;
193
+ let d = !0;
194
+ if (typeof getComputedStyle == "function")
195
+ for (let w = s.parentElement; w; w = w.parentElement) {
196
+ const S = getComputedStyle(w);
197
+ if (S.transform && S.transform !== "none" || S.perspective && S.perspective !== "none") {
198
+ d = !1;
199
+ break;
200
+ }
201
+ }
202
+ const u = (C = s.getBoundingClientRect) == null ? void 0 : C.call(s), p = tt((e == null ? void 0 : e.transform) || "", r, t) ?? A(H), g = B(
203
+ B(A(I(o, c)), p),
204
+ A(I(-o, -c))
205
+ ), f = [
206
+ [0, 0],
207
+ [r, 0],
208
+ [0, t],
209
+ [r, t]
210
+ ].map(([w, S]) => {
211
+ const F = g[6] * w + g[7] * S + g[8];
212
+ return [
213
+ (g[0] * w + g[1] * S + g[2]) / F,
214
+ (g[3] * w + g[4] * S + g[5]) / F
215
+ ];
216
+ }), a = ((u == null ? void 0 : u.left) ?? 0) - Math.min(...f.map((w) => w[0])), n = ((u == null ? void 0 : u.top) ?? 0) - Math.min(...f.map((w) => w[1])), y = I(a + o, n + c), l = it(I(-o, -c), U(r, t)), m = A(G(y)), b = A(G(l));
217
+ return {
218
+ frame: d ? { left: a, top: n, width: r, height: t } : void 0,
219
+ read(w) {
220
+ const S = {};
221
+ for (const [F, M] of Object.entries(w)) {
222
+ const k = String(M);
223
+ if (F === "transform") {
224
+ if (!d) continue;
225
+ const R = tt(k, r, t), x = R && rt(B(B(A(y), R), A(l)));
226
+ if (x) {
227
+ const [q, j, T, O, V, P, E, v] = x, W = q - T * E, N = O - P * E, Z = j - T * v, Y = V - P * v, z = Math.hypot(W, N);
228
+ if (z > 1e-8) {
229
+ S[F] = J(et, [
230
+ T,
231
+ P,
232
+ Math.atan2(N, W),
233
+ z,
234
+ (W * Y - N * Z) / z,
235
+ (W * Z + N * Y) / z,
236
+ E,
237
+ v
238
+ ]);
239
+ continue;
240
+ }
241
+ }
242
+ }
243
+ const _ = [...k.matchAll(Q)].map(
244
+ (R) => Number(R[0])
245
+ );
246
+ _.length && _.every(Number.isFinite) && (S[F] = J(
247
+ `css:${k.replace(Q, "#")}`,
248
+ _
249
+ ));
250
+ }
251
+ return S;
252
+ },
253
+ write(w) {
254
+ const S = {};
255
+ for (const [F, M] of Object.entries(w))
256
+ if (F === "transform" && M.schema === et) {
257
+ const [k, _, R, x, q, j, T, O] = M.value, V = Math.cos(R), P = Math.sin(R), E = [
258
+ V * x + k * T,
259
+ V * j - P * q + k * O,
260
+ k,
261
+ P * x + _ * T,
262
+ P * j + V * q + _ * O,
263
+ _,
264
+ T,
265
+ O,
266
+ 1
267
+ ], v = B(B(m, E), b);
268
+ Math.abs(v[6]) + Math.abs(v[7]) < 1e-10 && Math.abs(v[8] - 1) < 1e-10 ? S[F] = `matrix(${[v[0], v[3], v[1], v[4], v[2], v[5]].join(",")})` : S[F] = `matrix3d(${[v[0], v[3], 0, v[6], v[1], v[4], 0, v[7], 0, 0, 1, 0, v[2], v[5], 0, v[8]].join(",")})`;
269
+ } else if (M.schema.startsWith("css:")) {
270
+ let k = 0;
271
+ S[F] = M.schema.slice(4).replace(/#/g, () => String(M.value[k++]));
272
+ }
273
+ return S;
274
+ }
275
+ };
276
+ }
277
+ const bt = 1e3 / 60, nt = 1e3 / 30, St = nt + 1;
278
+ class wt {
279
+ constructor() {
280
+ h(this, "drivers", /* @__PURE__ */ new Set());
281
+ h(this, "observers", /* @__PURE__ */ new Set());
282
+ h(this, "frameRequest", null);
283
+ h(this, "previousTimestamp", null);
284
+ h(this, "tick", (r) => {
285
+ this.frameRequest = null;
286
+ const t = this.previousTimestamp === null ? bt : Math.max(0, r - this.previousTimestamp);
287
+ this.previousTimestamp = r;
288
+ const e = {
289
+ delta: Math.min(t, nt),
290
+ rawDelta: t
291
+ };
292
+ this.runPhase(this.drivers, e), this.runPhase(this.observers, e), this.hasCallbacks() ? this.requestFrame() : this.previousTimestamp = null;
293
+ });
294
+ }
295
+ subscribe(r, t = "drive") {
296
+ const e = t === "drive" ? this.drivers : this.observers;
297
+ return e.add(r), this.requestFrame(), () => {
298
+ e.delete(r), this.stopIfIdle();
299
+ };
300
+ }
301
+ requestFrame() {
302
+ this.frameRequest !== null || !this.hasCallbacks() || (this.frameRequest = requestAnimationFrame(this.tick));
303
+ }
304
+ runPhase(r, t) {
305
+ for (const e of [...r])
306
+ r.has(e) && e(t);
307
+ }
308
+ hasCallbacks() {
309
+ return this.drivers.size > 0 || this.observers.size > 0;
310
+ }
311
+ stopIfIdle() {
312
+ this.hasCallbacks() || (this.frameRequest !== null && typeof cancelAnimationFrame < "u" && cancelAnimationFrame(this.frameRequest), this.frameRequest = null, this.previousTimestamp = null);
313
+ }
314
+ }
315
+ const at = new wt(), Ct = 2;
316
+ class ot extends st {
317
+ constructor(t) {
318
+ super();
319
+ h(this, "_element");
320
+ h(this, "_integrator");
321
+ /** Role label, see `WebAnimationOptions.label`. */
322
+ h(this, "label");
323
+ h(this, "styleFn");
324
+ h(this, "lowerBound");
325
+ h(this, "upperBound");
326
+ h(this, "currentValue");
327
+ h(this, "currentVelocity", 0);
328
+ h(this, "solverState");
329
+ h(this, "solverTarget", 1);
330
+ h(this, "presentationTime", 0);
331
+ h(this, "renderedStyles", []);
332
+ h(this, "frames", []);
333
+ h(this, "waapi", null);
334
+ h(this, "runId", 0);
335
+ h(this, "waitingForStart", !1);
336
+ h(this, "startReady", !1);
337
+ h(this, "pendingFirstFrame");
338
+ h(this, "stopStartupClock", null);
339
+ h(this, "startupStableFrames", 0);
340
+ h(this, "running", !1);
341
+ h(this, "paused", !1);
342
+ h(this, "settled", !1);
343
+ h(this, "reversing", !1);
344
+ h(this, "disposed", !1);
345
+ h(this, "legacyCompletionCleanup");
346
+ h(this, "motion");
347
+ h(this, "codec");
348
+ h(this, "adopted");
349
+ h(this, "presentationFrames", []);
350
+ h(this, "hold", null);
351
+ h(this, "fallbackCopy", null);
352
+ h(this, "fallbackChannels", /* @__PURE__ */ new Set());
353
+ h(this, "fallbackMode");
354
+ this._element = t.element, this._integrator = t.integrator, this.label = t.label, this.styleFn = t.style, this.lowerBound = t.lowerBound ?? 0, this.upperBound = t.upperBound ?? 1, this.currentValue = this.lowerBound, this.onUpdate = t.onUpdate, this.legacyCompletionCleanup = !!t.onComplete && !t.onDispose, this.onComplete = t.onComplete, this.onDispose = t.onDispose, this.motion = t.motion ?? {};
355
+ }
356
+ get handoffFallbackMode() {
357
+ return this.fallbackMode;
358
+ }
359
+ get handoffFallbacks() {
360
+ return [...this.fallbackChannels];
361
+ }
362
+ /** The DOM node this track drives. */
363
+ get element() {
364
+ return this._element;
365
+ }
366
+ /**
367
+ * Physics that drives this track. Read lazily at `play()` / `reverse()`
368
+ * (the simulation runs then), so replacing it before playback takes effect
369
+ * for the next run — this is what `withOverride` relies on.
370
+ */
371
+ get integrator() {
372
+ return this._integrator;
373
+ }
374
+ set integrator(t) {
375
+ this._integrator = t, this.solverState = void 0;
376
+ }
377
+ setIntegrator(t) {
378
+ this._integrator = t, this.solverState = void 0;
379
+ }
380
+ play() {
381
+ var e;
382
+ const t = this.reversing;
383
+ if (this.reversing = !1, this.paused && this.waapi && !t) {
384
+ if (this.paused = !1, this.running = !0, this.waitingForStart) {
385
+ this.startReady && this.startFramePacedPlayback(this.waapi);
386
+ return;
387
+ }
388
+ this.waapi.play(), (e = this.fallbackCopy) == null || e.play();
389
+ return;
390
+ }
391
+ this.runToward(this.upperBound);
392
+ }
393
+ reverse() {
394
+ this.reversing = !0, this.runToward(this.lowerBound);
395
+ }
396
+ pause() {
397
+ var t, e, i;
398
+ this.running && (this.captureLiveState(), (t = this.waapi) == null || t.pause(), (e = this.fallbackCopy) == null || e.pause(), (i = this.stopStartupClock) == null || i.call(this), this.stopStartupClock = null, this.running = !1, this.paused = !0);
399
+ }
400
+ complete() {
401
+ this.settled || (this.clearWaapi(), this.running = !1, this.paused = !1, this.currentValue = this.upperBound, this.currentVelocity = 0, this.applyStyleAt(this.currentValue), this.settled = !0, this.finish());
402
+ }
403
+ validate() {
404
+ const t = this.motion.handoffDuration ?? 280;
405
+ if (!Number.isFinite(t) || t < 0 || t > 1e4)
406
+ throw new Error(
407
+ "handoffDuration must be finite and between 0 and 10000 ms"
408
+ );
409
+ }
410
+ getMotionTracks() {
411
+ return [this];
412
+ }
413
+ get supportsInterruption() {
414
+ return !this.legacyCompletionCleanup;
415
+ }
416
+ stop() {
417
+ var t, e;
418
+ this.captureLiveState(), this.clearWaapi(), (t = this.hold) == null || t.cancel(), this.hold = null, (e = this.fallbackCopy) == null || e.cancel({ reason: "disposed", owns: () => !0 }), this.fallbackCopy = null, this.running = !1, this.paused = !1;
419
+ }
420
+ cancel(t) {
421
+ this.stop(), this.disposeResources(t);
422
+ }
423
+ disposeResources(t) {
424
+ var e;
425
+ if (!this.disposed && (this.disposed = !0, t.owns(this.element)))
426
+ try {
427
+ (e = this.onDispose) == null || e.call(this, t);
428
+ } catch (i) {
429
+ console.error("[ssgoi] animation cleanup failed", i);
430
+ }
431
+ }
432
+ finish() {
433
+ var t, e, i, o;
434
+ this.presentationTime = ((t = this.frames[this.frames.length - 1]) == null ? void 0 : t.time) ?? 0, this.solverState = void 0, (e = this.hold) == null || e.cancel(), this.hold = null, this.applyStyleAt(this.currentValue), this.clearWaapi(), (i = this.fallbackCopy) == null || i.cancel({ reason: "disposed", owns: () => !0 }), this.fallbackCopy = null, this.deferDisposal || this.disposeResources(D), (o = this.onComplete) == null || o.call(this);
435
+ }
436
+ get motionIdentity() {
437
+ return {
438
+ target: this.element,
439
+ key: this.motion.key,
440
+ role: this.motion.role,
441
+ space: this.motion.space,
442
+ lifetime: this.motion.lifetime
443
+ };
444
+ }
445
+ /** Final output, including any earlier residual, is the next handoff's source. */
446
+ getMotionSnapshot() {
447
+ var o, c;
448
+ this.running && this.captureLiveState();
449
+ const t = this.samplePresentation(
450
+ $(this.waapi) ?? this.presentationTime
451
+ ), e = this.paused || this.waitingForStart && !$(this.waapi) ? 0 : this.playbackRate, i = {
452
+ ...this.styleFn(
453
+ this.currentValue,
454
+ this.lowerBound + this.upperBound - this.currentValue
455
+ ),
456
+ ...(o = this.codec) == null ? void 0 : o.write(t)
457
+ };
458
+ return {
459
+ ...this.motionIdentity,
460
+ displayStyle: i,
461
+ inlineStyle: this.element.style.cssText,
462
+ frame: (c = this.codec) == null ? void 0 : c.frame,
463
+ channels: Object.fromEntries(
464
+ Object.entries(t).map(([d, u]) => [
465
+ d,
466
+ {
467
+ ...u,
468
+ velocity: u.velocity.map((p) => p * e)
469
+ }
470
+ ])
471
+ )
472
+ };
473
+ }
474
+ adopt(t) {
475
+ var d, u, p, g, f;
476
+ this.codec ?? (this.codec = this.motion.codec ?? L(this.element)), this.adopted = t;
477
+ const e = this.codec.read({
478
+ transform: "none",
479
+ opacity: 1,
480
+ ...this.styleFn(
481
+ this.currentValue,
482
+ this.lowerBound + this.upperBound - this.currentValue
483
+ )
484
+ });
485
+ this.fallbackChannels.clear(), this.fallbackMode = void 0;
486
+ const i = this.styleFn(
487
+ this.currentValue,
488
+ this.lowerBound + this.upperBound - this.currentValue
489
+ ), o = t.displayStyle;
490
+ for (const [a, n] of Object.entries(o ?? {}))
491
+ a in i && String(n) !== String(i[a]) && (!t.channels[a] || !e[a]) && this.fallbackChannels.add(a);
492
+ for (const [a, n] of Object.entries(t.channels)) {
493
+ const y = e[a];
494
+ y && !K(n, y) && this.fallbackChannels.add(a);
495
+ }
496
+ if (this.fallbackChannels.size && (this.fallbackMode = "finish"), this.fallbackChannels.size && this.motion.fallback !== "finish") {
497
+ const a = t;
498
+ if (a.frame && a.displayStyle && t.target.cloneNode && t.target.parentElement && !t.target.shadowRoot && !((u = (d = t.target).matches) != null && u.call(
499
+ d,
500
+ "canvas, video, audio, iframe, object, embed"
501
+ )) && !((g = (p = t.target).querySelector) != null && g.call(
502
+ p,
503
+ "canvas, video, audio, iframe, object, embed"
504
+ ))) {
505
+ this.fallbackMode = "crossfade";
506
+ const n = t.target.cloneNode(!0);
507
+ n.removeAttribute("id"), n.removeAttribute("data-ssgoi-transition");
508
+ for (const l of n.querySelectorAll(
509
+ "[id], [data-ssgoi-transition]"
510
+ ))
511
+ l.removeAttribute("id"), l.removeAttribute("data-ssgoi-transition");
512
+ n.style.cssText = a.inlineStyle ?? "", Object.assign(n.style, a.displayStyle, {
513
+ position: "fixed",
514
+ left: `${a.frame.left}px`,
515
+ top: `${a.frame.top}px`,
516
+ width: `${a.frame.width}px`,
517
+ height: `${a.frame.height}px`,
518
+ margin: "0",
519
+ pointerEvents: "none",
520
+ zIndex: "2147483646"
521
+ }), n.setAttribute("aria-hidden", "true"), n.inert = !0, t.target.parentElement.appendChild(n);
522
+ const y = Number(a.displayStyle.opacity ?? 1);
523
+ this.fallbackCopy = new ot({
524
+ element: n,
525
+ integrator: {
526
+ step: (l, m, b) => ({
527
+ position: Math.min(m, l.position + b / 0.18),
528
+ velocity: 0
529
+ }),
530
+ isSettled: (l, m) => l.position >= m
531
+ },
532
+ style: (l, m) => ({ opacity: y * m }),
533
+ onDispose: () => n.remove()
534
+ }), this.adopted = {
535
+ ...t,
536
+ channels: {
537
+ ...t.channels,
538
+ opacity: { schema: "css:#", value: [0], velocity: [0] }
539
+ }
540
+ };
541
+ }
542
+ }
543
+ const c = this.codec.write(this.adopted.channels);
544
+ (f = this.hold) == null || f.cancel(), Object.keys(c).length && (this.hold = this.element.animate([c], {
545
+ duration: 1,
546
+ fill: "both"
547
+ }), this.hold.pause(), this.hold.currentTime = 0);
548
+ }
549
+ /** Presentation channels of frame `index`, corrected when a handoff applied. */
550
+ channelsAt(t) {
551
+ const e = this.presentationFrames[t];
552
+ if (e) return e.channels;
553
+ const i = this.frames[t];
554
+ return this.codec ?? (this.codec = this.motion.codec ?? L(this.element)), this.codec.read({
555
+ transform: "none",
556
+ opacity: 1,
557
+ ...this.styleFn(
558
+ i.position,
559
+ this.lowerBound + this.upperBound - i.position
560
+ )
561
+ });
562
+ }
563
+ samplePresentation(t) {
564
+ const e = this.frames;
565
+ if (!e.length)
566
+ return this.adopted ? { ...this.adopted.channels } : (this.codec ?? (this.codec = this.motion.codec ?? L(this.element)), this.codec.read({
567
+ transform: "none",
568
+ opacity: 1,
569
+ ...this.styleFn(
570
+ this.currentValue,
571
+ this.lowerBound + this.upperBound - this.currentValue
572
+ )
573
+ }));
574
+ let i = e.findIndex((n) => n.time > t);
575
+ i < 0 && (i = e.length - 1);
576
+ const o = Math.max(0, i - 1), c = e[o], d = e[i], u = this.channelsAt(o), p = o === i ? u : this.channelsAt(i), g = (d.time - c.time) / 1e3, f = g ? Math.max(0, Math.min(1, (t - c.time) / (g * 1e3))) : 0, a = {};
577
+ for (const [n, y] of Object.entries(u)) {
578
+ const l = p[n];
579
+ if (!l || !K(y, l)) {
580
+ a[n] = y;
581
+ continue;
582
+ }
583
+ a[n] = {
584
+ schema: y.schema,
585
+ value: y.value.map((m, b) => m + (l.value[b] - m) * f),
586
+ velocity: y.value.map(
587
+ (m, b) => t >= e[e.length - 1].time || !g ? 0 : (l.value[b] - m) / g
588
+ )
589
+ };
590
+ }
591
+ return a;
592
+ }
593
+ /**
594
+ * Drop the WAAPI forwards-fill after the run has settled, letting inline
595
+ * styles govern the resting visual. Call only from `onComplete` (the run is
596
+ * already finished) — otherwise it cancels mid-flight. Unlike `complete()`,
597
+ * it writes no final frame, so a caller can reset the element to its natural
598
+ * state without the lingering fill clobbering it.
599
+ */
600
+ releaseFill() {
601
+ this.clearWaapi();
602
+ }
603
+ get isAnimating() {
604
+ return this.running;
605
+ }
606
+ get isPaused() {
607
+ return this.paused;
608
+ }
609
+ get isComplete() {
610
+ return this.settled;
611
+ }
612
+ get isReversing() {
613
+ return this.reversing;
614
+ }
615
+ get progress() {
616
+ this.running && this.captureLiveState();
617
+ const t = this.upperBound - this.lowerBound;
618
+ if (t === 0) return 0;
619
+ const e = (this.currentValue - this.lowerBound) / t;
620
+ return e < 0 ? 0 : e > 1 ? 1 : e;
621
+ }
622
+ findTimeForProgress(t) {
623
+ if (this.frames.length < 2) return null;
624
+ const e = this.upperBound - this.lowerBound;
625
+ if (e === 0) return 0;
626
+ for (const i of this.frames)
627
+ if ((i.position - this.lowerBound) / e >= t) return i.time;
628
+ return this.frames[this.frames.length - 1].time;
629
+ }
630
+ get playbackRate() {
631
+ return super.playbackRate;
632
+ }
633
+ set playbackRate(t) {
634
+ super.playbackRate = t, this.waapi && (this.waapi.playbackRate = t);
635
+ }
636
+ getPose() {
637
+ return this.running && this.captureLiveState(), [
638
+ {
639
+ element: this._element,
640
+ value: this.currentValue,
641
+ velocity: this.currentVelocity
642
+ }
643
+ ];
644
+ }
645
+ getTimeline() {
646
+ const t = this.frames.map((e, i) => {
647
+ const o = e.position, c = this.lowerBound + this.upperBound - o;
648
+ return {
649
+ time: e.time,
650
+ value: e.position,
651
+ velocity: e.velocity,
652
+ style: this.renderedStyles[i] ?? this.styleFn(o, c)
653
+ };
654
+ });
655
+ return [{ element: this._element, frames: t }];
656
+ }
657
+ matchInto(t) {
658
+ const e = t.find((i) => i.element === this._element);
659
+ e && (this.currentValue = e.value, this.currentVelocity = e.velocity, this.solverState = void 0);
660
+ }
661
+ /* ───────────────────────────────────────────────────────── private */
662
+ runToward(t) {
663
+ var g, f;
664
+ if (this.validate(), this.running || this.paused) {
665
+ const a = this.getMotionSnapshot();
666
+ this.captureLiveState(), this.adopted = a;
667
+ }
668
+ if (this.clearWaapi(), this.running = !1, this.paused = !1, this.settled = !1, this.disposed = !1, this.presentationTime = 0, this.presentationFrames = [], this.solverTarget = t, this.frames = dt(
669
+ this._integrator,
670
+ this.currentValue,
671
+ t,
672
+ this.currentVelocity,
673
+ this.solverState,
674
+ !0
675
+ ), this.frames.length === 0 && this.adopted && (this.frames = [{ time: 0, position: t, velocity: 0 }]), this.frames.length === 0) {
676
+ this.currentValue = t, this.currentVelocity = 0, this.applyStyleAt(t), this.settled = !0, this.finish();
677
+ return;
678
+ }
679
+ const e = (a) => this.styleFn(a.position, this.lowerBound + this.upperBound - a.position), i = this.adopted ? this.bridgeKeyframes(e) : this.frames.map((a) => e(a));
680
+ this.renderedStyles = i, this.adopted = void 0;
681
+ const o = i[0], c = this.frames[this.frames.length - 1], d = c.time, u = ++this.runId, p = this._element.animate(i, {
682
+ duration: d,
683
+ fill: "both",
684
+ easing: "linear",
685
+ composite: "replace"
686
+ });
687
+ p.playbackRate = this.playbackRate, p.currentTime = 0, p.pause(), this.waapi = p, (g = this.fallbackCopy) == null || g.play(), (f = this.hold) == null || f.cancel(), this.hold = null, this.waitingForStart = !0, this.startReady = !1, this.pendingFirstFrame = o, this.running = !0, p.onfinish = () => {
688
+ !this.running || this.waapi !== p || (this.running = !1, this.settled = !0, this.currentValue = c.position, this.currentVelocity = 0, this.finish());
689
+ }, this.startWhenReady(p, u);
690
+ }
691
+ /**
692
+ * Bake the residual correction into the keyframes: each authored frame is
693
+ * decoded through the codec, offset by the decaying residual, and encoded
694
+ * back. `presentationFrames` records the corrected output so a later
695
+ * interruption samples what is actually displayed.
696
+ */
697
+ bridgeKeyframes(t) {
698
+ var g;
699
+ this.codec = this.motion.codec ?? L(this.element);
700
+ const e = this.codec, i = Math.max(16, this.motion.handoffDuration ?? 280), o = this.frames[this.frames.length - 1];
701
+ for (let f = o.time + 1e3 / 60; f < i + 1e3 / 60; f += 1e3 / 60)
702
+ this.frames.push({ time: f, position: o.position, velocity: 0 });
703
+ const c = this.frames.map(
704
+ (f) => e.read({ transform: "none", opacity: 1, ...t(f) })
705
+ );
706
+ for (let f = 1; f < c.length; f++) {
707
+ const a = c[f - 1].transform, n = c[f].transform;
708
+ if ((a == null ? void 0 : a.schema) === "viewport-plane-v1" && (n == null ? void 0 : n.schema) === a.schema) {
709
+ const y = [...n.value];
710
+ y[2] = a.value[2] + Math.atan2(
711
+ Math.sin(y[2] - a.value[2]),
712
+ Math.cos(y[2] - a.value[2])
713
+ ), c[f].transform = { ...n, value: y };
714
+ }
715
+ }
716
+ const d = c[0], u = c[1] ?? d, p = {};
717
+ for (const [f, a] of Object.entries(
718
+ ((g = this.adopted) == null ? void 0 : g.channels) ?? {}
719
+ )) {
720
+ let n = d[f];
721
+ if (!n) {
722
+ const l = f === "transform" ? { transform: "none" } : f === "opacity" ? { opacity: 1 } : {};
723
+ if (n = e.read(l)[f], n)
724
+ for (const m of c) m[f] = n;
725
+ }
726
+ if (!n || !K(a, n)) continue;
727
+ const y = u[f] ?? n;
728
+ p[f] = {
729
+ offset: a.value.map((l, m) => {
730
+ let b = l - n.value[m];
731
+ return f === "transform" && a.schema === "viewport-plane-v1" && m === 2 && (b = Math.atan2(Math.sin(b), Math.cos(b))), b;
732
+ }),
733
+ velocity: a.velocity.map(
734
+ (l, m) => l / Math.max(Math.abs(this.playbackRate), 1e-4) - (y.value[m] - n.value[m]) * 60
735
+ )
736
+ };
737
+ }
738
+ return this.presentationFrames = this.frames.map((f, a) => {
739
+ const n = { ...c[a] };
740
+ for (const [y, l] of Object.entries(p)) {
741
+ const m = n[y];
742
+ n[y] = {
743
+ ...m,
744
+ value: m.value.map(
745
+ (b, C) => b + pt(
746
+ l.offset[C],
747
+ l.velocity[C],
748
+ f.time / 1e3,
749
+ i / 1e3
750
+ ).value
751
+ )
752
+ };
753
+ }
754
+ return { time: f.time, channels: n };
755
+ }), this.frames.map((f, a) => {
756
+ const n = this.presentationFrames[a].channels;
757
+ return {
758
+ ...t(f),
759
+ ...e.write(
760
+ Object.fromEntries(
761
+ Object.keys(p).map((y) => [y, n[y]])
762
+ )
763
+ )
764
+ };
765
+ });
766
+ }
767
+ clearWaapi() {
768
+ var t, e;
769
+ this.runId++, (t = this.waapi) == null || t.cancel(), this.waapi = null, this.waitingForStart = !1, this.startReady = !1, this.pendingFirstFrame = void 0, (e = this.stopStartupClock) == null || e.call(this), this.stopStartupClock = null, this.startupStableFrames = 0;
770
+ }
771
+ captureLiveState() {
772
+ if (this.frames.length === 0) return;
773
+ const t = $(this.waapi);
774
+ if (t === null) return;
775
+ this.presentationTime = t;
776
+ const { position: e, velocity: i } = ft(this.frames, t);
777
+ this.currentValue = e, this.currentVelocity = i, this.solverState = mt(
778
+ this.frames,
779
+ t,
780
+ this._integrator,
781
+ this.solverTarget
782
+ );
783
+ }
784
+ async startWhenReady(t, e) {
785
+ try {
786
+ await t.ready, typeof requestAnimationFrame < "u" && await yt(this._element);
787
+ } catch {
788
+ return;
789
+ }
790
+ this.runId !== e || this.waapi !== t || (this.startReady = !0, !(!this.running || this.paused) && this.startFramePacedPlayback(t));
791
+ }
792
+ startFramePacedPlayback(t) {
793
+ if (!(this.waapi !== t || !this.waitingForStart || !this.startReady || this.stopStartupClock)) {
794
+ if (this.pendingFirstFrame)
795
+ for (const e of Object.keys(this.pendingFirstFrame))
796
+ this._element.style[e] = "";
797
+ if (this.pendingFirstFrame = void 0, typeof requestAnimationFrame > "u" || this.playbackRate < 0) {
798
+ this.handOffToWaapi(t);
799
+ return;
800
+ }
801
+ this.startupStableFrames = 0, this.stopStartupClock = at.subscribe((e) => {
802
+ this.advanceFramePacedStartup(t, e);
803
+ });
804
+ }
805
+ }
806
+ advanceFramePacedStartup(t, e) {
807
+ if (this.waapi !== t || !this.running || this.paused || !this.waitingForStart)
808
+ return;
809
+ const i = this.frames[this.frames.length - 1];
810
+ if (!i) return;
811
+ const o = $(t) ?? 0, c = Math.min(
812
+ i.time,
813
+ o + e.delta * Math.max(0, this.playbackRate)
814
+ );
815
+ if (t.currentTime = c, this.captureLiveState(), c >= i.time) {
816
+ this.finishFramePacedRun(t, i);
817
+ return;
818
+ }
819
+ e.rawDelta <= St ? this.startupStableFrames++ : this.startupStableFrames = 0, !(this.startupStableFrames < Ct) && this.handOffToWaapi(t);
820
+ }
821
+ handOffToWaapi(t) {
822
+ var e;
823
+ this.waapi !== t || !this.running || this.paused || ((e = this.stopStartupClock) == null || e.call(this), this.stopStartupClock = null, this.waitingForStart = !1, this.startReady = !1, this.startupStableFrames = 0, t.play());
824
+ }
825
+ finishFramePacedRun(t, e) {
826
+ var i;
827
+ this.waapi !== t || !this.running || ((i = this.stopStartupClock) == null || i.call(this), this.stopStartupClock = null, this.waitingForStart = !1, this.startReady = !1, this.startupStableFrames = 0, this.running = !1, this.settled = !0, this.currentValue = e.position, this.currentVelocity = 0, this.finish());
828
+ }
829
+ applyStyleAt(t) {
830
+ const e = this.lowerBound + this.upperBound - t, i = this.styleFn(t, e);
831
+ for (const [o, c] of Object.entries(i))
832
+ this._element.style[o] = typeof c == "number" ? String(c) : c;
833
+ }
834
+ }
835
+ function $(s) {
836
+ const r = s == null ? void 0 : s.currentTime;
837
+ return typeof r == "number" ? r : null;
838
+ }
839
+ function Ft(s) {
840
+ return typeof s.step == "function" ? s : gt.from(s);
841
+ }
842
+ class lt extends st {
843
+ constructor(t, e = {}) {
844
+ super();
845
+ h(this, "_children");
846
+ h(this, "progressChildren");
847
+ h(this, "_startAt");
848
+ h(this, "namedChildren");
849
+ h(this, "restoreChildCallbacks", []);
850
+ h(this, "runId", 0);
851
+ h(this, "pendingComplete", 0);
852
+ h(this, "running", !1);
853
+ h(this, "disposed", !1);
854
+ h(this, "settled", !1);
855
+ h(this, "startedChildren", /* @__PURE__ */ new Set());
856
+ h(this, "lastMethod", "play");
857
+ h(this, "pausedRun", !1);
858
+ h(this, "pendingStartObservers", []);
859
+ this.namedChildren = new Map(
860
+ Array.isArray(t) ? [] : Object.entries(t)
861
+ ), this._children = Array.isArray(t) ? [...t] : [...this.namedChildren.values()];
862
+ for (const i of this._children) i.deferDisposal = !0;
863
+ this.progressChildren = this._children.filter(
864
+ (i) => !(i instanceof lt) || i.progressChildren.length > 0
865
+ ), (e.mode ?? "parallel") === "sequence" ? this._startAt = this._children.map((i, o) => o === 0 ? 0 : 1) : this._startAt = e.startAt ?? [];
866
+ }
867
+ /** Child animations in play order. */
868
+ get children() {
869
+ return this._children;
870
+ }
871
+ /**
872
+ * Per-child start thresholds (see `MultiAnimationOptions.startAt`). Read
873
+ * at run time, so replacing it before `play()` changes the overlap.
874
+ */
875
+ get startAt() {
876
+ return this._startAt;
877
+ }
878
+ set startAt(t) {
879
+ this._startAt = t;
880
+ }
881
+ /** Every `WebAnimation` in this composite, nested composites included. */
882
+ tracks() {
883
+ return this._children.flatMap((t) => [...t.getMotionTracks()]);
884
+ }
885
+ getMotionTracks() {
886
+ return this.tracks();
887
+ }
888
+ validate() {
889
+ this.buildDependencies();
890
+ for (const t of this._children) t.validate();
891
+ }
892
+ /** Select a registered child, which may itself be a composite. */
893
+ select(t) {
894
+ const e = this.namedChildren.get(t);
895
+ if (!e) throw new Error(`Unknown animation child: ${t}`);
896
+ return e;
897
+ }
898
+ set(t, e) {
899
+ if (typeof t == "string") {
900
+ const i = this.select(t);
901
+ return (e == null ? void 0 : e.integrator) !== void 0 && i.set({ integrator: Ft(e.integrator) }), this;
902
+ }
903
+ return super.set(t);
904
+ }
905
+ /** Setting the composite explicitly retunes every child in the group. */
906
+ setIntegrator(t) {
907
+ for (const e of this._children) e.set({ integrator: t });
908
+ }
909
+ play() {
910
+ this.startRun("play");
911
+ }
912
+ reverse() {
913
+ this.startRun("reverse");
914
+ }
915
+ pause() {
916
+ this.pausedRun = this.running || this.pausedRun, this.running = !1, this.clearPendingStartObservers();
917
+ for (const t of this._children) t.pause();
918
+ }
919
+ complete() {
920
+ var t;
921
+ if (!this.settled) {
922
+ this.settled = !0, this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers();
923
+ for (const e of this._children) e.complete();
924
+ if (!this.deferDisposal) {
925
+ for (const e of this._children) e.cancel(D);
926
+ this.disposeResources(D);
927
+ }
928
+ (t = this.onComplete) == null || t.call(this);
929
+ }
930
+ }
931
+ get supportsInterruption() {
932
+ return this._children.every((t) => t.supportsInterruption);
933
+ }
934
+ stop() {
935
+ this.runId++, this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers();
936
+ for (const t of this._children) t.stop();
937
+ }
938
+ cancel(t) {
939
+ this.stop();
940
+ for (const e of this._children) e.cancel(t);
941
+ this.disposeResources(t);
942
+ }
943
+ disposeResources(t) {
944
+ var e;
945
+ if (!this.disposed) {
946
+ this.disposed = !0;
947
+ try {
948
+ (e = this.onDispose) == null || e.call(this, t);
949
+ } catch (i) {
950
+ console.error("[ssgoi] composite cleanup failed", i);
951
+ }
952
+ }
953
+ }
954
+ get progress() {
955
+ if (this.progressChildren.length === 0) return 0;
956
+ let t = 0;
957
+ for (const e of this.progressChildren) t += e.progress;
958
+ return t / this.progressChildren.length;
959
+ }
960
+ getPose() {
961
+ return this._children.flatMap((t) => t.getPose());
962
+ }
963
+ getTimeline() {
964
+ return this._children.flatMap((t) => t.getTimeline());
965
+ }
966
+ matchInto(t) {
967
+ for (const e of this._children) e.matchInto(t);
968
+ }
969
+ get isAnimating() {
970
+ return this._children.some((t) => t.isAnimating);
971
+ }
972
+ get isPaused() {
973
+ return this._children.some((t) => t.isPaused) && this._children.every((t) => t.isPaused || t.isComplete);
974
+ }
975
+ get isComplete() {
976
+ return this.settled;
977
+ }
978
+ get isReversing() {
979
+ return this._children.some((t) => t.isReversing);
980
+ }
981
+ get playbackRate() {
982
+ return super.playbackRate;
983
+ }
984
+ set playbackRate(t) {
985
+ super.playbackRate = t;
986
+ for (const e of this._children) e.playbackRate = t;
987
+ }
988
+ /* ───────────────────────────────────────────────────────── private */
989
+ startRun(t) {
990
+ const e = this.buildDependencies(), i = this.pausedRun && t === this.lastMethod, o = t !== this.lastMethod, c = new Set(this.startedChildren), d = new Set(
991
+ this._children.filter((l) => l.isComplete)
992
+ ), u = t === "reverse" && c.size ? this._children.filter((l) => c.has(l)) : [...this._children], p = t === "reverse" ? [...u].reverse() : u, g = /* @__PURE__ */ new Map();
993
+ if (t === "reverse")
994
+ for (const [l, m] of e) {
995
+ if (!u.includes(l) || !u.includes(m.after))
996
+ continue;
997
+ const b = g.get(m.after) ?? [];
998
+ b.push({
999
+ after: l,
1000
+ at: m.at === "settled" ? "settled" : 1 - m.at
1001
+ }), g.set(m.after, b);
1002
+ }
1003
+ else
1004
+ for (const [l, m] of e)
1005
+ g.set(l, [m]);
1006
+ if (o || i)
1007
+ for (const l of c)
1008
+ d.has(l) || g.delete(l);
1009
+ this.running && this.pause(), this.restoreCompletionHandlers();
1010
+ const f = ++this.runId;
1011
+ if (this.running = !0, this.pausedRun = !1, this.lastMethod = t, this.disposed = !1, this.settled = !1, this.pendingComplete = u.length, !i && !o && this.startedChildren.clear(), this.pendingComplete === 0) {
1012
+ this.handleFinished();
1013
+ return;
1014
+ }
1015
+ const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
1016
+ if (i)
1017
+ for (const l of u)
1018
+ c.has(l) && d.has(l) && (n.add(l), a.add(l), this.pendingComplete--);
1019
+ for (const l of u) {
1020
+ const m = l.onComplete, b = () => {
1021
+ if (!(this.runId !== f || !this.running || a.has(l))) {
1022
+ try {
1023
+ m == null || m();
1024
+ } catch (C) {
1025
+ console.error("[ssgoi] animation completion failed", C);
1026
+ }
1027
+ a.add(l), --this.pendingComplete === 0 && this.handleFinished();
1028
+ }
1029
+ };
1030
+ l.onComplete = b, this.restoreChildCallbacks.push(() => {
1031
+ l.onComplete === b && (l.onComplete = m);
1032
+ });
1033
+ }
1034
+ const y = () => {
1035
+ let l = !0;
1036
+ for (; this.running && this.runId === f && l; ) {
1037
+ l = !1;
1038
+ for (const m of p)
1039
+ !this.running || n.has(m) || (g.get(m) ?? []).some(
1040
+ (C) => !n.has(C.after) || !this.hasReachedThreshold(
1041
+ C.after,
1042
+ C.at,
1043
+ t
1044
+ )
1045
+ ) || (n.add(m), this.startedChildren.add(m), m[t](), l = !0);
1046
+ }
1047
+ n.size === u.length && this.clearPendingStartObservers();
1048
+ };
1049
+ y(), this.pendingComplete === 0 && this.handleFinished(), this.running && n.size !== u.length && this.pendingStartObservers.push(
1050
+ at.subscribe(y, "observe")
1051
+ );
1052
+ }
1053
+ buildDependencies() {
1054
+ const t = /* @__PURE__ */ new Map(), e = new Set(this._children);
1055
+ if (e.size !== this._children.length)
1056
+ throw new Error(
1057
+ "Each child animation must occur once in a MultiAnimation"
1058
+ );
1059
+ this._children.forEach((d, u) => {
1060
+ const p = d.startCondition;
1061
+ if (p) {
1062
+ if (!e.has(p.after))
1063
+ throw new Error(
1064
+ "startAt.after must reference a sibling in the same MultiAnimation"
1065
+ );
1066
+ t.set(d, { ...p });
1067
+ } else u > 0 && this._startAt.some((g) => g > 0) && t.set(d, {
1068
+ after: this._children[u - 1],
1069
+ at: this._startAt[u] ?? 0
1070
+ });
1071
+ });
1072
+ const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), c = (d) => {
1073
+ if (o.has(d))
1074
+ throw new Error("Animation startAt dependencies form a cycle");
1075
+ if (i.has(d)) return;
1076
+ o.add(d);
1077
+ const u = t.get(d);
1078
+ u && c(u.after), o.delete(d), i.add(d);
1079
+ };
1080
+ return this._children.forEach(c), t;
1081
+ }
1082
+ hasReachedThreshold(t, e, i) {
1083
+ return t.isComplete ? !0 : e === "settled" ? !1 : e <= 0 ? !0 : (i === "play" ? t.progress : 1 - t.progress) >= e;
1084
+ }
1085
+ clearPendingStartObservers() {
1086
+ for (const t of this.pendingStartObservers) t();
1087
+ this.pendingStartObservers = [];
1088
+ }
1089
+ restoreCompletionHandlers() {
1090
+ for (const t of this.restoreChildCallbacks) t();
1091
+ this.restoreChildCallbacks = [];
1092
+ }
1093
+ handleFinished() {
1094
+ var t;
1095
+ if (this.running) {
1096
+ if (this.running = !1, this.settled = !0, this.clearPendingStartObservers(), this.restoreCompletionHandlers(), !this.deferDisposal) {
1097
+ for (const e of this._children) e.cancel(D);
1098
+ this.disposeResources(D);
1099
+ }
1100
+ (t = this.onComplete) == null || t.call(this);
1101
+ }
1102
+ }
1103
+ findTimeForProgress(t) {
1104
+ return null;
1105
+ }
1106
+ }
1107
+ const X = /* @__PURE__ */ new WeakMap();
1108
+ function Mt(s) {
1109
+ const r = X.get(s) ?? {
1110
+ value: s.style.getPropertyValue("opacity"),
1111
+ priority: s.style.getPropertyPriority("opacity"),
1112
+ opacity: typeof getComputedStyle == "function" ? Number.parseFloat(getComputedStyle(s).opacity) : Number.NaN,
1113
+ users: /* @__PURE__ */ new Set()
1114
+ }, t = {};
1115
+ r.users.add(t), X.set(s, r);
1116
+ let e = !1;
1117
+ return {
1118
+ opacity: Number.isFinite(r.opacity) ? r.opacity : 1,
1119
+ set: (i) => {
1120
+ t.value = i, s.style.opacity = String(i);
1121
+ },
1122
+ restore: () => {
1123
+ if (!e) {
1124
+ if (e = !0, r.users.delete(t), r.users.size > 0) {
1125
+ const i = Array.from(r.users), o = i[i.length - 1];
1126
+ (o == null ? void 0 : o.value) !== void 0 && (s.style.opacity = String(o.value));
1127
+ return;
1128
+ }
1129
+ r.value ? s.style.setProperty("opacity", r.value, r.priority) : s.style.removeProperty("opacity"), X.delete(s);
1130
+ }
1131
+ }
1132
+ };
1133
+ }
1134
+ export {
1135
+ st as A,
1136
+ lt as M,
1137
+ ot as W,
1138
+ L as c,
1139
+ D as f,
1140
+ Mt as r
1141
+ };