@ssgoi/core 7.1.3-beta.5 → 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
@@ -1,4 +1,4 @@
1
- import { I as s, s as d } from "./provider-Cea0Pfm1.js";
1
+ import { I as s, a as d } from "./provider-BLf6XeXT.js";
2
2
  const g = {
3
3
  spring: { stiffness: 180, damping: 20, doubleSpring: !0 }
4
4
  }, m = {
@@ -1 +1 @@
1
- "use strict";const S=require("./provider-D9Q2URox.cjs"),g={spring:{stiffness:180,damping:20,doubleSpring:!0}},c={spring:{stiffness:170,damping:20,doubleSpring:!0}},r={spring:{stiffness:170,damping:22,doubleSpring:.8}};function f(n,i=0){var e,a;const o=((e=n.integrator)==null?void 0:e.call(n))??S.IntegratorProvider.from(n),t=S.simulate(o,0,1,0);if(t.some(u=>!Number.isFinite(u.position)||!Number.isFinite(u.velocity)))throw new Error("SSGOI: physics produced a non-finite timeline.");return{frames:t,offset:i,duration:((a=t[t.length-1])==null?void 0:a.time)??0}}function d(n,i,o){const t=f(o??(n==="fade"?g:r)),e=f(o??(n==="fade"?c:r),n==="fade"?t.duration:0);return{kind:n,direction:i,out:t,in:e,duration:Math.max(t.duration,e.offset+e.duration)}}function s(n,i,o,t){"worklet";return n==="fade"?{opacity:i==="in"?t:1-t,x:0}:{opacity:1,x:(o==="forward"?1:-1)*(i==="in"?1-t:-t)}}exports.FADE_IN_PHYSICS=c;exports.FADE_OUT_PHYSICS=g;exports.SLIDE_PHYSICS=r;exports.createPageMotionPlan=d;exports.pageMotionStyle=s;
1
+ "use strict";const S=require("./provider-JDtJ5Jzf.cjs"),g={spring:{stiffness:180,damping:20,doubleSpring:!0}},c={spring:{stiffness:170,damping:20,doubleSpring:!0}},r={spring:{stiffness:170,damping:22,doubleSpring:.8}};function f(n,i=0){var e,a;const o=((e=n.integrator)==null?void 0:e.call(n))??S.IntegratorProvider.from(n),t=S.simulate(o,0,1,0);if(t.some(u=>!Number.isFinite(u.position)||!Number.isFinite(u.velocity)))throw new Error("SSGOI: physics produced a non-finite timeline.");return{frames:t,offset:i,duration:((a=t[t.length-1])==null?void 0:a.time)??0}}function d(n,i,o){const t=f(o??(n==="fade"?g:r)),e=f(o??(n==="fade"?c:r),n==="fade"?t.duration:0);return{kind:n,direction:i,out:t,in:e,duration:Math.max(t.duration,e.offset+e.duration)}}function s(n,i,o,t){"worklet";return n==="fade"?{opacity:i==="in"?t:1-t,x:0}:{opacity:1,x:(o==="forward"?1:-1)*(i==="in"?1-t:-t)}}exports.FADE_IN_PHYSICS=c;exports.FADE_OUT_PHYSICS=g;exports.SLIDE_PHYSICS=r;exports.createPageMotionPlan=d;exports.pageMotionStyle=s;
@@ -0,0 +1,291 @@
1
+ var F = Object.defineProperty;
2
+ var I = (n, e, t) => e in n ? F(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var r = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
4
+ let N = class {
5
+ constructor() {
6
+ /** Current playback rate (1 = realtime, 0 = paused, negative = backwards) */
7
+ r(this, "_playbackRate", 1);
8
+ /** Fired every frame with the most recent value. Optional. */
9
+ r(this, "onUpdate");
10
+ /** Fired once when the animation settles. */
11
+ r(this, "onComplete");
12
+ }
13
+ get playbackRate() {
14
+ return this._playbackRate;
15
+ }
16
+ set playbackRate(e) {
17
+ this._playbackRate = e;
18
+ }
19
+ };
20
+ const M = 0.01, T = 0.01, R = 0.05, S = 1e3 / 60;
21
+ function U(n, e, t, s, i, o = !1) {
22
+ if (e === t && s === 0 && (!i || n.isSettled(i, t)))
23
+ return [];
24
+ const l = 600;
25
+ let c = {
26
+ ...i,
27
+ position: e,
28
+ velocity: s
29
+ }, p = 0;
30
+ const a = [];
31
+ for (let h = 0; h < l; h++) {
32
+ const d = h * S;
33
+ if (a.push({
34
+ time: d,
35
+ position: c.position,
36
+ velocity: c.velocity,
37
+ ...o ? { state: c } : {}
38
+ }), c = n.step(c, t, S / 1e3), n.isSettled(c, t)) {
39
+ if (p += S / 1e3, p >= R) {
40
+ a.push({
41
+ time: (h + 1) * S,
42
+ position: t,
43
+ velocity: 0
44
+ });
45
+ break;
46
+ }
47
+ } else
48
+ p = 0;
49
+ }
50
+ return a;
51
+ }
52
+ function x(n, e) {
53
+ "worklet";
54
+ if (n.length === 0) return { position: 0, velocity: 0 };
55
+ const t = n[0], s = n[n.length - 1];
56
+ if (e <= 0)
57
+ return { position: t.position, velocity: t.velocity };
58
+ if (e >= s.time)
59
+ return { position: s.position, velocity: s.velocity };
60
+ let i = 0, o = n.length - 1;
61
+ for (; i < o - 1; ) {
62
+ const a = i + o >> 1;
63
+ n[a].time <= e ? i = a : o = a;
64
+ }
65
+ const l = n[i], c = n[o], p = (e - l.time) / (c.time - l.time);
66
+ return {
67
+ position: l.position + (c.position - l.position) * p,
68
+ velocity: l.velocity + (c.velocity - l.velocity) * p
69
+ };
70
+ }
71
+ function q(n, e, t, s) {
72
+ const i = x(n, e);
73
+ let o = n[0];
74
+ for (const p of n) {
75
+ if (p.time > e) break;
76
+ o = p;
77
+ }
78
+ if (!(o != null && o.state)) return i;
79
+ const l = Math.max(0, Math.min(1e3 / 60, e - o.time)) / 1e3;
80
+ return { ...l ? t.step(o.state, s, l) : o.state, ...i };
81
+ }
82
+ function z(n, e) {
83
+ const t = /* @__PURE__ */ new Set();
84
+ return e.map((s) => {
85
+ const i = (a) => a.role === s.role && a.space === s.space, o = n.filter(
86
+ (a) => a.target === s.target && i(a) && (a.key === void 0 || s.key === void 0 || a.key === s.key)
87
+ ), l = o.length ? o : s.key === void 0 ? [] : n.filter(
88
+ (a) => a.key === s.key && i(a)
89
+ ), c = e.filter(
90
+ (a) => a.role === s.role && a.space === s.space && (a.target === s.target || s.key !== void 0 && a.key === s.key)
91
+ ).length > 1;
92
+ if (l.length > 1 || c || l[0] && t.has(l[0]))
93
+ return { next: s, reason: "ambiguous" };
94
+ const p = l[0];
95
+ return p ? (t.add(p), {
96
+ next: s,
97
+ previous: p,
98
+ reason: o.length ? "element" : "key"
99
+ }) : { next: s, reason: "enter" };
100
+ });
101
+ }
102
+ function B(n, e) {
103
+ return n.schema === e.schema && n.value.length === e.value.length && n.velocity.length === n.value.length && e.velocity.length === e.value.length && [...n.value, ...n.velocity, ...e.value, ...e.velocity].every(
104
+ Number.isFinite
105
+ );
106
+ }
107
+ function V(n, e, t, s) {
108
+ if (!(s > 0) || t >= s)
109
+ return { value: 0, velocity: 0 };
110
+ const i = Math.max(0, t) / s, o = 2 * i ** 3 - 3 * i ** 2 + 1, l = i ** 3 - 2 * i ** 2 + i;
111
+ return {
112
+ value: o * n + l * s * e,
113
+ velocity: (6 * i ** 2 - 6 * i) * n / s + (3 * i ** 2 - 4 * i + 1) * e
114
+ };
115
+ }
116
+ class D {
117
+ constructor(e) {
118
+ r(this, "stiffness");
119
+ r(this, "damping");
120
+ r(this, "omega");
121
+ // Angular frequency
122
+ r(this, "zeta");
123
+ // Damping ratio
124
+ r(this, "restDelta");
125
+ r(this, "restSpeed");
126
+ const { stiffness: t, damping: s } = e, i = 1;
127
+ this.stiffness = t, this.damping = s, this.omega = Math.sqrt(t / i), this.zeta = s / (2 * Math.sqrt(t * i)), this.restDelta = e.restDelta ?? M, this.restSpeed = e.restSpeed ?? T;
128
+ }
129
+ step(e, t, s) {
130
+ const i = Math.min(s, 0.033), { omega: o, zeta: l } = this, { position: c, velocity: p } = e, a = -2 * i * l * o * p, h = i * o * o * (t - c), d = p + a + h;
131
+ return {
132
+ position: c + i * d,
133
+ velocity: d
134
+ };
135
+ }
136
+ isSettled(e, t) {
137
+ const s = Math.abs(t - e.position), i = Math.abs(e.velocity);
138
+ return s < this.restDelta && i < this.restSpeed;
139
+ }
140
+ }
141
+ class A {
142
+ constructor(e) {
143
+ /** Leader spring values (the follower is derived; see `follower`). */
144
+ r(this, "stiffness");
145
+ r(this, "damping");
146
+ r(this, "leader");
147
+ r(this, "follower");
148
+ r(this, "restDelta");
149
+ r(this, "restSpeed");
150
+ this.stiffness = e.stiffness, this.damping = e.damping, this.restDelta = e.restDelta ?? M, this.restSpeed = e.restSpeed ?? T, this.leader = new D({
151
+ stiffness: e.stiffness,
152
+ damping: e.damping,
153
+ restDelta: this.restDelta,
154
+ restSpeed: this.restSpeed
155
+ });
156
+ let t, s, i, o;
157
+ typeof e.follower == "number" ? (t = e.stiffness * e.follower, s = e.damping) : e.follower ? (t = e.follower.stiffness, s = e.follower.damping, i = e.follower.restDelta, o = e.follower.restSpeed) : (t = e.stiffness, s = e.damping), this.follower = new D({
158
+ stiffness: t,
159
+ damping: s,
160
+ restDelta: i ?? this.restDelta,
161
+ restSpeed: o ?? this.restSpeed
162
+ });
163
+ }
164
+ step(e, t, s) {
165
+ const o = e._leader ?? {
166
+ position: e.position,
167
+ velocity: e.velocity
168
+ }, l = this.leader.step(o, t, s), c = this.follower.step(
169
+ e,
170
+ l.position,
171
+ s
172
+ );
173
+ return {
174
+ position: c.position,
175
+ velocity: c.velocity,
176
+ _leader: l
177
+ };
178
+ }
179
+ isSettled(e, t) {
180
+ const s = e, i = Math.abs(t - e.position) < this.restDelta && Math.abs(e.velocity) < this.restSpeed;
181
+ return s._leader ? Math.abs(t - s._leader.position) < this.restDelta && Math.abs(s._leader.velocity) < this.restSpeed && i : i;
182
+ }
183
+ }
184
+ const O = 0.01, L = 500, g = 10;
185
+ class H {
186
+ constructor(e) {
187
+ r(this, "acceleration");
188
+ r(this, "resistance");
189
+ r(this, "resistanceType");
190
+ r(this, "min");
191
+ r(this, "max");
192
+ r(this, "bounceStiffness");
193
+ r(this, "bounceDamping");
194
+ r(this, "restDelta");
195
+ this.acceleration = e.acceleration, this.resistance = e.resistance, this.resistanceType = e.resistanceType ?? "quadratic", this.min = e.min, this.max = e.max, this.bounceStiffness = e.bounceStiffness ?? L, this.bounceDamping = e.bounceDamping ?? g, this.restDelta = e.restDelta ?? O;
196
+ }
197
+ step(e, t, s) {
198
+ const i = Math.min(s, 0.033), { acceleration: o, resistance: l, resistanceType: c, min: p, max: a } = this, { position: h, velocity: d } = e, y = p !== void 0 && h < p, b = a !== void 0 && h > a;
199
+ let v;
200
+ if (y || b) {
201
+ const f = h - (y ? p : a), _ = -this.bounceStiffness * f, E = -this.bounceDamping * d;
202
+ v = _ + E;
203
+ } else {
204
+ const u = t > h ? 1 : -1;
205
+ let f;
206
+ c === "linear" ? f = l * d : f = l * d * Math.abs(d), v = u * o - f;
207
+ }
208
+ const w = d + v * i;
209
+ let m = h + w * i;
210
+ if (!y && !b) {
211
+ const u = t > h ? 1 : -1;
212
+ (u > 0 && m > t || u < 0 && m < t) && (m = t);
213
+ }
214
+ return {
215
+ position: m,
216
+ velocity: m === t ? 0 : w
217
+ };
218
+ }
219
+ isSettled(e, t) {
220
+ return Math.abs(t - e.position) < this.restDelta;
221
+ }
222
+ }
223
+ class k {
224
+ /**
225
+ * Create an Integrator from physics config
226
+ *
227
+ * @param config Physics configuration (spring or inertia)
228
+ * @returns Appropriate Integrator instance
229
+ * @throws Error if both spring and inertia are provided
230
+ */
231
+ static from(e) {
232
+ if (e.spring && e.inertia)
233
+ throw new Error(
234
+ "Cannot use both 'spring' and 'inertia' together. Choose one physics type."
235
+ );
236
+ if (e.inertia)
237
+ return new H({
238
+ acceleration: e.inertia.acceleration,
239
+ resistance: e.inertia.resistance,
240
+ resistanceType: e.inertia.resistanceType,
241
+ min: e.inertia.min,
242
+ max: e.inertia.max,
243
+ bounceStiffness: e.inertia.bounceStiffness,
244
+ bounceDamping: e.inertia.bounceDamping,
245
+ restDelta: e.inertia.restDelta
246
+ });
247
+ const t = e.spring ?? { stiffness: 300, damping: 30 };
248
+ if (t.doubleSpring) {
249
+ const s = t.doubleSpring;
250
+ let i;
251
+ return typeof s == "number" ? i = s : typeof s == "object" && (i = {
252
+ stiffness: s.stiffness,
253
+ damping: s.damping
254
+ }), new A({
255
+ stiffness: t.stiffness,
256
+ damping: t.damping,
257
+ follower: i,
258
+ restDelta: t.restDelta,
259
+ restSpeed: t.restSpeed
260
+ });
261
+ }
262
+ return new D({
263
+ stiffness: t.stiffness,
264
+ damping: t.damping,
265
+ restDelta: t.restDelta,
266
+ restSpeed: t.restSpeed
267
+ });
268
+ }
269
+ /**
270
+ * Create an Integrator from SpringConfig (legacy support)
271
+ * @deprecated Use from({ spring: config }) instead
272
+ */
273
+ static fromSpring(e) {
274
+ return k.from({ spring: e });
275
+ }
276
+ }
277
+ export {
278
+ N as A,
279
+ A as D,
280
+ k as I,
281
+ M as P,
282
+ D as S,
283
+ U as a,
284
+ R as b,
285
+ B as c,
286
+ H as d,
287
+ x as i,
288
+ z as m,
289
+ V as r,
290
+ q as s
291
+ };
@@ -0,0 +1 @@
1
+ "use strict";var O=Object.defineProperty;var A=(n,e,t)=>e in n?O(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>A(n,typeof e!="symbol"?e+"":e,t);let L=class{constructor(){a(this,"_playbackRate",1);a(this,"onUpdate");a(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e}};const b=.01,E=.01,I=.05,S=1e3/60;function x(n,e,t,s,i,o=!1){if(e===t&&s===0&&(!i||n.isSettled(i,t)))return[];const l=600;let c={...i,position:e,velocity:s},p=0;const r=[];for(let h=0;h<l;h++){const m=h*S;if(r.push({time:m,position:c.position,velocity:c.velocity,...o?{state:c}:{}}),c=n.step(c,t,S/1e3),n.isSettled(c,t)){if(p+=S/1e3,p>=I){r.push({time:(h+1)*S,position:t,velocity:0});break}}else p=0}return r}function _(n,e){"worklet";if(n.length===0)return{position:0,velocity:0};const t=n[0],s=n[n.length-1];if(e<=0)return{position:t.position,velocity:t.velocity};if(e>=s.time)return{position:s.position,velocity:s.velocity};let i=0,o=n.length-1;for(;i<o-1;){const r=i+o>>1;n[r].time<=e?i=r:o=r}const l=n[i],c=n[o],p=(e-l.time)/(c.time-l.time);return{position:l.position+(c.position-l.position)*p,velocity:l.velocity+(c.velocity-l.velocity)*p}}function H(n,e,t,s){const i=_(n,e);let o=n[0];for(const p of n){if(p.time>e)break;o=p}if(!(o!=null&&o.state))return i;const l=Math.max(0,Math.min(1e3/60,e-o.time))/1e3;return{...l?t.step(o.state,s,l):o.state,...i}}function C(n,e){const t=new Set;return e.map(s=>{const i=r=>r.role===s.role&&r.space===s.space,o=n.filter(r=>r.target===s.target&&i(r)&&(r.key===void 0||s.key===void 0||r.key===s.key)),l=o.length?o:s.key===void 0?[]:n.filter(r=>r.key===s.key&&i(r)),c=e.filter(r=>r.role===s.role&&r.space===s.space&&(r.target===s.target||s.key!==void 0&&r.key===s.key)).length>1;if(l.length>1||c||l[0]&&t.has(l[0]))return{next:s,reason:"ambiguous"};const p=l[0];return p?(t.add(p),{next:s,previous:p,reason:o.length?"element":"key"}):{next:s,reason:"enter"}})}function N(n,e){return n.schema===e.schema&&n.value.length===e.value.length&&n.velocity.length===n.value.length&&e.velocity.length===e.value.length&&[...n.value,...n.velocity,...e.value,...e.velocity].every(Number.isFinite)}function P(n,e,t,s){if(!(s>0)||t>=s)return{value:0,velocity:0};const i=Math.max(0,t)/s,o=2*i**3-3*i**2+1,l=i**3-2*i**2+i;return{value:o*n+l*s*e,velocity:(6*i**2-6*i)*n/s+(3*i**2-4*i+1)*e}}class v{constructor(e){a(this,"stiffness");a(this,"damping");a(this,"omega");a(this,"zeta");a(this,"restDelta");a(this,"restSpeed");const{stiffness:t,damping:s}=e,i=1;this.stiffness=t,this.damping=s,this.omega=Math.sqrt(t/i),this.zeta=s/(2*Math.sqrt(t*i)),this.restDelta=e.restDelta??b,this.restSpeed=e.restSpeed??E}step(e,t,s){const i=Math.min(s,.033),{omega:o,zeta:l}=this,{position:c,velocity:p}=e,r=-2*i*l*o*p,h=i*o*o*(t-c),m=p+r+h;return{position:c+i*m,velocity:m}}isSettled(e,t){const s=Math.abs(t-e.position),i=Math.abs(e.velocity);return s<this.restDelta&&i<this.restSpeed}}class k{constructor(e){a(this,"stiffness");a(this,"damping");a(this,"leader");a(this,"follower");a(this,"restDelta");a(this,"restSpeed");this.stiffness=e.stiffness,this.damping=e.damping,this.restDelta=e.restDelta??b,this.restSpeed=e.restSpeed??E,this.leader=new v({stiffness:e.stiffness,damping:e.damping,restDelta:this.restDelta,restSpeed:this.restSpeed});let t,s,i,o;typeof e.follower=="number"?(t=e.stiffness*e.follower,s=e.damping):e.follower?(t=e.follower.stiffness,s=e.follower.damping,i=e.follower.restDelta,o=e.follower.restSpeed):(t=e.stiffness,s=e.damping),this.follower=new v({stiffness:t,damping:s,restDelta:i??this.restDelta,restSpeed:o??this.restSpeed})}step(e,t,s){const o=e._leader??{position:e.position,velocity:e.velocity},l=this.leader.step(o,t,s),c=this.follower.step(e,l.position,s);return{position:c.position,velocity:c.velocity,_leader:l}}isSettled(e,t){const s=e,i=Math.abs(t-e.position)<this.restDelta&&Math.abs(e.velocity)<this.restSpeed;return s._leader?Math.abs(t-s._leader.position)<this.restDelta&&Math.abs(s._leader.velocity)<this.restSpeed&&i:i}}const U=.01,q=500,z=10;class g{constructor(e){a(this,"acceleration");a(this,"resistance");a(this,"resistanceType");a(this,"min");a(this,"max");a(this,"bounceStiffness");a(this,"bounceDamping");a(this,"restDelta");this.acceleration=e.acceleration,this.resistance=e.resistance,this.resistanceType=e.resistanceType??"quadratic",this.min=e.min,this.max=e.max,this.bounceStiffness=e.bounceStiffness??q,this.bounceDamping=e.bounceDamping??z,this.restDelta=e.restDelta??U}step(e,t,s){const i=Math.min(s,.033),{acceleration:o,resistance:l,resistanceType:c,min:p,max:r}=this,{position:h,velocity:m}=e,y=p!==void 0&&h<p,T=r!==void 0&&h>r;let D;if(y||T){const f=h-(y?p:r),F=-this.bounceStiffness*f,R=-this.bounceDamping*m;D=F+R}else{const u=t>h?1:-1;let f;c==="linear"?f=l*m:f=l*m*Math.abs(m),D=u*o-f}const M=m+D*i;let d=h+M*i;if(!y&&!T){const u=t>h?1:-1;(u>0&&d>t||u<0&&d<t)&&(d=t)}return{position:d,velocity:d===t?0:M}}isSettled(e,t){return Math.abs(t-e.position)<this.restDelta}}class w{static from(e){if(e.spring&&e.inertia)throw new Error("Cannot use both 'spring' and 'inertia' together. Choose one physics type.");if(e.inertia)return new g({acceleration:e.inertia.acceleration,resistance:e.inertia.resistance,resistanceType:e.inertia.resistanceType,min:e.inertia.min,max:e.inertia.max,bounceStiffness:e.inertia.bounceStiffness,bounceDamping:e.inertia.bounceDamping,restDelta:e.inertia.restDelta});const t=e.spring??{stiffness:300,damping:30};if(t.doubleSpring){const s=t.doubleSpring;let i;return typeof s=="number"?i=s:typeof s=="object"&&(i={stiffness:s.stiffness,damping:s.damping}),new k({stiffness:t.stiffness,damping:t.damping,follower:i,restDelta:t.restDelta,restSpeed:t.restSpeed})}return new v({stiffness:t.stiffness,damping:t.damping,restDelta:t.restDelta,restSpeed:t.restSpeed})}static fromSpring(e){return w.from({spring:e})}}exports.Animation=L;exports.DoubleSpringIntegrator=k;exports.InertiaIntegrator=g;exports.IntegratorProvider=w;exports.POSITION_THRESHOLD=b;exports.SETTLE_THRESHOLD=I;exports.SpringIntegrator=v;exports.compatibleChannel=N;exports.interpolateFrame=_;exports.matchMotion=C;exports.residualAt=P;exports.sampleIntegratorState=H;exports.simulate=x;
@@ -0,0 +1 @@
1
+ "use strict";var ht=Object.defineProperty;var ct=(s,r,t)=>r in s?ht(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var h=(s,r,t)=>ct(s,typeof r!="symbol"?r+"":r,t);const A=require("./provider-JDtJ5Jzf.cjs"),x={reason:"finished",owns:()=>!0};class Z extends A.Animation{constructor(){super(...arguments);h(this,"_startCondition");h(this,"onDispose");h(this,"deferDisposal",!1)}getMotionTracks(){return[]}validate(){}get supportsInterruption(){return!1}stop(){this.pause()}cancel(t){var e;this.isComplete||this.complete(),(e=this.onDispose)==null||e.call(this,t)}get startCondition(){return this._startCondition}set(t){if(t.startAt){const{after:e,at:i}=t.startAt;if(e===this)throw new Error("An animation cannot start after itself");if(i!=="settled"&&(!Number.isFinite(i)||i<0||i>1))throw new Error("startAt.at must be a progress from 0 to 1 or settled")}if(t.integrator!==void 0){if(typeof t.integrator.step!="function"||typeof t.integrator.isSettled!="function")throw new Error("An integrator must implement step and isSettled");this.setIntegrator(t.integrator)}return t.startAt!==void 0&&(this._startCondition=t.startAt?{...t.startAt}:void 0),this}setIntegrator(t){throw new Error("This animation does not support replacing its integrator")}}function ut(s){return new Promise(r=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r()})})})}const U=[1,0,0,1,0,0],nt=(s,r)=>[s[0]*r[0]+s[2]*r[1],s[1]*r[0]+s[3]*r[1],s[0]*r[2]+s[2]*r[3],s[1]*r[2]+s[3]*r[3],s[0]*r[4]+s[2]*r[5]+s[4],s[1]*r[4]+s[3]*r[5]+s[5]];function tt(s){const r=s[0]*s[3]-s[1]*s[2];return Math.abs(r)<1e-10?null:[s[3]/r,-s[1]/r,-s[2]/r,s[0]/r,(s[2]*s[5]-s[3]*s[4])/r,(s[1]*s[4]-s[0]*s[5])/r]}const B=(s,r)=>[1,0,0,1,s,r],K=(s,r)=>[s,0,0,r,0,0];function dt(s,r,t){if(!s||s==="none")return[...U];let e=[...U];const i=/([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;let o="";for(const c of s.matchAll(i)){o+=c[0];const d=c[1].toLowerCase(),u=c[2].trim().split(/\s*,\s*|\s+/);if(u.some(n=>!/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(n)))return null;const p=u.map(Number.parseFloat);if(p.some(n=>!Number.isFinite(n)))return null;const g=(n,y)=>{var l;return p[n]*((l=u[n])!=null&&l.endsWith("%")?y/100:1)},f=n=>{var y,l;return p[n]*((y=u[n])!=null&&y.endsWith("rad")?1:(l=u[n])!=null&&l.endsWith("turn")?2*Math.PI:Math.PI/180)};let a;if(d==="matrix"&&p.length===6)a=p;else if(d==="translate"||d==="translate3d"){if(d==="translate3d"&&p[2]!==0)return null;a=B(g(0,r),u[1]?g(1,t):0)}else if(d==="translatex")a=B(g(0,r),0);else if(d==="translatey")a=B(0,g(0,t));else if(d==="translatez"&&p[0]===0)a=[...U];else if(d==="scale")a=K(p[0],p[1]??p[0]);else if(d==="scalex")a=K(p[0],1);else if(d==="scaley")a=K(1,p[0]);else if(d==="rotate"||d==="rotatez"){const n=f(0);a=[Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]}else return null;e=nt(e,a)}return o.replace(/\s/g,"")===s.replace(/\s/g,"")?e:null}function et(s,r){return{schema:s,value:r,velocity:r.map(()=>0)}}const st=/[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi,M=s=>[s[0],s[2],s[4],s[1],s[3],s[5],0,0,1];function O(s,r){return Array.from({length:9},(t,e)=>{const i=Math.floor(e/3),o=e%3;return s[i*3]*r[o]+s[i*3+1]*r[o+3]+s[i*3+2]*r[o+6]})}function at(s){return Math.abs(s[8])<1e-8||!s.every(Number.isFinite)?null:s.map(r=>r/s[8])}function it(s,r,t){const e=dt(s,r,t);if(e)return M(e);if(typeof DOMMatrix>"u")return null;const i=s.replace(/(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,(o,c,d)=>{const u=d.split(/\s*,\s*|\s+/).map((p,g)=>{if(!p.endsWith("%"))return p;const f=c.toLowerCase()==="translatey"||g===1?t:r;return`${Number.parseFloat(p)*f/100}px`});return`${c}(${u.join(",")})`});try{const o=new DOMMatrix(i);return at([o.m11,o.m21,o.m41,o.m12,o.m22,o.m42,o.m14,o.m24,o.m44])}catch{return null}}const rt="viewport-plane-v1";function j(s){var C;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;let d=!0;if(typeof getComputedStyle=="function")for(let w=s.parentElement;w;w=w.parentElement){const S=getComputedStyle(w);if(S.transform&&S.transform!=="none"||S.perspective&&S.perspective!=="none"){d=!1;break}}const u=(C=s.getBoundingClientRect)==null?void 0:C.call(s),p=it((e==null?void 0:e.transform)||"",r,t)??M(U),g=O(O(M(B(o,c)),p),M(B(-o,-c))),f=[[0,0],[r,0],[0,t],[r,t]].map(([w,S])=>{const F=g[6]*w+g[7]*S+g[8];return[(g[0]*w+g[1]*S+g[2])/F,(g[3]*w+g[4]*S+g[5])/F]}),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=B(a+o,n+c),l=nt(B(-o,-c),K(r,t)),m=M(tt(y)),b=M(tt(l));return{frame:d?{left:a,top:n,width:r,height:t}:void 0,read(w){const S={};for(const[F,_]of Object.entries(w)){const k=String(_);if(F==="transform"){if(!d)continue;const T=it(k,r,t),V=T&&at(O(O(M(y),T),M(l)));if(V){const[W,N,P,E,D,I,q,v]=V,z=W-P*q,L=E-I*q,J=N-P*v,Q=D-I*v,$=Math.hypot(z,L);if($>1e-8){S[F]=et(rt,[P,I,Math.atan2(L,z),$,(z*Q-L*J)/$,(z*J+L*Q)/$,q,v]);continue}}}const R=[...k.matchAll(st)].map(T=>Number(T[0]));R.length&&R.every(Number.isFinite)&&(S[F]=et(`css:${k.replace(st,"#")}`,R))}return S},write(w){const S={};for(const[F,_]of Object.entries(w))if(F==="transform"&&_.schema===rt){const[k,R,T,V,W,N,P,E]=_.value,D=Math.cos(T),I=Math.sin(T),q=[D*V+k*P,D*N-I*W+k*E,k,I*V+R*P,I*N+D*W+R*E,R,P,E,1],v=O(O(m,q),b);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(",")})`}else if(_.schema.startsWith("css:")){let k=0;S[F]=_.schema.slice(4).replace(/#/g,()=>String(_.value[k++]))}return S}}}const pt=1e3/60,ot=1e3/30,ft=ot+1;class mt{constructor(){h(this,"drivers",new Set);h(this,"observers",new Set);h(this,"frameRequest",null);h(this,"previousTimestamp",null);h(this,"tick",r=>{this.frameRequest=null;const t=this.previousTimestamp===null?pt:Math.max(0,r-this.previousTimestamp);this.previousTimestamp=r;const e={delta:Math.min(t,ot),rawDelta:t};this.runPhase(this.drivers,e),this.runPhase(this.observers,e),this.hasCallbacks()?this.requestFrame():this.previousTimestamp=null})}subscribe(r,t="drive"){const e=t==="drive"?this.drivers:this.observers;return e.add(r),this.requestFrame(),()=>{e.delete(r),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||!this.hasCallbacks()||(this.frameRequest=requestAnimationFrame(this.tick))}runPhase(r,t){for(const e of[...r])r.has(e)&&e(t)}hasCallbacks(){return this.drivers.size>0||this.observers.size>0}stopIfIdle(){this.hasCallbacks()||(this.frameRequest!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameRequest),this.frameRequest=null,this.previousTimestamp=null)}}const lt=new mt,gt=2;class Y extends Z{constructor(t){super();h(this,"_element");h(this,"_integrator");h(this,"label");h(this,"styleFn");h(this,"lowerBound");h(this,"upperBound");h(this,"currentValue");h(this,"currentVelocity",0);h(this,"solverState");h(this,"solverTarget",1);h(this,"presentationTime",0);h(this,"renderedStyles",[]);h(this,"frames",[]);h(this,"waapi",null);h(this,"runId",0);h(this,"waitingForStart",!1);h(this,"startReady",!1);h(this,"pendingFirstFrame");h(this,"stopStartupClock",null);h(this,"startupStableFrames",0);h(this,"running",!1);h(this,"paused",!1);h(this,"settled",!1);h(this,"reversing",!1);h(this,"disposed",!1);h(this,"legacyCompletionCleanup");h(this,"motion");h(this,"codec");h(this,"adopted");h(this,"presentationFrames",[]);h(this,"hold",null);h(this,"fallbackCopy",null);h(this,"fallbackChannels",new Set);h(this,"fallbackMode");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??{}}get handoffFallbackMode(){return this.fallbackMode}get handoffFallbacks(){return[...this.fallbackChannels]}get element(){return this._element}get integrator(){return this._integrator}set integrator(t){this._integrator=t,this.solverState=void 0}setIntegrator(t){this._integrator=t,this.solverState=void 0}play(){var e;const t=this.reversing;if(this.reversing=!1,this.paused&&this.waapi&&!t){if(this.paused=!1,this.running=!0,this.waitingForStart){this.startReady&&this.startFramePacedPlayback(this.waapi);return}this.waapi.play(),(e=this.fallbackCopy)==null||e.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e,i;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)}complete(){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())}validate(){const t=this.motion.handoffDuration??280;if(!Number.isFinite(t)||t<0||t>1e4)throw new Error("handoffDuration must be finite and between 0 and 10000 ms")}getMotionTracks(){return[this]}get supportsInterruption(){return!this.legacyCompletionCleanup}stop(){var t,e;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}cancel(t){this.stop(),this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed&&(this.disposed=!0,t.owns(this.element)))try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] animation cleanup failed",i)}}finish(){var t,e,i,o;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(x),(o=this.onComplete)==null||o.call(this)}get motionIdentity(){return{target:this.element,key:this.motion.key,role:this.motion.role,space:this.motion.space,lifetime:this.motion.lifetime}}getMotionSnapshot(){var o,c;this.running&&this.captureLiveState();const t=this.samplePresentation(H(this.waapi)??this.presentationTime),e=this.paused||this.waitingForStart&&!H(this.waapi)?0:this.playbackRate,i={...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),...(o=this.codec)==null?void 0:o.write(t)};return{...this.motionIdentity,displayStyle:i,inlineStyle:this.element.style.cssText,frame:(c=this.codec)==null?void 0:c.frame,channels:Object.fromEntries(Object.entries(t).map(([d,u])=>[d,{...u,velocity:u.velocity.map(p=>p*e)}]))}}adopt(t){var d,u,p,g,f;this.codec??(this.codec=this.motion.codec??j(this.element)),this.adopted=t;const e=this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)});this.fallbackChannels.clear(),this.fallbackMode=void 0;const i=this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),o=t.displayStyle;for(const[a,n]of Object.entries(o??{}))a in i&&String(n)!==String(i[a])&&(!t.channels[a]||!e[a])&&this.fallbackChannels.add(a);for(const[a,n]of Object.entries(t.channels)){const y=e[a];y&&!A.compatibleChannel(n,y)&&this.fallbackChannels.add(a)}if(this.fallbackChannels.size&&(this.fallbackMode="finish"),this.fallbackChannels.size&&this.motion.fallback!=="finish"){const a=t;if(a.frame&&a.displayStyle&&t.target.cloneNode&&t.target.parentElement&&!t.target.shadowRoot&&!((u=(d=t.target).matches)!=null&&u.call(d,"canvas, video, audio, iframe, object, embed"))&&!((g=(p=t.target).querySelector)!=null&&g.call(p,"canvas, video, audio, iframe, object, embed"))){this.fallbackMode="crossfade";const n=t.target.cloneNode(!0);n.removeAttribute("id"),n.removeAttribute("data-ssgoi-transition");for(const l of n.querySelectorAll("[id], [data-ssgoi-transition]"))l.removeAttribute("id"),l.removeAttribute("data-ssgoi-transition");n.style.cssText=a.inlineStyle??"",Object.assign(n.style,a.displayStyle,{position:"fixed",left:`${a.frame.left}px`,top:`${a.frame.top}px`,width:`${a.frame.width}px`,height:`${a.frame.height}px`,margin:"0",pointerEvents:"none",zIndex:"2147483646"}),n.setAttribute("aria-hidden","true"),n.inert=!0,t.target.parentElement.appendChild(n);const y=Number(a.displayStyle.opacity??1);this.fallbackCopy=new Y({element:n,integrator:{step:(l,m,b)=>({position:Math.min(m,l.position+b/.18),velocity:0}),isSettled:(l,m)=>l.position>=m},style:(l,m)=>({opacity:y*m}),onDispose:()=>n.remove()}),this.adopted={...t,channels:{...t.channels,opacity:{schema:"css:#",value:[0],velocity:[0]}}}}}const c=this.codec.write(this.adopted.channels);(f=this.hold)==null||f.cancel(),Object.keys(c).length&&(this.hold=this.element.animate([c],{duration:1,fill:"both"}),this.hold.pause(),this.hold.currentTime=0)}channelsAt(t){const e=this.presentationFrames[t];if(e)return e.channels;const i=this.frames[t];return this.codec??(this.codec=this.motion.codec??j(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(i.position,this.lowerBound+this.upperBound-i.position)})}samplePresentation(t){const e=this.frames;if(!e.length)return this.adopted?{...this.adopted.channels}:(this.codec??(this.codec=this.motion.codec??j(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)}));let i=e.findIndex(n=>n.time>t);i<0&&(i=e.length-1);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={};for(const[n,y]of Object.entries(u)){const l=p[n];if(!l||!A.compatibleChannel(y,l)){a[n]=y;continue}a[n]={schema:y.schema,value:y.value.map((m,b)=>m+(l.value[b]-m)*f),velocity:y.value.map((m,b)=>t>=e[e.length-1].time||!g?0:(l.value[b]-m)/g)}}return a}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const i of this.frames)if((i.position-this.lowerBound)/e>=t)return i.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this._element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map((e,i)=>{const o=e.position,c=this.lowerBound+this.upperBound-o;return{time:e.time,value:e.position,velocity:e.velocity,style:this.renderedStyles[i]??this.styleFn(o,c)}});return[{element:this._element,frames:t}]}matchInto(t){const e=t.find(i=>i.element===this._element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity,this.solverState=void 0)}runToward(t){var g,f;if(this.validate(),this.running||this.paused){const a=this.getMotionSnapshot();this.captureLiveState(),this.adopted=a}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=A.simulate(this._integrator,this.currentValue,t,this.currentVelocity,this.solverState,!0),this.frames.length===0&&this.adopted&&(this.frames=[{time:0,position:t,velocity:0}]),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,this.finish();return}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));this.renderedStyles=i,this.adopted=void 0;const o=i[0],c=this.frames[this.frames.length-1],d=c.time,u=++this.runId,p=this._element.animate(i,{duration:d,fill:"both",easing:"linear",composite:"replace"});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=()=>{!this.running||this.waapi!==p||(this.running=!1,this.settled=!0,this.currentValue=c.position,this.currentVelocity=0,this.finish())},this.startWhenReady(p,u)}bridgeKeyframes(t){var g;this.codec=this.motion.codec??j(this.element);const e=this.codec,i=Math.max(16,this.motion.handoffDuration??280),o=this.frames[this.frames.length-1];for(let f=o.time+1e3/60;f<i+1e3/60;f+=1e3/60)this.frames.push({time:f,position:o.position,velocity:0});const c=this.frames.map(f=>e.read({transform:"none",opacity:1,...t(f)}));for(let f=1;f<c.length;f++){const a=c[f-1].transform,n=c[f].transform;if((a==null?void 0:a.schema)==="viewport-plane-v1"&&(n==null?void 0:n.schema)===a.schema){const y=[...n.value];y[2]=a.value[2]+Math.atan2(Math.sin(y[2]-a.value[2]),Math.cos(y[2]-a.value[2])),c[f].transform={...n,value:y}}}const d=c[0],u=c[1]??d,p={};for(const[f,a]of Object.entries(((g=this.adopted)==null?void 0:g.channels)??{})){let n=d[f];if(!n){const l=f==="transform"?{transform:"none"}:f==="opacity"?{opacity:1}:{};if(n=e.read(l)[f],n)for(const m of c)m[f]=n}if(!n||!A.compatibleChannel(a,n))continue;const y=u[f]??n;p[f]={offset:a.value.map((l,m)=>{let b=l-n.value[m];return f==="transform"&&a.schema==="viewport-plane-v1"&&m===2&&(b=Math.atan2(Math.sin(b),Math.cos(b))),b}),velocity:a.velocity.map((l,m)=>l/Math.max(Math.abs(this.playbackRate),1e-4)-(y.value[m]-n.value[m])*60)}}return this.presentationFrames=this.frames.map((f,a)=>{const n={...c[a]};for(const[y,l]of Object.entries(p)){const m=n[y];n[y]={...m,value:m.value.map((b,C)=>b+A.residualAt(l.offset[C],l.velocity[C],f.time/1e3,i/1e3).value)}}return{time:f.time,channels:n}}),this.frames.map((f,a)=>{const n=this.presentationFrames[a].channels;return{...t(f),...e.write(Object.fromEntries(Object.keys(p).map(y=>[y,n[y]])))}})}clearWaapi(){var t,e;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}captureLiveState(){if(this.frames.length===0)return;const t=H(this.waapi);if(t===null)return;this.presentationTime=t;const{position:e,velocity:i}=A.interpolateFrame(this.frames,t);this.currentValue=e,this.currentVelocity=i,this.solverState=A.sampleIntegratorState(this.frames,t,this._integrator,this.solverTarget)}async startWhenReady(t,e){try{await t.ready,typeof requestAnimationFrame<"u"&&await ut(this._element)}catch{return}this.runId!==e||this.waapi!==t||(this.startReady=!0,!(!this.running||this.paused)&&this.startFramePacedPlayback(t))}startFramePacedPlayback(t){if(!(this.waapi!==t||!this.waitingForStart||!this.startReady||this.stopStartupClock)){if(this.pendingFirstFrame)for(const e of Object.keys(this.pendingFirstFrame))this._element.style[e]="";if(this.pendingFirstFrame=void 0,typeof requestAnimationFrame>"u"||this.playbackRate<0){this.handOffToWaapi(t);return}this.startupStableFrames=0,this.stopStartupClock=lt.subscribe(e=>{this.advanceFramePacedStartup(t,e)})}}advanceFramePacedStartup(t,e){if(this.waapi!==t||!this.running||this.paused||!this.waitingForStart)return;const i=this.frames[this.frames.length-1];if(!i)return;const o=H(t)??0,c=Math.min(i.time,o+e.delta*Math.max(0,this.playbackRate));if(t.currentTime=c,this.captureLiveState(),c>=i.time){this.finishFramePacedRun(t,i);return}e.rawDelta<=ft?this.startupStableFrames++:this.startupStableFrames=0,!(this.startupStableFrames<gt)&&this.handOffToWaapi(t)}handOffToWaapi(t){var e;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())}finishFramePacedRun(t,e){var i;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())}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,i=this.styleFn(t,e);for(const[o,c]of Object.entries(i))this._element.style[o]=typeof c=="number"?String(c):c}}function H(s){const r=s==null?void 0:s.currentTime;return typeof r=="number"?r:null}function yt(s){return typeof s.step=="function"?s:A.IntegratorProvider.from(s)}class G extends Z{constructor(t,e={}){super();h(this,"_children");h(this,"progressChildren");h(this,"_startAt");h(this,"namedChildren");h(this,"restoreChildCallbacks",[]);h(this,"runId",0);h(this,"pendingComplete",0);h(this,"running",!1);h(this,"disposed",!1);h(this,"settled",!1);h(this,"startedChildren",new Set);h(this,"lastMethod","play");h(this,"pausedRun",!1);h(this,"pendingStartObservers",[]);this.namedChildren=new Map(Array.isArray(t)?[]:Object.entries(t)),this._children=Array.isArray(t)?[...t]:[...this.namedChildren.values()];for(const i of this._children)i.deferDisposal=!0;this.progressChildren=this._children.filter(i=>!(i instanceof G)||i.progressChildren.length>0),(e.mode??"parallel")==="sequence"?this._startAt=this._children.map((i,o)=>o===0?0:1):this._startAt=e.startAt??[]}get children(){return this._children}get startAt(){return this._startAt}set startAt(t){this._startAt=t}tracks(){return this._children.flatMap(t=>[...t.getMotionTracks()])}getMotionTracks(){return this.tracks()}validate(){this.buildDependencies();for(const t of this._children)t.validate()}select(t){const e=this.namedChildren.get(t);if(!e)throw new Error(`Unknown animation child: ${t}`);return e}set(t,e){if(typeof t=="string"){const i=this.select(t);return(e==null?void 0:e.integrator)!==void 0&&i.set({integrator:yt(e.integrator)}),this}return super.set(t)}setIntegrator(t){for(const e of this._children)e.set({integrator:t})}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.pausedRun=this.running||this.pausedRun,this.running=!1,this.clearPendingStartObservers();for(const t of this._children)t.pause()}complete(){var t;if(!this.settled){this.settled=!0,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const e of this._children)e.complete();if(!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}get supportsInterruption(){return this._children.every(t=>t.supportsInterruption)}stop(){this.runId++,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const t of this._children)t.stop()}cancel(t){this.stop();for(const e of this._children)e.cancel(t);this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed){this.disposed=!0;try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] composite cleanup failed",i)}}}get progress(){if(this.progressChildren.length===0)return 0;let t=0;for(const e of this.progressChildren)t+=e.progress;return t/this.progressChildren.length}getPose(){return this._children.flatMap(t=>t.getPose())}getTimeline(){return this._children.flatMap(t=>t.getTimeline())}matchInto(t){for(const e of this._children)e.matchInto(t)}get isAnimating(){return this._children.some(t=>t.isAnimating)}get isPaused(){return this._children.some(t=>t.isPaused)&&this._children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.settled}get isReversing(){return this._children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this._children)e.playbackRate=t}startRun(t){const e=this.buildDependencies(),i=this.pausedRun&&t===this.lastMethod,o=t!==this.lastMethod,c=new Set(this.startedChildren),d=new Set(this._children.filter(l=>l.isComplete)),u=t==="reverse"&&c.size?this._children.filter(l=>c.has(l)):[...this._children],p=t==="reverse"?[...u].reverse():u,g=new Map;if(t==="reverse")for(const[l,m]of e){if(!u.includes(l)||!u.includes(m.after))continue;const b=g.get(m.after)??[];b.push({after:l,at:m.at==="settled"?"settled":1-m.at}),g.set(m.after,b)}else for(const[l,m]of e)g.set(l,[m]);if(o||i)for(const l of c)d.has(l)||g.delete(l);this.running&&this.pause(),this.restoreCompletionHandlers();const f=++this.runId;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){this.handleFinished();return}const a=new Set,n=new Set;if(i)for(const l of u)c.has(l)&&d.has(l)&&(n.add(l),a.add(l),this.pendingComplete--);for(const l of u){const m=l.onComplete,b=()=>{if(!(this.runId!==f||!this.running||a.has(l))){try{m==null||m()}catch(C){console.error("[ssgoi] animation completion failed",C)}a.add(l),--this.pendingComplete===0&&this.handleFinished()}};l.onComplete=b,this.restoreChildCallbacks.push(()=>{l.onComplete===b&&(l.onComplete=m)})}const y=()=>{let l=!0;for(;this.running&&this.runId===f&&l;){l=!1;for(const m of p)!this.running||n.has(m)||(g.get(m)??[]).some(C=>!n.has(C.after)||!this.hasReachedThreshold(C.after,C.at,t))||(n.add(m),this.startedChildren.add(m),m[t](),l=!0)}n.size===u.length&&this.clearPendingStartObservers()};y(),this.pendingComplete===0&&this.handleFinished(),this.running&&n.size!==u.length&&this.pendingStartObservers.push(lt.subscribe(y,"observe"))}buildDependencies(){const t=new Map,e=new Set(this._children);if(e.size!==this._children.length)throw new Error("Each child animation must occur once in a MultiAnimation");this._children.forEach((d,u)=>{const p=d.startCondition;if(p){if(!e.has(p.after))throw new Error("startAt.after must reference a sibling in the same MultiAnimation");t.set(d,{...p})}else u>0&&this._startAt.some(g=>g>0)&&t.set(d,{after:this._children[u-1],at:this._startAt[u]??0})});const i=new Set,o=new Set,c=d=>{if(o.has(d))throw new Error("Animation startAt dependencies form a cycle");if(i.has(d))return;o.add(d);const u=t.get(d);u&&c(u.after),o.delete(d),i.add(d)};return this._children.forEach(c),t}hasReachedThreshold(t,e,i){return t.isComplete?!0:e==="settled"?!1:e<=0?!0:(i==="play"?t.progress:1-t.progress)>=e}clearPendingStartObservers(){for(const t of this.pendingStartObservers)t();this.pendingStartObservers=[]}restoreCompletionHandlers(){for(const t of this.restoreChildCallbacks)t();this.restoreChildCallbacks=[]}handleFinished(){var t;if(this.running){if(this.running=!1,this.settled=!0,this.clearPendingStartObservers(),this.restoreCompletionHandlers(),!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}findTimeForProgress(t){return null}}const X=new WeakMap;function vt(s){const r=X.get(s)??{value:s.style.getPropertyValue("opacity"),priority:s.style.getPropertyPriority("opacity"),opacity:typeof getComputedStyle=="function"?Number.parseFloat(getComputedStyle(s).opacity):Number.NaN,users:new Set},t={};r.users.add(t),X.set(s,r);let e=!1;return{opacity:Number.isFinite(r.opacity)?r.opacity:1,set:i=>{t.value=i,s.style.opacity=String(i)},restore:()=>{if(!e){if(e=!0,r.users.delete(t),r.users.size>0){const i=Array.from(r.users),o=i[i.length-1];(o==null?void 0:o.value)!==void 0&&(s.style.opacity=String(o.value));return}r.value?s.style.setProperty("opacity",r.value,r.priority):s.style.removeProperty("opacity"),X.delete(s)}}}}exports.Animation=Z;exports.MultiAnimation=G;exports.WebAnimation=Y;exports.createWebPresentationCodec=j;exports.finishedDisposal=x;exports.retainOpacity=vt;