@wix/interact 2.5.6 → 2.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3457 +0,0 @@
1
- function Ot(t) {
2
- return [...t.matchAll(/\[([-\w]+)]/g)].map(([e, n]) => n);
3
- }
4
- function k(t, e) {
5
- const n = Ot(e);
6
- let s = 0;
7
- return n.length ? t.replace(/\[]/g, () => {
8
- const i = n[s++];
9
- return i !== void 0 ? `[${i}]` : "[]";
10
- }) : t;
11
- }
12
- function At(t, e) {
13
- return t.trigger === "viewEnter" && e.triggerType === "once" && W(t) === W(e);
14
- }
15
- function W(t) {
16
- const { key: e, listContainer: n, listItemSelector: s, selector: i } = t;
17
- return `${e}\0${n || ""}\0${s || ""}\0${i || ""}`;
18
- }
19
- function We(t) {
20
- let e = 0, n = 0;
21
- for (let s = 0; s < t.length; s++) {
22
- const i = t.charCodeAt(s);
23
- e = (e << 5) - e + i | 0, n = n << 3 ^ n >>> 2 ^ i | 0;
24
- }
25
- return ((e >>> 0) * 1048576 + (n >>> 0) % 1048576).toString(36);
26
- }
27
- class Y {
28
- animations;
29
- options;
30
- ready;
31
- isCSS;
32
- longestAnimation;
33
- constructor(e, n) {
34
- this.animations = e, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = e[0] instanceof CSSAnimation, this.longestAnimation = this._getAnimationWithLongestEndTime();
35
- }
36
- _getAnimationWithLongestEndTime() {
37
- return this.animations.reduce((e, n) => {
38
- const s = e.effect?.getComputedTiming().endTime ?? 0, i = n.effect?.getComputedTiming().endTime ?? 0;
39
- return s > i ? e : n;
40
- }, this.animations[0]);
41
- }
42
- getProgress() {
43
- return this.longestAnimation?.effect?.getComputedTiming().progress || 0;
44
- }
45
- async play(e) {
46
- await this.ready;
47
- for (const n of this.animations)
48
- n.play();
49
- await Promise.all(this.animations.map((n) => n.ready)), e && e();
50
- }
51
- pause() {
52
- for (const e of this.animations)
53
- e.pause();
54
- }
55
- async reverse(e) {
56
- await this.ready;
57
- for (const n of this.animations)
58
- n.reverse();
59
- await Promise.all(this.animations.map((n) => n.ready)), e && e();
60
- }
61
- progress(e) {
62
- for (const n of this.animations) {
63
- const { delay: s, duration: i, iterations: r } = n.effect.getTiming(), o = (Number.isFinite(i) ? i : 0) * (Number.isFinite(r) ? r : 1);
64
- n.currentTime = ((s || 0) + o) * e;
65
- }
66
- }
67
- cancel() {
68
- for (const e of this.animations)
69
- e.cancel();
70
- }
71
- setPlaybackRate(e) {
72
- for (const n of this.animations)
73
- n.playbackRate = e;
74
- }
75
- async onFinish(e) {
76
- try {
77
- await Promise.all(this.animations.map((s) => s.finished));
78
- const n = this.animations[0];
79
- if (n && !this.isCSS) {
80
- const s = n.effect?.target;
81
- if (s) {
82
- const i = this.options?.effectId || n.id, r = new CustomEvent("animationend", { detail: { effectId: i } });
83
- s.dispatchEvent(r);
84
- }
85
- }
86
- e();
87
- } catch (n) {
88
- console.warn("animation was interrupted - aborting onFinish callback - ", n);
89
- }
90
- }
91
- async onAbort(e) {
92
- try {
93
- await Promise.all(this.animations.map((n) => n.finished));
94
- } catch (n) {
95
- if (n.name === "AbortError") {
96
- const s = this.animations[0];
97
- if (s && !this.isCSS) {
98
- const i = s.effect?.target;
99
- if (i) {
100
- const r = new Event("animationcancel");
101
- i.dispatchEvent(r);
102
- }
103
- }
104
- e();
105
- }
106
- }
107
- }
108
- get finished() {
109
- return Promise.all(this.animations.map((e) => e.finished));
110
- }
111
- get playState() {
112
- return this.animations.some((e) => e.playState === "running") ? "running" : this.animations[0]?.playState;
113
- }
114
- hasAnimationName(e) {
115
- return this.animations.some((n) => n.animationName === e);
116
- }
117
- hasAnimationId(e) {
118
- return this.animations.some((n) => n.id === e);
119
- }
120
- getTimingOptions() {
121
- return this.animations.map((e) => {
122
- const n = e.effect?.getTiming(), s = n?.delay ?? 0, i = Number(n?.duration) || 0, r = n?.iterations ?? 1;
123
- return {
124
- delay: s,
125
- duration: i,
126
- iterations: r
127
- };
128
- });
129
- }
130
- }
131
- const Ve = (t) => t, Ct = (t) => 1 - Math.cos(t * Math.PI / 2), _t = (t) => Math.sin(t * Math.PI / 2), kt = (t) => -(Math.cos(Math.PI * t) - 1) / 2, $t = (t) => t ** 2, Pt = (t) => 1 - (1 - t) ** 2, qt = (t) => t < 0.5 ? 2 * t ** 2 : 1 - (-2 * t + 2) ** 2 / 2, Mt = (t) => t ** 3, xt = (t) => 1 - (1 - t) ** 3, Lt = (t) => t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2, Ft = (t) => t ** 4, Rt = (t) => 1 - (1 - t) ** 4, Nt = (t) => t < 0.5 ? 8 * t ** 4 : 1 - (-2 * t + 2) ** 4 / 2, zt = (t) => t ** 5, jt = (t) => 1 - (1 - t) ** 5, Dt = (t) => t < 0.5 ? 16 * t ** 5 : 1 - (-2 * t + 2) ** 5 / 2, Gt = (t) => t === 0 ? 0 : 2 ** (10 * t - 10), Ht = (t) => t === 1 ? 1 : 1 - 2 ** (-10 * t), Wt = (t) => t === 0 ? 0 : t === 1 ? 1 : t < 0.5 ? 2 ** (20 * t - 10) / 2 : (2 - 2 ** (-20 * t + 10)) / 2, Vt = (t) => 1 - Math.sqrt(1 - t ** 2), Yt = (t) => Math.sqrt(1 - (t - 1) ** 2), Kt = (t) => t < 0.5 ? (1 - Math.sqrt(1 - 4 * t ** 2)) / 2 : (Math.sqrt(-(2 * t - 3) * (2 * t - 1)) + 1) / 2, Bt = (t) => 2.70158 * t ** 3 - 1.70158 * t ** 2, Ut = (t) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2, Qt = (t, e = 1.70158 * 1.525) => t < 0.5 ? (2 * t) ** 2 * ((e + 1) * 2 * t - e) / 2 : ((2 * t - 2) ** 2 * ((e + 1) * (t * 2 - 2) + e) + 2) / 2, _e = {
132
- linear: Ve,
133
- sineIn: Ct,
134
- sineOut: _t,
135
- sineInOut: kt,
136
- quadIn: $t,
137
- quadOut: Pt,
138
- quadInOut: qt,
139
- cubicIn: Mt,
140
- cubicOut: xt,
141
- cubicInOut: Lt,
142
- quartIn: Ft,
143
- quartOut: Rt,
144
- quartInOut: Nt,
145
- quintIn: zt,
146
- quintOut: jt,
147
- quintInOut: Dt,
148
- expoIn: Gt,
149
- expoOut: Ht,
150
- expoInOut: Wt,
151
- circIn: Vt,
152
- circOut: Yt,
153
- circInOut: Kt,
154
- backIn: Bt,
155
- backOut: Ut,
156
- backInOut: Qt
157
- }, ke = {
158
- linear: "linear",
159
- ease: "ease",
160
- easeIn: "ease-in",
161
- easeOut: "ease-out",
162
- easeInOut: "ease-in-out",
163
- sineIn: "cubic-bezier(0.47, 0, 0.745, 0.715)",
164
- sineOut: "cubic-bezier(0.39, 0.575, 0.565, 1)",
165
- sineInOut: "cubic-bezier(0.445, 0.05, 0.55, 0.95)",
166
- quadIn: "cubic-bezier(0.55, 0.085, 0.68, 0.53)",
167
- quadOut: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
168
- quadInOut: "cubic-bezier(0.455, 0.03, 0.515, 0.955)",
169
- cubicIn: "cubic-bezier(0.55, 0.055, 0.675, 0.19)",
170
- cubicOut: "cubic-bezier(0.215, 0.61, 0.355, 1)",
171
- cubicInOut: "cubic-bezier(0.645, 0.045, 0.355, 1)",
172
- quartIn: "cubic-bezier(0.895, 0.03, 0.685, 0.22)",
173
- quartOut: "cubic-bezier(0.165, 0.84, 0.44, 1)",
174
- quartInOut: "cubic-bezier(0.77, 0, 0.175, 1)",
175
- quintIn: "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
176
- quintOut: "cubic-bezier(0.23, 1, 0.32, 1)",
177
- quintInOut: "cubic-bezier(0.86, 0, 0.07, 1)",
178
- expoIn: "cubic-bezier(0.95, 0.05, 0.795, 0.035)",
179
- expoOut: "cubic-bezier(0.19, 1, 0.22, 1)",
180
- expoInOut: "cubic-bezier(1, 0, 0, 1)",
181
- circIn: "cubic-bezier(0.6, 0.04, 0.98, 0.335)",
182
- circOut: "cubic-bezier(0.075, 0.82, 0.165, 1)",
183
- circInOut: "cubic-bezier(0.785, 0.135, 0.15, 0.86)",
184
- backIn: "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
185
- backOut: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
186
- backInOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
187
- };
188
- function Xt(t) {
189
- return t === "percentage" ? "%" : t || "px";
190
- }
191
- const Zt = /^(webkit|moz|ms|o)(?=[A-Z])/, Jt = Object.assign(/* @__PURE__ */ Object.create(null), {
192
- float: "cssFloat",
193
- "animation-timing-function": "easing",
194
- "animation-composition": "composite"
195
- });
196
- function ce(t) {
197
- return t.startsWith("--") ? t : (Zt.test(t) ? `-${t}` : t).replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`);
198
- }
199
- function en(t) {
200
- return t.startsWith("--") || !t.includes("-") ? t : t.replace(/^-/, "").replace(/-([a-z])/g, (e, n) => n.toUpperCase());
201
- }
202
- function Ye(t) {
203
- return Jt[t] || en(t);
204
- }
205
- function tn(t) {
206
- for (const e in t)
207
- if (Object.hasOwn(t, e) && Ye(e) !== e)
208
- return !0;
209
- return !1;
210
- }
211
- function nn(t) {
212
- if (!Array.isArray(t))
213
- return t;
214
- let e;
215
- return t.forEach((n, s) => {
216
- if (!n || typeof n != "object" || !tn(n))
217
- return;
218
- e ??= t.slice();
219
- const i = {};
220
- for (const r in n)
221
- Object.hasOwn(n, r) && (i[Ye(r)] = n[r]);
222
- e[s] = i;
223
- }), e || t;
224
- }
225
- function te(t) {
226
- return t ? ke[t] || t : ke.linear;
227
- }
228
- function sn(t, e, n, s) {
229
- const i = 3 * t, r = 3 * (n - t) - i, o = 1 - i - r, c = 3 * e, a = 3 * (s - e) - c, u = 1 - c - a, f = (h) => ((o * h + r) * h + i) * h, l = (h) => ((u * h + a) * h + c) * h, d = (h) => (3 * o * h + 2 * r) * h + i;
230
- function g(h) {
231
- let m = h;
232
- for (let y = 0; y < 8; y++) {
233
- const E = f(m) - h;
234
- if (Math.abs(E) < 1e-7) return m;
235
- const w = d(m);
236
- if (Math.abs(w) < 1e-6) break;
237
- m -= E / w;
238
- }
239
- let p = 0, v = 1;
240
- for (m = (p + v) / 2; v - p > 1e-7; ) {
241
- const y = f(m);
242
- if (Math.abs(y - h) < 1e-7) return m;
243
- h > y ? p = m : v = m, m = (p + v) / 2;
244
- }
245
- return m;
246
- }
247
- return (h) => h <= 0 ? 0 : h >= 1 ? 1 : l(g(h));
248
- }
249
- function rn(t) {
250
- const e = t.match(
251
- /^cubic-bezier\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/
252
- );
253
- if (!e) return;
254
- const n = parseFloat(e[1]), s = parseFloat(e[2]), i = parseFloat(e[3]), r = parseFloat(e[4]);
255
- if (![n, s, i, r].some(isNaN))
256
- return sn(n, s, i, r);
257
- }
258
- function on(t) {
259
- const e = t.match(/^linear\((.+)\)$/);
260
- if (!e) return;
261
- const n = e[1].split(",").map((o) => o.trim()).filter(Boolean);
262
- if (n.length === 0) return;
263
- const s = [];
264
- for (const o of n) {
265
- const c = o.split(/\s+/), a = parseFloat(c[0]);
266
- if (isNaN(a)) return;
267
- const u = [];
268
- for (let f = 1; f < c.length; f++)
269
- if (c[f].endsWith("%")) {
270
- const l = parseFloat(c[f]) / 100;
271
- if (isNaN(l)) return;
272
- u.push(l);
273
- }
274
- u.length === 0 ? s.push({ output: a, pos: null }) : u.length === 1 ? s.push({ output: a, pos: u[0] }) : (s.push({ output: a, pos: u[0] }), s.push({ output: a, pos: u[1] }));
275
- }
276
- if (s.length === 0) return;
277
- s[0].pos === null && (s[0].pos = 0), s[s.length - 1].pos === null && (s[s.length - 1].pos = 1);
278
- let i = 0;
279
- for (; i < s.length; )
280
- if (s[i].pos === null) {
281
- const o = i - 1;
282
- let c = i;
283
- for (; c < s.length && s[c].pos === null; ) c++;
284
- const a = s[o].pos, u = s[c].pos, f = c - o;
285
- for (let l = o + 1; l < c; l++)
286
- s[l].pos = a + (u - a) * (l - o) / f;
287
- i = c + 1;
288
- } else
289
- i++;
290
- for (let o = 1; o < s.length; o++)
291
- s[o].pos < s[o - 1].pos && (s[o].pos = s[o - 1].pos);
292
- const r = s;
293
- return (o) => {
294
- if (o <= r[0].pos) return r[0].output;
295
- const c = r[r.length - 1];
296
- if (o >= c.pos) return c.output;
297
- let a = 0, u = r.length - 1;
298
- for (; a < u - 1; ) {
299
- const d = a + u >>> 1;
300
- r[d].pos <= o ? a = d : u = d;
301
- }
302
- const f = r[a], l = r[u];
303
- return l.pos === f.pos ? l.output : f.output + (l.output - f.output) * (o - f.pos) / (l.pos - f.pos);
304
- };
305
- }
306
- function Ae(t) {
307
- if (!t) return;
308
- const e = _e[t];
309
- return e || (rn(t) ?? on(t) ?? _e.linear);
310
- }
311
- class cn extends Y {
312
- animationGroups;
313
- delay;
314
- offset;
315
- offsetEasing;
316
- timingOptions;
317
- constructor(e, n = {}) {
318
- const s = e.flatMap((i) => [...i.animations]);
319
- super(s), this.animationGroups = e, this.delay = n.delay ?? 0, this.offset = n.offset ?? 0, this.offsetEasing = typeof n.offsetEasing == "function" ? n.offsetEasing : Ae(n.offsetEasing) ?? Ve, this.timingOptions = this.animationGroups.map((i) => i.getTimingOptions().map(({ delay: r, duration: o, iterations: c }) => ({
320
- delay: r,
321
- duration: Number.isFinite(o) ? o : 0,
322
- iterations: Number.isFinite(c) ? c : 1
323
- }))), this.applyOffsets(), this.ready = Promise.all(e.map((i) => i.ready)).then(() => {
324
- });
325
- }
326
- /**
327
- * Calculates stagger delay offsets for each animation group using the formula:
328
- * easing(i / last) * last * offset
329
- * where i is the group index and last is the index of the final group.
330
- */
331
- calculateOffsets() {
332
- const e = this.animationGroups.length;
333
- if (e <= 1) return [0];
334
- const n = e - 1;
335
- return Array.from(
336
- { length: e },
337
- (s, i) => this.offsetEasing(i / n) * n * this.offset | 0
338
- );
339
- }
340
- applyOffsets() {
341
- if (this.animationGroups.length === 0 || this.animations.length === 0) return;
342
- const e = this.calculateOffsets(), n = this.getSequenceActiveDuration(e);
343
- this.animationGroups.forEach((s, i) => {
344
- s.animations.forEach((r, o) => {
345
- const c = r.effect;
346
- if (!c) return;
347
- const { delay: a, duration: u, iterations: f } = this.timingOptions[i][o], l = a + e[i], d = n - (l + u * f);
348
- c.updateTiming({ delay: l + this.delay, endDelay: d });
349
- });
350
- });
351
- }
352
- getSequenceActiveDuration(e) {
353
- const n = [];
354
- for (let s = 0; s < this.timingOptions.length; s++) {
355
- const i = this.timingOptions[s].reduce((r, o) => {
356
- if (!o) return r;
357
- const { delay: c, duration: a, iterations: u } = o;
358
- return Math.max(r, c + a * u);
359
- }, 0);
360
- n.push(e[s] + i);
361
- }
362
- return Math.max(...n);
363
- }
364
- /**
365
- * Inserts new AnimationGroups at specified indices, then recalculates
366
- * stagger offsets for all groups. Each entry specifies the target index
367
- * in the animationGroups array where the group should be inserted.
368
- */
369
- addGroups(e) {
370
- if (e.length === 0) return;
371
- const n = [...e].sort((s, i) => i.index - s.index);
372
- for (const { index: s, group: i } of n) {
373
- const r = Math.min(s, this.animationGroups.length);
374
- this.animationGroups.splice(r, 0, i), this.timingOptions.splice(r, 0, i.getTimingOptions());
375
- const o = [...i.animations], c = this.animationGroups.slice(0, r).reduce((a, u) => a + u.animations.length, 0);
376
- this.animations.splice(c, 0, ...o);
377
- }
378
- this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((s) => s.ready)).then(() => {
379
- });
380
- }
381
- /**
382
- * Removes AnimationGroups that match the predicate, then recalculates
383
- * stagger offsets for remaining groups. Cancelled animations in removed
384
- * groups are returned.
385
- */
386
- removeGroups(e) {
387
- const n = [], s = [], i = [];
388
- for (let r = 0; r < this.animationGroups.length; r++)
389
- e(this.animationGroups[r]) ? n.push(this.animationGroups[r]) : (s.push(this.animationGroups[r]), i.push(this.timingOptions[r]));
390
- if (n.length === 0) return n;
391
- for (const r of n)
392
- r.cancel();
393
- return this.animationGroups = s, this.timingOptions = i, this.animations = s.flatMap((r) => [...r.animations]), this.applyOffsets(), this.ready = Promise.all(this.animationGroups.map((r) => r.ready)).then(() => {
394
- }), n;
395
- }
396
- async onFinish(e) {
397
- try {
398
- await Promise.all(this.animationGroups.map((n) => n.finished)), e();
399
- } catch (n) {
400
- console.warn("animation was interrupted - aborting onFinish callback - ", n);
401
- }
402
- }
403
- }
404
- class an {
405
- _animation;
406
- customEffect;
407
- progress;
408
- _tickCbId;
409
- _finishHandler;
410
- constructor(e, n, s, i) {
411
- const r = new KeyframeEffect(n, [], {
412
- ...s,
413
- composite: "add"
414
- }), { timeline: o } = i;
415
- this._animation = new Animation(r, o), this._tickCbId = null, this.progress = null, this.customEffect = (c) => e(r.target, c), this._finishHandler = (c) => {
416
- this.effect.target?.getAnimations().find((a) => a === this._animation) || this.cancel();
417
- }, this.addEventListener("finish", this._finishHandler), this.addEventListener("remove", this._finishHandler);
418
- }
419
- // private tick method for customEffect loop implementation
420
- _tick() {
421
- try {
422
- const e = this.effect?.getComputedTiming().progress ?? null;
423
- e !== this.progress && (this.customEffect?.(e), this.progress = e), this._tickCbId = requestAnimationFrame(() => {
424
- this._tick();
425
- });
426
- } catch (e) {
427
- this._tickCbId = null, console.error(
428
- `failed to run customEffect! effectId: ${this.id}, error: ${e instanceof Error ? e.message : e}`
429
- );
430
- }
431
- }
432
- // Animation timing properties
433
- get currentTime() {
434
- return this._animation.currentTime;
435
- }
436
- set currentTime(e) {
437
- this._animation.currentTime = e;
438
- }
439
- get startTime() {
440
- return this._animation.startTime;
441
- }
442
- set startTime(e) {
443
- this._animation.startTime = e;
444
- }
445
- get playbackRate() {
446
- return this._animation.playbackRate;
447
- }
448
- set playbackRate(e) {
449
- this._animation.playbackRate = e;
450
- }
451
- // Animation basic properties
452
- get id() {
453
- return this._animation.id;
454
- }
455
- set id(e) {
456
- this._animation.id = e;
457
- }
458
- get effect() {
459
- return this._animation.effect;
460
- }
461
- set effect(e) {
462
- this._animation.effect = e;
463
- }
464
- get timeline() {
465
- return this._animation.timeline;
466
- }
467
- set timeline(e) {
468
- this._animation.timeline = e;
469
- }
470
- // Animation readonly state properties
471
- get finished() {
472
- return this._animation.finished;
473
- }
474
- get pending() {
475
- return this._animation.pending;
476
- }
477
- get playState() {
478
- return this._animation.playState;
479
- }
480
- get ready() {
481
- return this._animation.ready;
482
- }
483
- get replaceState() {
484
- return this._animation.replaceState;
485
- }
486
- // Animation event handlers
487
- get oncancel() {
488
- return this._animation.oncancel;
489
- }
490
- set oncancel(e) {
491
- this._animation.oncancel = e;
492
- }
493
- get onfinish() {
494
- return this._animation.onfinish;
495
- }
496
- set onfinish(e) {
497
- this._animation.onfinish = e;
498
- }
499
- get onremove() {
500
- return this._animation.onremove;
501
- }
502
- set onremove(e) {
503
- this._animation.onremove = e;
504
- }
505
- // CustomAnimation overridden methods
506
- play() {
507
- this._animation.play(), cancelAnimationFrame(this._tickCbId), this._tickCbId = requestAnimationFrame(() => this._tick());
508
- }
509
- pause() {
510
- this._animation.pause(), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
511
- }
512
- cancel() {
513
- this.removeEventListener("finish", this._finishHandler), this.removeEventListener("remove", this._finishHandler), this._animation.cancel(), this.customEffect(null), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
514
- }
515
- commitStyles() {
516
- console.warn(
517
- "CustomEffect animations do not support commitStyles method as they have no style to commit"
518
- );
519
- }
520
- // Animation methods without override
521
- finish() {
522
- this._animation.finish();
523
- }
524
- persist() {
525
- this._animation.persist();
526
- }
527
- reverse() {
528
- this._animation.reverse();
529
- }
530
- updatePlaybackRate(e) {
531
- this._animation.updatePlaybackRate(e);
532
- }
533
- // Animation events API
534
- addEventListener(e, n, s) {
535
- this._animation.addEventListener(e, n, s);
536
- }
537
- removeEventListener(e, n, s) {
538
- this._animation.removeEventListener(e, n, s);
539
- }
540
- dispatchEvent(e) {
541
- return this._animation.dispatchEvent(e);
542
- }
543
- }
544
- function fn(t) {
545
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
546
- }
547
- var ne = { exports: {} }, $e = ne.exports, Pe;
548
- function un() {
549
- return Pe || (Pe = 1, (function(t) {
550
- (function(e) {
551
- var n = function() {
552
- }, s = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.msRequestAnimationFrame || function(f) {
553
- return setTimeout(f, 16);
554
- };
555
- function i() {
556
- var f = this;
557
- f.reads = [], f.writes = [], f.raf = s.bind(e);
558
- }
559
- i.prototype = {
560
- constructor: i,
561
- /**
562
- * We run this inside a try catch
563
- * so that if any jobs error, we
564
- * are able to recover and continue
565
- * to flush the batch until it's empty.
566
- *
567
- * @param {Array} tasks
568
- */
569
- runTasks: function(f) {
570
- for (var l; l = f.shift(); ) l();
571
- },
572
- /**
573
- * Adds a job to the read batch and
574
- * schedules a new frame if need be.
575
- *
576
- * @param {Function} fn
577
- * @param {Object} ctx the context to be bound to `fn` (optional).
578
- * @public
579
- */
580
- measure: function(f, l) {
581
- var d = l ? f.bind(l) : f;
582
- return this.reads.push(d), r(this), d;
583
- },
584
- /**
585
- * Adds a job to the
586
- * write batch and schedules
587
- * a new frame if need be.
588
- *
589
- * @param {Function} fn
590
- * @param {Object} ctx the context to be bound to `fn` (optional).
591
- * @public
592
- */
593
- mutate: function(f, l) {
594
- var d = l ? f.bind(l) : f;
595
- return this.writes.push(d), r(this), d;
596
- },
597
- /**
598
- * Clears a scheduled 'read' or 'write' task.
599
- *
600
- * @param {Object} task
601
- * @return {Boolean} success
602
- * @public
603
- */
604
- clear: function(f) {
605
- return c(this.reads, f) || c(this.writes, f);
606
- },
607
- /**
608
- * Extend this FastDom with some
609
- * custom functionality.
610
- *
611
- * Because fastdom must *always* be a
612
- * singleton, we're actually extending
613
- * the fastdom instance. This means tasks
614
- * scheduled by an extension still enter
615
- * fastdom's global task queue.
616
- *
617
- * The 'super' instance can be accessed
618
- * from `this.fastdom`.
619
- *
620
- * @example
621
- *
622
- * var myFastdom = fastdom.extend({
623
- * initialize: function() {
624
- * // runs on creation
625
- * },
626
- *
627
- * // override a method
628
- * measure: function(fn) {
629
- * // do extra stuff ...
630
- *
631
- * // then call the original
632
- * return this.fastdom.measure(fn);
633
- * },
634
- *
635
- * ...
636
- * });
637
- *
638
- * @param {Object} props properties to mixin
639
- * @return {FastDom}
640
- */
641
- extend: function(f) {
642
- if (typeof f != "object") throw new Error("expected object");
643
- var l = Object.create(this);
644
- return a(l, f), l.fastdom = this, l.initialize && l.initialize(), l;
645
- },
646
- // override this with a function
647
- // to prevent Errors in console
648
- // when tasks throw
649
- catch: null
650
- };
651
- function r(f) {
652
- f.scheduled || (f.scheduled = !0, f.raf(o.bind(null, f)));
653
- }
654
- function o(f) {
655
- var l = f.writes, d = f.reads, g;
656
- try {
657
- n("flushing reads", d.length), f.runTasks(d), n("flushing writes", l.length), f.runTasks(l);
658
- } catch (h) {
659
- g = h;
660
- }
661
- if (f.scheduled = !1, (d.length || l.length) && r(f), g)
662
- if (n("task errored", g.message), f.catch) f.catch(g);
663
- else throw g;
664
- }
665
- function c(f, l) {
666
- var d = f.indexOf(l);
667
- return !!~d && !!f.splice(d, 1);
668
- }
669
- function a(f, l) {
670
- for (var d in l)
671
- l.hasOwnProperty(d) && (f[d] = l[d]);
672
- }
673
- var u = e.fastdom = e.fastdom || new i();
674
- t.exports = u;
675
- })(typeof window < "u" ? window : typeof $e < "u" ? $e : globalThis);
676
- })(ne)), ne.exports;
677
- }
678
- var ln = un();
679
- const O = /* @__PURE__ */ fn(ln), ve = {};
680
- function dn(t) {
681
- Object.assign(ve, t);
682
- }
683
- function hn(t) {
684
- return t in ve ? ve[t] : (console.warn(
685
- `${t} not found in registry. Please make sure to import and register the preset.`
686
- ), null);
687
- }
688
- function N(t, e) {
689
- return t ? (e || document).getElementById(t) : null;
690
- }
691
- function mn(t, e) {
692
- return t?.matches(`[data-motion-part~="${e}"]`) ? t : t?.querySelector(`[data-motion-part~="${e}"]`);
693
- }
694
- function pn(t) {
695
- const e = t.alternate ? "alternate" : "";
696
- return t.reversed ? `${e ? `${e}-` : ""}reverse` : e || "normal";
697
- }
698
- function he(t) {
699
- return `${t.value}${Xt(t.unit)}`;
700
- }
701
- function qe(t, e, n) {
702
- return `${t.name || "cover"} ${n && t.offset.unit !== "percentage" ? `calc(100% + ${he(t.offset)}${e ? ` + ${e}` : ""})` : e ? `calc(${he(t.offset)} + ${e})` : he(t.offset)}`;
703
- }
704
- function Ke(t) {
705
- return {
706
- start: qe(t.startOffset, t.startOffsetAdd),
707
- end: qe(t.endOffset, t.endOffsetAdd, !0)
708
- };
709
- }
710
- function Be(t) {
711
- return (e) => O.measure(() => e(t));
712
- }
713
- function Ue(t) {
714
- return (e) => O.mutate(() => e(t));
715
- }
716
- function V(t) {
717
- if (t.namedEffect) {
718
- const e = t.namedEffect.type;
719
- return typeof e == "string" ? hn(e) : null;
720
- } else if (t.keyframeEffect) {
721
- const e = (s) => {
722
- const { name: i, keyframes: r } = s.keyframeEffect;
723
- return [{ ...s, name: i, keyframes: r }];
724
- };
725
- return { web: e, style: e, getNames: (s) => {
726
- const { effectId: i } = s, { name: r } = s.keyframeEffect, o = r || i;
727
- return o ? [o] : [];
728
- } };
729
- } else if (t.customEffect)
730
- return (e) => [{ ...e, keyframes: [] }];
731
- return null;
732
- }
733
- function Qe(t, e, n, s) {
734
- return t.map((i, r) => {
735
- const o = {
736
- fill: i.fill,
737
- easing: te(i.easing),
738
- iterations: i.iterations === 0 ? 1 / 0 : i.iterations || 1,
739
- composite: i.composite,
740
- direction: pn(i)
741
- };
742
- Ce(e) ? (o.duration = i.duration, o.delay = i.delay || 0) : e?.trigger === "view-progress" && (s || window.ViewTimeline) ? o.duration = "auto" : (o.duration = 99.99, o.delay = 0.01);
743
- const c = nn(i.keyframes);
744
- return {
745
- effect: c === i.keyframes ? i : { ...i, keyframes: c },
746
- options: o,
747
- id: n && `${n}-${r + 1}`,
748
- part: i.part
749
- };
750
- });
751
- }
752
- function Ce(t) {
753
- return !t || t.trigger !== "pointer-move" && t.trigger !== "view-progress";
754
- }
755
- function Me(t, e, n, s, i) {
756
- if (t) {
757
- if (Ce(s) && (e.duration = e.duration || 1, i?.reducedMotion))
758
- if (e.iterations === 1 || e.iterations == null)
759
- e = { ...e, duration: 1 };
760
- else
761
- return [];
762
- let r;
763
- return n instanceof HTMLElement && (r = { measure: Be(n), mutate: Ue(n) }), t.web ? t.web(e, r, i) : t(e, r, i);
764
- }
765
- return [];
766
- }
767
- function Xe(t, e, n, s, i) {
768
- const r = typeof t == "string" ? N(t, i) : t;
769
- if (n?.trigger === "pointer-move" && !e.keyframeEffect) {
770
- let d = e;
771
- e.customEffect && (d = {
772
- ...e,
773
- namedEffect: { id: "", type: "CustomMouse" }
774
- });
775
- const g = V(
776
- d
777
- ), h = Me(
778
- g,
779
- e,
780
- r,
781
- n,
782
- s
783
- );
784
- return typeof h != "function" ? null : h(r);
785
- }
786
- const o = V(e), c = Me(
787
- o,
788
- e,
789
- r,
790
- n,
791
- s
792
- );
793
- if (!c || c.length === 0)
794
- return null;
795
- const a = Qe(c, n, e.effectId);
796
- let u;
797
- const f = n?.trigger === "view-progress";
798
- f && window.ViewTimeline && (u = new ViewTimeline({
799
- subject: n.element || N(n.componentId)
800
- }));
801
- const l = a.map(({ effect: d, options: g, id: h, part: m }) => {
802
- const p = m ? mn(r, m) : r, v = new KeyframeEffect(p || null, [], g);
803
- O.mutate(() => {
804
- "timing" in d && v.updateTiming(d.timing), v.setKeyframes(d.keyframes);
805
- });
806
- const y = f && u ? { timeline: u } : {}, E = typeof d.customEffect == "function" ? new an(
807
- d.customEffect,
808
- p || null,
809
- g,
810
- y
811
- ) : new Animation(v, y.timeline);
812
- if (f)
813
- if (u)
814
- O.mutate(() => {
815
- const { start: w, end: S } = Ke(d);
816
- E.rangeStart = w, E.rangeEnd = S, E.play();
817
- });
818
- else {
819
- const { startOffset: w, endOffset: S } = e;
820
- O.mutate(() => {
821
- const T = d.startOffset || w, I = d.endOffset || S;
822
- Object.assign(E, {
823
- start: {
824
- name: T.name,
825
- offset: T.offset?.value,
826
- add: d.startOffsetAdd
827
- },
828
- end: {
829
- name: I.name,
830
- offset: I.offset?.value,
831
- add: d.endOffsetAdd
832
- }
833
- });
834
- });
835
- }
836
- return h && (E.id = h), E;
837
- });
838
- return new Y(l, {
839
- ...e,
840
- trigger: { ...n || {} },
841
- // make sure the group is ready after all animation targets are measured and mutated
842
- measured: new Promise((d) => O.mutate(d))
843
- });
844
- }
845
- function gn(t, e) {
846
- return t ? `#${t}${e ? `[data-motion-part~="${e}"]` : ""}` : "";
847
- }
848
- function vn(t, e) {
849
- const { duration: n, delay: s, iterations: i = 1, fill: r, easing: o = "linear", direction: c } = t.options, a = t.effect.name, u = n === "auto";
850
- return `${a} ${u ? "auto" : `${n}ms`}${u ? " " : ` ${s ?? 0}ms `}${o}${r && r !== "none" ? ` ${r}` : ""} ${!i || i === 1 / 0 ? "infinite" : i}${c === "normal" ? "" : ` ${c}`} ${e ? "" : "paused"}`;
851
- }
852
- function yn(t, e, n) {
853
- return t?.style ? (Ce(n) && (e.duration = e.duration || 1), t.style(e)) : [];
854
- }
855
- function En(t, e, n) {
856
- const s = V(e), i = yn(s, e), r = Qe(i, n, e.effectId, !0), o = n?.trigger === "view-progress";
857
- return r.map((c, a) => {
858
- const { start: u, end: f } = o ? Ke(c.effect) : {};
859
- return {
860
- target: gn(t, c.part),
861
- animation: vn(c, o),
862
- composition: c.options.composite,
863
- custom: c.effect.custom,
864
- name: c.effect.name,
865
- keyframes: c.effect.keyframes,
866
- id: c.id && `${c.id}-${a + 1}`,
867
- animationTimeline: o ? `--${n?.id}` : "",
868
- animationRange: u || f ? `${u} ${f}` : ""
869
- };
870
- });
871
- }
872
- function wn(t, e, n) {
873
- const s = V(e), i = t instanceof HTMLElement ? t : N(t);
874
- if (s && s.prepare && i) {
875
- const r = { measure: Be(i), mutate: Ue(i) };
876
- s.prepare(e, r);
877
- }
878
- n && O.mutate(n);
879
- }
880
- function Ze(t, e) {
881
- const n = V(e);
882
- if (!n)
883
- return null;
884
- if (!n.style)
885
- return e.effectId && t ? bn(t, e.effectId) : null;
886
- const s = n.getNames(e), r = (typeof t == "string" ? N(t) : t)?.getAnimations(), o = r?.map((a) => a.animationName) || [], c = [];
887
- return s.forEach((a) => {
888
- o.includes(a) && c.push(
889
- r?.find((u) => u.animationName === a)
890
- );
891
- }), c?.length ? new Y(c) : null;
892
- }
893
- function bn(t, e) {
894
- const s = (typeof t == "string" ? N(t) : t)?.getAnimations().filter((i) => {
895
- const r = i.id || i.animationName;
896
- return r ? r.startsWith(e) : !0;
897
- });
898
- return s?.length ? new Y(s) : null;
899
- }
900
- function Je(t, e, n, s = {}) {
901
- const { disabled: i, allowActiveEvent: r, ...o } = s, c = Xe(t, e, n, o);
902
- if (!c)
903
- return null;
904
- let a = {};
905
- if (n.trigger === "view-progress" && !window.ViewTimeline) {
906
- const u = n.element || N(n.componentId), { ready: f } = c;
907
- return c.animations.map((l) => ({
908
- /* we use getters for start and end in order to access the animation's start and end
909
- only when initializing the scrub scene rather than immediately */
910
- get start() {
911
- return l.start;
912
- },
913
- get end() {
914
- return l.end;
915
- },
916
- viewSource: u,
917
- ready: f,
918
- getProgress() {
919
- return c.getProgress();
920
- },
921
- effect(d, g) {
922
- const { activeDuration: h } = l.effect.getComputedTiming(), { delay: m } = l.effect.getTiming();
923
- l.currentTime = ((m || 0) + (h || 0)) * g;
924
- },
925
- disabled: i,
926
- destroy() {
927
- l.cancel();
928
- }
929
- }));
930
- } else if (n.trigger === "pointer-move") {
931
- const u = e, { centeredToTarget: f, transitionDuration: l, transitionEasing: d } = u, g = n.axis;
932
- if (u.keyframeEffect) {
933
- const h = c;
934
- return h.animations?.length === 0 ? null : {
935
- target: void 0,
936
- centeredToTarget: f,
937
- ready: h.ready,
938
- _currentProgress: 0,
939
- getProgress() {
940
- return this._currentProgress;
941
- },
942
- effect(p, v) {
943
- const y = g === "x" ? v.x : v.y;
944
- this._currentProgress = y, h.progress(y);
945
- },
946
- disabled: i ?? !1,
947
- destroy() {
948
- h.cancel();
949
- }
950
- };
951
- }
952
- a = {
953
- centeredToTarget: f,
954
- allowActiveEvent: r
955
- }, e.customEffect && l && (a.transitionDuration = l, a.transitionEasing = Ae(d)), a.target = c.target;
956
- }
957
- return {
958
- ...a,
959
- getProgress() {
960
- return c.getProgress();
961
- },
962
- effect(u, f, l, d) {
963
- c.progress(
964
- l ? {
965
- // @ts-expect-error spread error on p
966
- ...f,
967
- v: l,
968
- active: d
969
- } : f
970
- );
971
- },
972
- disabled: i,
973
- destroy() {
974
- c.cancel();
975
- }
976
- };
977
- }
978
- function K(t, e, n, s = !1) {
979
- const i = Ze(t, e);
980
- return i ? (i.ready = new Promise((r) => {
981
- wn(t, e, r);
982
- }), i) : Xe(t, e, n, { reducedMotion: s });
983
- }
984
- function Sn(t) {
985
- return t === null ? [null] : typeof t == "string" ? Array.from(document.querySelectorAll(t)) : Array.isArray(t) ? t : [t];
986
- }
987
- function et(t, e) {
988
- const n = [];
989
- for (const { target: s, options: i } of t) {
990
- const r = Sn(s);
991
- for (const o of r) {
992
- const c = K(
993
- o,
994
- i,
995
- void 0,
996
- e?.reducedMotion
997
- );
998
- c instanceof Y && n.push(c);
999
- }
1000
- }
1001
- return n;
1002
- }
1003
- function Tn(t, e, n) {
1004
- const s = et(e, n);
1005
- return new cn(s, t);
1006
- }
1007
- function In(t, e = 2) {
1008
- return parseFloat(t.toFixed(e));
1009
- }
1010
- function On(t) {
1011
- return /\[]/g.test(t);
1012
- }
1013
- function An(t) {
1014
- return `--${t.join("-")}`;
1015
- }
1016
- function Cn(t) {
1017
- return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
1018
- }
1019
- function _n(t, e, n, s) {
1020
- const i = t.length - 1;
1021
- t.forEach((r, o) => {
1022
- if (r) {
1023
- const c = o ? s(o / i) * i * n | 0 : 0;
1024
- r.delay = e + c + (r.delay || 0);
1025
- }
1026
- });
1027
- }
1028
- function se(t, e) {
1029
- return e.includes("&") ? e.replace(/&/g, t) : `${t}${e}`;
1030
- }
1031
- function _() {
1032
- return "wi-12343210".replace(
1033
- /\d/g,
1034
- (t) => String.fromCharCode(
1035
- (+t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +t / 4) + 97
1036
- )
1037
- // 97 for "a"
1038
- );
1039
- }
1040
- function tt(t) {
1041
- const { transition: e, transitionProperties: n } = t;
1042
- return (e?.styleProperties || n || []).map((i) => ({
1043
- ...i,
1044
- name: ce(i.name)
1045
- }));
1046
- }
1047
- function nt(t) {
1048
- let { transition: e, transitionProperties: n } = t, s = [];
1049
- if (e?.styleProperties) {
1050
- const { duration: i, easing: r, delay: o } = e;
1051
- i && (e.styleProperties.some(
1052
- (a) => a.name.startsWith("--")
1053
- ) ? s = [
1054
- `all ${i}ms ${te(r || "ease")}${o ? ` ${o}ms` : ""}`,
1055
- "visibility 0s"
1056
- ] : s = e.styleProperties.map(
1057
- (a) => `${ce(a.name)} ${i}ms ${te(
1058
- r || "ease"
1059
- )}${o ? ` ${o}ms` : ""}`
1060
- ));
1061
- } else
1062
- s = n?.filter((i) => i.duration).map(
1063
- (i) => `${ce(i.name)} ${i.duration}ms ${te(i.easing) || "ease"}${i.delay ? ` ${i.delay}ms` : ""}`
1064
- ) || [];
1065
- return s;
1066
- }
1067
- function kn({
1068
- key: t,
1069
- effectId: e,
1070
- transition: n,
1071
- transitionProperties: s,
1072
- childSelector: i = "> :first-child",
1073
- selectorCondition: r
1074
- }) {
1075
- const o = nt({
1076
- transition: n,
1077
- transitionProperties: s
1078
- }), c = tt({ transition: n, transitionProperties: s }).map(
1079
- (h) => `${h.name}: ${h.value};`
1080
- ), a = t.replace(/"/g, "'"), u = `:is(:state(${e}), :--${e}) ${i}`, f = `[data-interact-effect~="${e}"] ${i}`, l = r ? se(u, r) : u, d = r ? se(f, r) : f, g = [
1081
- `${l},
1082
- ${d} {
1083
- ${c.join(`
1084
- `)}
1085
- }`
1086
- ];
1087
- if (o.length) {
1088
- const h = `[data-interact-key="${a}"] ${i}`, m = r ? se(h, r) : h;
1089
- g.push(`@media (prefers-reduced-motion: no-preference) { ${m} {
1090
- transition: ${o.join(", ")};
1091
- } }`);
1092
- }
1093
- return g;
1094
- }
1095
- function B(t, e, n) {
1096
- const s = (t || []).filter((i) => e[i]?.type === n && e[i].predicate).map((i) => e[i].predicate).join(") and (");
1097
- return s && `(${s})`;
1098
- }
1099
- function $(t, e) {
1100
- const n = B(t, e, "media");
1101
- return n && window.matchMedia(n);
1102
- }
1103
- function P(t, e) {
1104
- return (t || []).filter((n) => e[n]?.type === "selector" && e[n].predicate).map((n) => `:is(${e[n].predicate})`).join("");
1105
- }
1106
- const Q = {
1107
- rangeStart: { name: "cover", offset: { value: 0, unit: "percentage" } },
1108
- rangeEnd: { name: "cover", offset: { value: 100, unit: "percentage" } }
1109
- };
1110
- function $n(t, e) {
1111
- const n = t?.name ?? Q.rangeStart.name, s = e?.name ?? t?.name ?? Q.rangeEnd.name, i = {
1112
- name: n,
1113
- offset: t?.offset || Q.rangeStart.offset
1114
- }, r = {
1115
- name: s,
1116
- offset: e?.offset || Q.rangeEnd.offset
1117
- };
1118
- return { startOffset: i, endOffset: r };
1119
- }
1120
- function q(t) {
1121
- if ("keyframeEffect" in t && !t.keyframeEffect.name && "effectId" in t && (t.keyframeEffect.name = t.effectId), "duration" in t)
1122
- return {
1123
- id: "",
1124
- ...t
1125
- };
1126
- const { rangeStart: e, rangeEnd: n, ...s } = t, { startOffset: i, endOffset: r } = $n(e, n);
1127
- return {
1128
- id: "",
1129
- startOffset: i,
1130
- endOffset: r,
1131
- ...s
1132
- };
1133
- }
1134
- function A(t, e, n) {
1135
- let s = t.get(e);
1136
- s || (s = /* @__PURE__ */ new Set(), t.set(e, s)), s.add(n);
1137
- }
1138
- function U(t, e) {
1139
- t.get(e)?.forEach((s) => {
1140
- const { source: i, target: r, cleanup: o } = s;
1141
- o();
1142
- const c = i === e ? r : i;
1143
- t.get(c)?.delete(s);
1144
- }), t.delete(e);
1145
- }
1146
- const Pn = {
1147
- root: null,
1148
- rootMargin: "0px 0px -10% 0px",
1149
- threshold: [0]
1150
- }, qn = {
1151
- root: null,
1152
- rootMargin: "0px",
1153
- threshold: [0]
1154
- }, Mn = 0.2;
1155
- function xn(t) {
1156
- const e = t.trim().split(/\s+/), n = e[0], s = e.length > 1 ? e[1] : e[0], i = (r) => r.startsWith("-") ? r.slice(1) : parseFloat(r) ? `-${r}` : r;
1157
- return `${i(n)} 0px ${i(s)}`;
1158
- }
1159
- const H = {}, M = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakSet(), j = /* @__PURE__ */ new WeakMap();
1160
- let st = {}, D = null;
1161
- function Ln(t) {
1162
- st = t;
1163
- }
1164
- function it(t, e, n) {
1165
- M.get(t)?.forEach(({ source: i, handler: r }) => {
1166
- i === t && r(e, n);
1167
- });
1168
- }
1169
- function xe() {
1170
- return D || (D = new IntersectionObserver((t) => {
1171
- t.forEach((e) => {
1172
- const n = e.target;
1173
- e.isIntersecting || it(n, !1, !0);
1174
- });
1175
- }, qn), D);
1176
- }
1177
- function rt(t, e = !1) {
1178
- const n = JSON.stringify({ ...t, isSafeMode: e });
1179
- if (H[n])
1180
- return H[n];
1181
- const s = t.threshold ?? Mn, i = e ? Pn : {
1182
- root: null,
1183
- rootMargin: t.inset ? xn(t.inset) : "0px",
1184
- threshold: s
1185
- }, r = new IntersectionObserver((o) => {
1186
- o.forEach((c) => {
1187
- const a = c.target, u = !ae.has(a);
1188
- if (u && (ae.add(a), t.useSafeViewEnter && !c.isIntersecting)) {
1189
- O.measure(() => {
1190
- const f = c.boundingClientRect.height, l = c.rootBounds?.height;
1191
- if (!l)
1192
- return;
1193
- const d = Array.isArray(t.threshold) ? Math.min(...t.threshold) : t.threshold;
1194
- d && f * d > l && O.mutate(() => {
1195
- r.unobserve(a);
1196
- const h = rt(t, !0);
1197
- j.set(a, h), h.observe(a);
1198
- });
1199
- });
1200
- return;
1201
- }
1202
- (c.isIntersecting || !u) && it(a, c.isIntersecting);
1203
- });
1204
- }, i);
1205
- return H[n] = r, r;
1206
- }
1207
- function Fn(t, e, n, s = {}, { reducedMotion: i, selectorCondition: r, animation: o } = {}) {
1208
- const c = { ...st, ...s }, a = n.triggerType || "once", u = o || K(
1209
- e,
1210
- q(n),
1211
- void 0,
1212
- i
1213
- );
1214
- if (!u)
1215
- return;
1216
- const f = rt(c);
1217
- a !== "once" && u.persist?.();
1218
- let l = !0, d = !1, g;
1219
- g = { source: t, target: e, handler: (p, v) => {
1220
- if (!(r && !e.matches(r)))
1221
- if (a === "once") {
1222
- if (p && !d) {
1223
- d = !0, M.get(t)?.delete(g), M.get(e)?.delete(g);
1224
- const y = M.get(t);
1225
- (!y || y.size === 0) && ((j.get(t) || f).unobserve(t), ae.delete(t)), u.play(() => {
1226
- const E = () => {
1227
- e.dataset.interactEnter = "start";
1228
- };
1229
- if (u.isCSS) {
1230
- O.mutate(() => {
1231
- requestAnimationFrame(E);
1232
- });
1233
- const w = () => {
1234
- O.mutate(() => {
1235
- e.dataset.interactEnter = "done";
1236
- });
1237
- };
1238
- u.onFinish(w), u.onAbort(w);
1239
- } else
1240
- O.mutate(E);
1241
- });
1242
- }
1243
- } else a === "alternate" ? l && p ? (l = !1, u.play()) : l || u.reverse() : a === "repeat" ? p ? (u.progress(0), u.play()) : v && (u.pause(), u.progress(0)) : a === "state" && (p ? u.play() : v && u.pause());
1244
- }, cleanup: () => {
1245
- (j.get(t) || f).unobserve(t), (a === "repeat" || a === "state") && xe().unobserve(t), u.cancel(), ae.delete(t), j.delete(t);
1246
- } }, A(M, t, g), A(M, e, g), j.set(t, f), f.observe(t), (a === "repeat" || a === "state") && xe().observe(t);
1247
- }
1248
- function Rn(t) {
1249
- U(M, t);
1250
- }
1251
- function Nn() {
1252
- D = null, Object.keys(H).forEach((t) => delete H[t]);
1253
- }
1254
- const zn = {
1255
- add: Fn,
1256
- remove: Rn,
1257
- setOptions: Ln,
1258
- reset: Nn
1259
- };
1260
- function ot(t, e) {
1261
- return Object.assign(Object.create(e), t);
1262
- }
1263
- function jn(t, e, n, s) {
1264
- let i = t * (1 - n) + e * n;
1265
- if (s) {
1266
- const r = i - t;
1267
- Math.abs(r) < s && (i = t + s * Math.sign(r));
1268
- const o = e - i;
1269
- if (Math.abs(o) < s)
1270
- return e;
1271
- }
1272
- return i;
1273
- }
1274
- function Dn(t) {
1275
- let e = !1;
1276
- return function() {
1277
- e || (e = !0, window.requestAnimationFrame(() => {
1278
- e = !1, t();
1279
- }));
1280
- };
1281
- }
1282
- function Le(t, e) {
1283
- let n = 0;
1284
- return function() {
1285
- n && window.clearTimeout(n), n = window.setTimeout(() => {
1286
- n = 0, t();
1287
- }, e);
1288
- };
1289
- }
1290
- function Gn(t, e) {
1291
- const n = t.match(/^calc\s*\(\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\+\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\)\s*$/);
1292
- return fe(n[1], e) + fe(n[6], e);
1293
- }
1294
- function fe(t, e) {
1295
- return t ? /^-?\d+px$/.test(t) ? parseInt(t) : /^-?\d+[lsd]?vh$/.test(t) ? parseInt(t) * e.viewportHeight / 100 : /^-?\d+[lsd]?vw$/.test(t) ? parseInt(t) * e.viewportWidth / 100 : /^calc\s*\(\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\+\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\)\s*$/.test(t) ? Gn(t, e) : parseInt(t) || 0 : 0;
1296
- }
1297
- function L(t, e, n) {
1298
- const { name: s, offset: i = 0 } = t, { start: r, end: o } = n, c = o - r, a = i / 100;
1299
- let u, f;
1300
- return s === "entry" ? (u = r - e, f = Math.min(e, c)) : s === "entry-crossing" ? (u = r - e, f = c) : s === "contain" ? (u = Math.min(o - e, r), f = Math.abs(e - c)) : s === "exit" ? (u = Math.max(r, o - e), f = Math.min(e, c)) : s === "exit-crossing" ? (u = r, f = c) : s === "cover" && (u = r - e, f = c + e), u + a * f | 0;
1301
- }
1302
- function me(t, e, n, s, i) {
1303
- let r = 0;
1304
- const o = { start: e, end: n };
1305
- return t.forEach((c, a) => {
1306
- r += c.offset;
1307
- const u = c.sticky;
1308
- if (u) {
1309
- if ("end" in u && t[a - 1]?.element) {
1310
- const d = ((i ? c.element.offsetWidth : c.element.offsetHeight) || 0) + u.end - s, g = r + d - c.offset, h = g < o.start, m = !h && g <= n;
1311
- let p = 0;
1312
- (h || m) && (p = c.offset, o.end += p), h && (o.start += p);
1313
- }
1314
- if ("start" in u) {
1315
- const f = r - u.start, l = f < o.start, d = !l && f <= o.end;
1316
- let g = 0;
1317
- const h = t[a - 1]?.element;
1318
- if (h) {
1319
- if (l || d) {
1320
- const m = (i ? h.offsetWidth : h.offsetHeight) || 0, p = c.offset, v = (i ? c.element.offsetWidth : c.element.offsetHeight) || 0;
1321
- g = m - (p + v), r += g, o.end += g;
1322
- }
1323
- l && (o.start += g);
1324
- }
1325
- }
1326
- }
1327
- }), o;
1328
- }
1329
- function Hn(t, e, n, s, i, r) {
1330
- const { start: o, end: c, duration: a } = t;
1331
- let u = o, f = c, l = t.startRange, d = t.endRange, g;
1332
- if (typeof a == "string") {
1333
- l = { name: a, offset: 0 }, d = { name: a, offset: 100 }, u = L(l, n, e), f = L(d, n, e), g = f - u;
1334
- const h = me(r, u, f, n, s);
1335
- u = h.start, f = h.end;
1336
- } else {
1337
- if (l || o?.name) {
1338
- l = l || o;
1339
- const h = fe(l.add, i), m = L({ ...l, offset: 0 }, n, e), p = L({ ...l, offset: 100 }, n, e), v = me(r, m, p, n, s);
1340
- u = v.start + l.offset / 100 * (v.end - v.start) + h;
1341
- }
1342
- if (d || c?.name) {
1343
- d = d || c;
1344
- const h = fe(d.add, i), m = L({ ...d, offset: 0 }, n, e), p = L({ ...d, offset: 100 }, n, e), v = me(r, m, p, n, s);
1345
- f = v.start + d.offset / 100 * (v.end - v.start) + h;
1346
- } else typeof a == "number" && (f = u + a);
1347
- }
1348
- return !g && !a && (g = f - u), { ...t, start: u, end: f, startRange: l, endRange: d, duration: g || a };
1349
- }
1350
- function Wn(t) {
1351
- return t.position === "sticky";
1352
- }
1353
- function Vn(t, e, n) {
1354
- return t.position === "fixed" && (!e || e === window.document.body || e === n);
1355
- }
1356
- function Yn(t, e) {
1357
- return parseInt(e ? t.left : t.top);
1358
- }
1359
- function Kn(t, e) {
1360
- return parseInt(e ? t.right : t.bottom);
1361
- }
1362
- function Bn(t, e, n) {
1363
- n && (t.style.position = "static");
1364
- const s = (e ? t.offsetLeft : t.offsetTop) || 0;
1365
- return n && (t.style.position = null), s;
1366
- }
1367
- function Un(t, e) {
1368
- let n;
1369
- const s = Yn(t, e), i = Kn(t, e), r = !isNaN(s), o = !isNaN(i);
1370
- return (r || o) && (n = {}, r && (n.start = s), o && (n.end = i)), n;
1371
- }
1372
- function X(t, e, n, s, i) {
1373
- const r = t[0].viewSource, o = [];
1374
- let c = (s ? r.offsetWidth : r.offsetHeight) || 0, a = 0, u = r;
1375
- for (; u; ) {
1376
- const l = window.getComputedStyle(u), d = Wn(l), g = d ? Un(l, s) : void 0, h = Bn(u, s, d);
1377
- if ((!g || !("end" in g)) && (a += h), o.push({ element: u, offset: h, sticky: g }), u = u.offsetParent, Vn(l, u, e))
1378
- break;
1379
- if (u === e) {
1380
- o.push({ element: u, offset: 0 });
1381
- break;
1382
- }
1383
- }
1384
- return o.reverse(), t.map((l) => ({
1385
- ...Hn(
1386
- l,
1387
- { start: a, end: a + c },
1388
- n,
1389
- s,
1390
- i,
1391
- o
1392
- )
1393
- }));
1394
- }
1395
- const Fe = 100, Qn = {
1396
- horizontal: !1,
1397
- observeViewportEntry: !0,
1398
- viewportRootMargin: "7% 7%",
1399
- observeViewportResize: !1,
1400
- observeSourcesResize: !1,
1401
- observeContentResize: !1
1402
- };
1403
- function Xn(t, e, n, s) {
1404
- let i = 0;
1405
- return t >= e && t <= n ? i = s ? (t - e) / s : 1 : t > n && (i = 1), i;
1406
- }
1407
- function Re(t, e) {
1408
- return t === window ? e ? window.document.documentElement.clientWidth : window.document.documentElement.clientHeight : e ? t.clientWidth : t.clientHeight;
1409
- }
1410
- function Zn() {
1411
- return {
1412
- viewportWidth: window.document.documentElement.clientWidth,
1413
- viewportHeight: window.document.documentElement.clientHeight
1414
- };
1415
- }
1416
- function Jn(t) {
1417
- const e = ot(t, Qn), n = e.root, s = e.horizontal, i = /* @__PURE__ */ new WeakMap();
1418
- let r = Re(n, s), o, c, a, u, f;
1419
- const l = [], d = Zn();
1420
- if (e.scenes = Object.values(
1421
- // TODO(ameerf): find a polyfill and use groupBy instead of following reduce
1422
- t.scenes.reduce(
1423
- (m, p, v) => {
1424
- const y = p.groupId ? `group-${p.groupId}` : String(v);
1425
- return m[y] ? m[y].push(p) : m[y] = [p], m;
1426
- },
1427
- {}
1428
- )
1429
- ).flatMap((m) => (m.every((p) => p.viewSource && (typeof p.duration == "string" || p.start?.name)) ? (m = X(m, n, r, s, d), (e.observeSourcesResize || e.observeContentResize) && l.push(m)) : m.forEach((p) => {
1430
- p.end == null && (p.end = p.start + p.duration), p.duration == null && (p.duration = p.end - p.start);
1431
- }), m)), e.scenes.forEach((m, p) => {
1432
- m.index = p;
1433
- }), l.length) {
1434
- const m = /* @__PURE__ */ new Map();
1435
- window.ResizeObserver && (a = new window.ResizeObserver(function(p) {
1436
- p.forEach((v) => {
1437
- const y = m.get(v.target), E = X(y, n, r, s, d);
1438
- E.forEach((w, S) => {
1439
- e.scenes[w.index] = E[S];
1440
- }), l.splice(l.indexOf(y), 1, E);
1441
- });
1442
- }), l.forEach((p) => {
1443
- a.observe(p[0].viewSource, { box: "border-box" }), m.set(p[0].viewSource, p);
1444
- }), e.observeContentResize && e.contentRoot && new window.ResizeObserver(Le(() => {
1445
- const v = l.map((y) => {
1446
- const E = X(y, n, r, s, d);
1447
- return E.forEach((w, S) => {
1448
- e.scenes[w.index] = E[S];
1449
- }), E;
1450
- });
1451
- l.length = 0, l.push(...v), l.forEach((y) => {
1452
- m.set(y[0].viewSource, y);
1453
- });
1454
- }, Fe)).observe(e.contentRoot, { box: "border-box" })), e.observeViewportResize && (u = Le(function() {
1455
- r = Re(n, s);
1456
- const p = l.map((v) => {
1457
- const y = X(v, n, r, s, d);
1458
- return y.forEach((E, w) => {
1459
- e.scenes[E.index] = y[w];
1460
- }), y;
1461
- });
1462
- l.length = 0, l.push(...p), l.forEach((v) => {
1463
- m.set(v[0].viewSource, v);
1464
- });
1465
- }, Fe), n === window ? window.addEventListener("resize", u) : window.ResizeObserver && (f = new window.ResizeObserver(u), f.observe(n, { box: "border-box" })));
1466
- }
1467
- e.observeViewportEntry && window.IntersectionObserver && (c = new window.IntersectionObserver(function(m) {
1468
- m.forEach((p) => {
1469
- (i.get(p.target) || []).forEach((v) => {
1470
- v.disabled = !p.isIntersecting;
1471
- });
1472
- });
1473
- }, {
1474
- root: n === window ? window.document : n,
1475
- rootMargin: e.viewportRootMargin,
1476
- threshold: 0
1477
- }), e.scenes.forEach((m) => {
1478
- if (m.viewSource) {
1479
- let p = i.get(m.viewSource);
1480
- p || (p = [], i.set(m.viewSource, p), c.observe(m.viewSource)), p.push(m);
1481
- }
1482
- }));
1483
- function g({ p: m, vp: p }) {
1484
- m = +m.toFixed(1);
1485
- const v = +p.toFixed(4);
1486
- if (m !== o) {
1487
- for (let y of e.scenes)
1488
- if (!y.disabled) {
1489
- const { start: E, end: w, duration: S } = y, T = Xn(m, E, w, S);
1490
- y.effect(y, T, v);
1491
- }
1492
- o = m;
1493
- }
1494
- }
1495
- function h() {
1496
- e.scenes.forEach((m) => m.destroy?.()), c && (c.disconnect(), c = null), a && (a.disconnect(), a = null), u && (f ? (f.disconnect(), f = null) : window.removeEventListener("resize", u));
1497
- }
1498
- return {
1499
- tick: g,
1500
- destroy: h
1501
- };
1502
- }
1503
- const es = {
1504
- transitionActive: !1,
1505
- transitionFriction: 0.9,
1506
- transitionEpsilon: 1,
1507
- velocityActive: !1,
1508
- velocityMax: 1
1509
- };
1510
- class ts {
1511
- constructor(e = {}) {
1512
- this.config = ot(e, es), this.progress = {
1513
- p: 0,
1514
- prevP: 0,
1515
- vp: 0
1516
- }, this.currentProgress = {
1517
- p: 0,
1518
- prevP: 0,
1519
- vp: 0
1520
- }, this._lerpFrameId = 0, this.effect = null;
1521
- const n = !this.config.root || this.config.root === window.document.body;
1522
- this.config.root = n ? window : this.config.root, this.config.contentRoot = this.config.contentRoot || (n ? window.document.body : this.config.root.firstElementChild), this.config.resetProgress = this.config.resetProgress || this.resetProgress.bind(this), this._measure = this.config.measure || (() => {
1523
- const s = this.config.root;
1524
- this.progress.p = this.config.horizontal ? s.scrollX || s.scrollLeft || 0 : s.scrollY || s.scrollTop || 0;
1525
- }), this._trigger = Dn(() => {
1526
- this._measure?.(), this.tick(!0);
1527
- });
1528
- }
1529
- /**
1530
- * Setup event and effect, and reset progress and frame.
1531
- */
1532
- start() {
1533
- this.setupEffect(), this.setupEvent(), this.resetProgress(), this.tick();
1534
- }
1535
- /**
1536
- * Removes event listener.
1537
- */
1538
- pause() {
1539
- this.removeEvent();
1540
- }
1541
- /**
1542
- * Reset progress in the DOM and inner state to given x and y.
1543
- *
1544
- * @param {Object} [scrollPosition]
1545
- * @param {number} [scrollPosition.x]
1546
- * @param {number} [scrollPosition.y]
1547
- */
1548
- resetProgress(e = {}) {
1549
- const n = this.config.root, s = e.x || e.x === 0 ? e.x : n.scrollX || n.scrollLeft || 0, i = e.y || e.y === 0 ? e.y : n.scrollY || n.scrollTop || 0, r = this.config.horizontal ? s : i;
1550
- this.progress.p = r, this.progress.prevP = r, this.progress.vp = 0, this.config.transitionActive && (this.currentProgress.p = r, this.currentProgress.prevP = r, this.currentProgress.vp = 0), e && this.config.root.scrollTo(s, i);
1551
- }
1552
- /**
1553
- * Handle animation frame work.
1554
- *
1555
- * @param {boolean} [clearLerpFrame] whether to cancel an existing lerp frame
1556
- */
1557
- tick(e) {
1558
- const n = this.config.transitionActive;
1559
- n && this.lerp();
1560
- const s = n ? this.currentProgress : this.progress;
1561
- if (this.config.velocityActive) {
1562
- const i = s.p - s.prevP, r = i < 0 ? -1 : 1;
1563
- s.vp = Math.min(this.config.velocityMax, Math.abs(i)) / this.config.velocityMax * r;
1564
- }
1565
- this.effect.tick(s), n && s.p !== this.progress.p && (e && this._lerpFrameId && window.cancelAnimationFrame(this._lerpFrameId), this._lerpFrameId = window.requestAnimationFrame(() => this.tick())), s.prevP = s.p;
1566
- }
1567
- /**
1568
- * Calculate current progress.
1569
- */
1570
- lerp() {
1571
- this.currentProgress.p = jn(this.currentProgress.p, this.progress.p, +(1 - this.config.transitionFriction).toFixed(3), this.config.transitionEpsilon);
1572
- }
1573
- /**
1574
- * Stop the event and effect, and remove all DOM side-effects.
1575
- */
1576
- destroy() {
1577
- this.pause(), this.removeEffect();
1578
- }
1579
- /**
1580
- * Register to scroll for triggering update.
1581
- */
1582
- setupEvent() {
1583
- this.removeEvent(), this.config.root.addEventListener("scroll", this._trigger);
1584
- }
1585
- /**
1586
- * Remove scroll handler.
1587
- */
1588
- removeEvent() {
1589
- this.config.root.removeEventListener("scroll", this._trigger);
1590
- }
1591
- /**
1592
- * Reset registered effect.
1593
- */
1594
- setupEffect() {
1595
- this.removeEffect(), this.effect = Jn(this.config);
1596
- }
1597
- /**
1598
- * Remove registered effect.
1599
- */
1600
- removeEffect() {
1601
- this.effect && this.effect.destroy(), this.effect = null;
1602
- }
1603
- }
1604
- const ye = /* @__PURE__ */ new WeakMap();
1605
- let ct = () => ({});
1606
- function ns(t) {
1607
- ct = t;
1608
- }
1609
- function ss(t, e, n, s, { reducedMotion: i }) {
1610
- if (i)
1611
- return;
1612
- const r = {
1613
- trigger: "view-progress",
1614
- element: t
1615
- }, o = q(n);
1616
- let c;
1617
- if ("ViewTimeline" in window) {
1618
- const u = K(
1619
- e,
1620
- o,
1621
- r
1622
- );
1623
- u && !u.isCSS && (u.play(), c = () => {
1624
- u.ready.then(() => {
1625
- u.cancel();
1626
- });
1627
- });
1628
- } else {
1629
- const u = Je(e, o, r);
1630
- if (u) {
1631
- const f = Array.isArray(u) ? u : [u], l = new ts({
1632
- viewSource: t,
1633
- scenes: f,
1634
- observeViewportEntry: !1,
1635
- observeViewportResize: !1,
1636
- observeSourcesResize: !0,
1637
- root: document.body,
1638
- ...ct()
1639
- });
1640
- c = () => {
1641
- l.destroy();
1642
- }, Promise.all(f.map((d) => d.ready || Promise.resolve())).then(
1643
- () => {
1644
- l.start();
1645
- }
1646
- );
1647
- }
1648
- }
1649
- if (!c) return;
1650
- const a = { source: t, target: e, cleanup: c };
1651
- A(ye, t, a), A(ye, e, a);
1652
- }
1653
- function is(t) {
1654
- U(ye, t);
1655
- }
1656
- const rs = {
1657
- add: ss,
1658
- remove: is,
1659
- registerOptionsGetter: ns
1660
- };
1661
- function Ne(t, e, n) {
1662
- return Math.min(Math.max(t, n), e);
1663
- }
1664
- function ze(t) {
1665
- let e = !1;
1666
- return function() {
1667
- if (!e)
1668
- return e = !0, window.requestAnimationFrame(() => {
1669
- e = !1, t();
1670
- });
1671
- };
1672
- }
1673
- function os(t) {
1674
- let e = t, n = 0, s = 0;
1675
- if (e.offsetParent)
1676
- do
1677
- n += e.offsetLeft, s += e.offsetTop, e = e.offsetParent;
1678
- while (e);
1679
- return {
1680
- left: n,
1681
- top: s,
1682
- width: t.offsetWidth,
1683
- height: t.offsetHeight
1684
- };
1685
- }
1686
- function cs() {
1687
- const t = window.devicePixelRatio;
1688
- let e = !1;
1689
- if (t === 1)
1690
- return !1;
1691
- document.body.addEventListener("pointerdown", (s) => {
1692
- e = s.offsetX !== 10;
1693
- }, { once: !0 });
1694
- const n = new PointerEvent("pointerdown", {
1695
- clientX: 10
1696
- });
1697
- return document.body.dispatchEvent(n), e;
1698
- }
1699
- function as() {
1700
- return new Promise((t) => {
1701
- const e = window.scrollY;
1702
- let n = !1, s;
1703
- function i() {
1704
- document.body.addEventListener("pointerdown", (c) => {
1705
- s === void 0 ? s = c.offsetY : n = c.offsetY === s;
1706
- }, { once: !0 });
1707
- const o = new PointerEvent("pointerdown", {
1708
- clientY: 500
1709
- });
1710
- document.body.dispatchEvent(o);
1711
- }
1712
- function r() {
1713
- window.scrollY !== e && (window.removeEventListener("scroll", r), i(), t(n));
1714
- }
1715
- i(), window.addEventListener("scroll", r), window.scrollY > 0 && window.scrollBy(0, -1);
1716
- });
1717
- }
1718
- function fs(t) {
1719
- as().then((e) => {
1720
- t.fixRequired = e, e && (window.addEventListener("scroll", t.scrollHandler), t.scrollHandler());
1721
- });
1722
- }
1723
- let Z = 0;
1724
- const ie = /* @__PURE__ */ new Set();
1725
- function us() {
1726
- const t = (n) => {
1727
- for (let s of n.changedTouches)
1728
- ie.add(s.identifier);
1729
- }, e = (n) => {
1730
- for (let s of n.changedTouches)
1731
- ie.delete(s.identifier);
1732
- };
1733
- return document.addEventListener("touchstart", t, { passive: !0 }), document.addEventListener("touchend", e, { passive: !0 }), function() {
1734
- ie.clear(), document.removeEventListener("touchstart", t), document.removeEventListener("touchend", e);
1735
- };
1736
- }
1737
- function ls(t, e) {
1738
- if ("onscrollend" in window)
1739
- return t.addEventListener("scrollend", e), function() {
1740
- t.removeEventListener("scrollend", e);
1741
- };
1742
- let n = 0, s;
1743
- Z || (s = us()), Z += 1;
1744
- function i(r) {
1745
- clearTimeout(n), n = setTimeout(() => {
1746
- ie.size ? setTimeout(i, 100) : (e(r), n = 0);
1747
- }, 100);
1748
- }
1749
- return t.addEventListener("scroll", i), function() {
1750
- t.removeEventListener("scroll", i), Z -= 1, Z || s();
1751
- };
1752
- }
1753
- function ds(t, e, n) {
1754
- return {
1755
- x(s) {
1756
- const i = t.left - n.x + t.width / 2, r = i >= e.width / 2, o = (r ? i : e.width - i) * 2, c = r ? 0 : i - o / 2;
1757
- return (s - c) / o;
1758
- },
1759
- y(s) {
1760
- const i = t.top - n.y + t.height / 2, r = i >= e.height / 2, o = (r ? i : e.height - i) * 2, c = r ? 0 : i - o / 2;
1761
- return (s - c) / o;
1762
- }
1763
- };
1764
- }
1765
- function hs(t, e) {
1766
- this.x = window.scrollX, this.y = window.scrollY, requestAnimationFrame(() => t && t(e));
1767
- }
1768
- function ms(t) {
1769
- t.rect.width = window.document.documentElement.clientWidth, t.rect.height = window.document.documentElement.clientHeight;
1770
- }
1771
- function ps(t) {
1772
- const e = new ResizeObserver((n) => {
1773
- n.forEach((s) => {
1774
- t.rect.width = s.borderBoxSize[0].inlineSize, t.rect.height = s.borderBoxSize[0].blockSize;
1775
- });
1776
- });
1777
- return e.observe(t.root, { box: "border-box" }), e;
1778
- }
1779
- function gs(t) {
1780
- let e = !1, n = { x: t.rect.width / 2, y: t.rect.height / 2, vx: 0, vy: 0 }, s, i, r, o, c;
1781
- const a = { x: 0, y: 0 };
1782
- t.scenes.forEach((f) => {
1783
- f.target && f.centeredToTarget && (f.transform = ds(os(f.target), t.rect, a), e = !0), t.root ? i = ps(t) : (r = ms.bind(null, t), window.addEventListener("resize", r));
1784
- }), s = function(f) {
1785
- for (let l of t.scenes)
1786
- if (!l.disabled) {
1787
- const d = l.transform?.x(f.x) || f.x / t.rect.width, g = l.transform?.y(f.y) || f.y / t.rect.height, h = +Ne(0, 1, d).toPrecision(4), m = +Ne(0, 1, g).toPrecision(4), p = { x: f.vx, y: f.vy };
1788
- t.allowActiveEvent && (f.active = d <= 1 && g <= 1 && d >= 0 && g >= 0), l.effect(l, { x: h, y: m }, p, f.active);
1789
- }
1790
- Object.assign(n, f);
1791
- }, e && (o = hs.bind(a, s, n), c = ls(document, o));
1792
- function u() {
1793
- t.scenes.forEach((f) => f.destroy?.()), c?.(), i ? (i.disconnect(), i = null) : (window.removeEventListener("resize", r), r = null), s = null, n = null;
1794
- }
1795
- return {
1796
- tick: s,
1797
- destroy: u
1798
- };
1799
- }
1800
- const vs = 1e3 / 60 * 3;
1801
- let J;
1802
- function ys() {
1803
- F.x = window.scrollX, F.y = window.scrollY;
1804
- }
1805
- const F = { x: 0, y: 0, scrollHandler: ys, fixRequired: void 0 };
1806
- class Es {
1807
- constructor(e = {}) {
1808
- this.config = { ...e }, this.effect = null, this._nextTick = null, this._nextTransitionTick = null, this._startTime = 0;
1809
- let n;
1810
- this.config.transitionDuration ? n = this.config.noThrottle ? () => this.transition() : ze(() => this.transition()) : n = this.config.noThrottle ? () => (this.tick(), null) : ze(() => {
1811
- this.tick();
1812
- }), this.config.rect = this.config.root ? {
1813
- width: this.config.root.offsetWidth,
1814
- height: this.config.root.offsetHeight
1815
- } : {
1816
- width: window.document.documentElement.clientWidth,
1817
- height: window.document.documentElement.clientHeight
1818
- }, this.progress = {
1819
- x: this.config.rect.width / 2,
1820
- y: this.config.rect.height / 2,
1821
- vx: 0,
1822
- vy: 0
1823
- }, this.previousProgress = { ...this.progress }, this.currentProgress = null;
1824
- const s = (i) => {
1825
- const r = this.config.root ? i.offsetX : i.x, o = this.config.root ? i.offsetY : i.y;
1826
- this.progress.vx = r - this.progress.x, this.progress.vy = o - this.progress.y, this.progress.x = r, this.progress.y = o, this._nextTick = n();
1827
- };
1828
- if (this._pointerLeave = () => {
1829
- this.progress.active = !1, this.progress.vx = 0, this.progress.vy = 0, this._nextTick = n();
1830
- }, this._pointerEnter = () => {
1831
- this.progress.active = !0, this._nextTick = n();
1832
- }, this.config.root) {
1833
- J = typeof J == "boolean" ? J : cs();
1834
- const i = J ? window.devicePixelRatio : 1;
1835
- typeof F.fixRequired > "u" && fs(F), this._measure = (r) => {
1836
- if (r.target !== this.config.root) {
1837
- const o = new PointerEvent("pointermove", {
1838
- bubbles: !0,
1839
- cancelable: !0,
1840
- clientX: r.x * i + F.x,
1841
- clientY: r.y * i + F.y
1842
- });
1843
- r.stopPropagation(), this.config.root.dispatchEvent(o);
1844
- } else
1845
- s(r);
1846
- };
1847
- } else
1848
- this._measure = s;
1849
- }
1850
- /**
1851
- * Setup event and effect, and reset progress and frame.
1852
- */
1853
- start() {
1854
- this.setupEffect(), this.setupEvent();
1855
- }
1856
- /**
1857
- * Removes event listener.
1858
- */
1859
- pause() {
1860
- this.removeEvent();
1861
- }
1862
- /**
1863
- * Handle animation frame work.
1864
- */
1865
- tick() {
1866
- this.effect.tick(this.progress);
1867
- }
1868
- /**
1869
- * Starts a transition from the previous progress to the current progress.
1870
- *
1871
- * @returns {number} the requestAnimationFrame id for the transition tick.
1872
- */
1873
- transition() {
1874
- const e = this.config.transitionDuration, n = this.config.transitionEasing || ((o) => o), s = performance.now();
1875
- let i = !1;
1876
- const r = (o) => {
1877
- const c = (o - this._startTime) / e, a = n(Math.min(1, c));
1878
- i && (this.progress.vx = 0, this.progress.vy = 0, i = !1), this.currentProgress = Object.entries(this.progress).reduce((u, [f, l]) => (f === "active" ? u[f] = l : u[f] = this.previousProgress[f] + (l - this.previousProgress[f]) * a, u), this.currentProgress || {}), c < 1 && (this._nextTransitionTick = requestAnimationFrame(r), i = o - this._startTime > vs), this.effect.tick(this.currentProgress);
1879
- };
1880
- return this._startTime ? (this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick), Object.assign(this.previousProgress, this.currentProgress), this._startTime = s, r(s)) : this._startTime = s, this._nextTransitionTick;
1881
- }
1882
- /**
1883
- * Stop the event and effect, and remove all DOM side effects.
1884
- */
1885
- destroy() {
1886
- this.pause(), this.removeEffect(), this._nextTick && cancelAnimationFrame(this._nextTick), this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick);
1887
- }
1888
- /**
1889
- * Register to pointermove for triggering update.
1890
- */
1891
- setupEvent() {
1892
- this.removeEvent();
1893
- const e = this.config.root || window;
1894
- e.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.eventSource && this.config.eventSource.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.allowActiveEvent && (e.addEventListener("pointerleave", this._pointerLeave, { passive: !0 }), e.addEventListener("pointerenter", this._pointerEnter, { passive: !0 }), this.config.eventSource && (this.config.eventSource.addEventListener("pointerleave", this._pointerLeave, { passive: !0 }), this.config.eventSource.addEventListener("pointerenter", this._pointerEnter, { passive: !0 })));
1895
- }
1896
- /**
1897
- * Remove pointermove handler.
1898
- */
1899
- removeEvent() {
1900
- const e = this.config.root || window;
1901
- e.removeEventListener("pointermove", this._measure), this.config.eventSource && this.config.eventSource.removeEventListener("pointermove", this._measure), this.config.allowActiveEvent && (e.removeEventListener("pointerleave", this._pointerLeave), e.removeEventListener("pointerenter", this._pointerEnter), this.config.eventSource && (this.config.eventSource.removeEventListener("pointerleave", this._pointerLeave), this.config.eventSource.removeEventListener("pointerenter", this._pointerEnter)));
1902
- }
1903
- /**
1904
- * Reset registered effect.
1905
- */
1906
- setupEffect() {
1907
- this.removeEffect(), this.effect = gs(this.config);
1908
- }
1909
- /**
1910
- * Remove registered effect.
1911
- */
1912
- removeEffect() {
1913
- this.effect && this.effect.destroy(), this.effect = null;
1914
- }
1915
- }
1916
- const Ee = /* @__PURE__ */ new WeakMap();
1917
- let at = () => ({});
1918
- function ws(t) {
1919
- at = t;
1920
- }
1921
- function bs(t, e, n, s = {}, { reducedMotion: i }) {
1922
- if (i)
1923
- return;
1924
- const r = {
1925
- trigger: "pointer-move",
1926
- element: t,
1927
- axis: s.axis ?? "y"
1928
- }, o = Je(e, q(n), r);
1929
- if (o) {
1930
- const c = Array.isArray(o) ? o : [o], a = new Es({
1931
- root: s.hitArea === "self" ? t : void 0,
1932
- scenes: c,
1933
- ...at()
1934
- }), f = { source: t, target: e, cleanup: () => {
1935
- a.destroy();
1936
- } };
1937
- A(Ee, t, f), A(Ee, e, f), Promise.all(
1938
- c.map((l) => l.ready || Promise.resolve())
1939
- ).then(() => {
1940
- a.start();
1941
- });
1942
- }
1943
- }
1944
- function Ss(t) {
1945
- U(Ee, t);
1946
- }
1947
- const Ts = {
1948
- add: bs,
1949
- remove: Ss,
1950
- registerOptionsGetter: ws
1951
- }, we = /* @__PURE__ */ new WeakMap();
1952
- function Is(t, e, n, s, {
1953
- reducedMotion: i,
1954
- selectorCondition: r,
1955
- animation: o,
1956
- sourceAnimationOptions: c
1957
- }) {
1958
- const a = o || K(
1959
- e,
1960
- q(n),
1961
- void 0,
1962
- i
1963
- );
1964
- if (!a)
1965
- return;
1966
- const { effectId: u } = s, f = (g) => {
1967
- if (r && !e.matches(r)) return;
1968
- const h = g.animationName, m = g.detail?.effectId, p = c ? Ze(t, c) : null;
1969
- if (p) {
1970
- if (p.playState === "running" || h && !p.hasAnimationName(h))
1971
- return;
1972
- if (m && m !== u && !p.hasAnimationId(m))
1973
- return;
1974
- }
1975
- a.play();
1976
- }, d = { source: t, target: e, cleanup: () => {
1977
- a.cancel(), t.removeEventListener("animationend", f);
1978
- } };
1979
- A(we, t, d), A(we, e, d), t.addEventListener("animationend", f);
1980
- }
1981
- function Os(t) {
1982
- U(we, t);
1983
- }
1984
- const As = {
1985
- add: Is,
1986
- remove: Os
1987
- };
1988
- function Cs(t, e, n = !1, s, i, r) {
1989
- const o = r || K(
1990
- t,
1991
- q(e),
1992
- void 0,
1993
- n
1994
- );
1995
- if (!o)
1996
- return null;
1997
- let c = !0;
1998
- const a = e.triggerType || "alternate";
1999
- return (u) => {
2000
- if (s && !t.matches(s)) return;
2001
- const f = !i, l = i?.enter?.includes(u.type), d = i?.leave?.includes(u.type);
2002
- if (l || f) {
2003
- if (a === "alternate" || a === "state")
2004
- c ? (c = !1, o.play()) : a === "alternate" ? o.reverse() : a === "state" && (o.playState === "running" ? o.pause() : o.playState !== "finished" && o.play());
2005
- else {
2006
- if (o.progress(0), delete t.dataset.interactEnter, o.isCSS) {
2007
- const g = () => {
2008
- O.mutate(() => {
2009
- t.dataset.interactEnter = "done";
2010
- });
2011
- };
2012
- o.onFinish(g), o.onAbort(g);
2013
- }
2014
- o.play();
2015
- }
2016
- return;
2017
- }
2018
- d && (a === "alternate" ? o.reverse() : a === "repeat" ? (o.cancel(), O.mutate(() => {
2019
- delete t.dataset.interactEnter;
2020
- })) : a === "state" && o.playState === "running" && o.pause());
2021
- };
2022
- }
2023
- function _s(t, e, {
2024
- effectId: n,
2025
- listContainer: s,
2026
- listItemSelector: i,
2027
- stateAction: r
2028
- }, o, c) {
2029
- const a = !!s, u = r ?? "toggle", f = u === "toggle";
2030
- return (l) => {
2031
- if (o && !t.matches(o)) return;
2032
- const d = a ? t.closest(
2033
- `${s} > ${i || ""}:has(:scope)`
2034
- ) : void 0, g = !c, h = c?.enter?.includes(l.type), m = c?.leave?.includes(l.type);
2035
- g ? e.toggleEffect(n, u, d) : (h && e.toggleEffect(n, f ? "add" : u, d), m && f && e.toggleEffect(n, "remove", d));
2036
- };
2037
- }
2038
- const be = /* @__PURE__ */ new WeakMap();
2039
- function je(t, e) {
2040
- return (n) => {
2041
- const s = n;
2042
- t.contains(s.relatedTarget) || e(s);
2043
- };
2044
- }
2045
- function ks(t) {
2046
- return (e) => {
2047
- const n = e;
2048
- n.pointerType && t(n);
2049
- };
2050
- }
2051
- function $s(t) {
2052
- return (e) => {
2053
- const n = e;
2054
- n.code === "Space" ? (n.preventDefault(), t(n)) : n.code === "Enter" && t(n);
2055
- };
2056
- }
2057
- const Ps = {
2058
- focusin: (t, e) => je(t, e),
2059
- focusout: (t, e) => je(t, e),
2060
- click: (t, e) => ks(e),
2061
- keydown: (t, e) => $s(e)
2062
- };
2063
- function qs(t, e, n) {
2064
- const s = Ps[t];
2065
- return s ? s(e, n) : (i) => n(i);
2066
- }
2067
- function Ms(t) {
2068
- return typeof t == "object" && !Array.isArray(t) && ("enter" in t || "leave" in t);
2069
- }
2070
- function xs(t) {
2071
- if (typeof t == "string")
2072
- return { toggle: [t] };
2073
- if (Array.isArray(t))
2074
- return { toggle: [...t] };
2075
- if (Ms(t)) {
2076
- const e = t.enter ? [...t.enter] : [], n = t.leave ? [...t.leave] : [];
2077
- return { enter: e, leave: n };
2078
- }
2079
- return {};
2080
- }
2081
- function Ls(t) {
2082
- return !!(t.enter?.length || t.leave?.length);
2083
- }
2084
- function Fs(t) {
2085
- return Ls(t) ? { enter: t.enter ?? [], leave: t.leave ?? [] } : void 0;
2086
- }
2087
- function Rs(t, e, n, s, {
2088
- reducedMotion: i,
2089
- targetController: r,
2090
- selectorCondition: o,
2091
- animation: c
2092
- }) {
2093
- const a = xs(s.eventConfig), u = n.transition || n.transitionProperties, f = Fs(a);
2094
- let l, d = !1;
2095
- if (u ? l = _s(
2096
- e,
2097
- r,
2098
- n,
2099
- o,
2100
- f
2101
- ) : (l = Cs(
2102
- e,
2103
- n,
2104
- i,
2105
- o,
2106
- f,
2107
- c
2108
- ), d = n.triggerType === "once"), !l)
2109
- return;
2110
- const g = l, h = new AbortController();
2111
- function m(y, E, w) {
2112
- const S = qs(E, t, g);
2113
- y.addEventListener(E, S, { ...w, signal: h.signal });
2114
- }
2115
- const v = { source: t, target: e, cleanup: () => {
2116
- h.abort();
2117
- } };
2118
- if (A(be, t, v), A(be, e, v), f) {
2119
- const y = a.enter, E = a.leave;
2120
- y.forEach((T) => {
2121
- T === "focusin" && (t.tabIndex = 0), m(t, T, { passive: !0, once: d });
2122
- });
2123
- const w = !n.stateAction || n.stateAction === "toggle";
2124
- (u ? w : n.triggerType !== "once") && E.forEach((T) => {
2125
- if (T === "focusout") {
2126
- m(t, T, { once: d });
2127
- return;
2128
- }
2129
- m(t, T, { passive: !0 });
2130
- });
2131
- } else
2132
- (a.toggle ?? []).forEach((E) => {
2133
- m(t, E, { once: d, passive: E !== "keydown" });
2134
- });
2135
- }
2136
- function Ns(t) {
2137
- U(be, t);
2138
- }
2139
- const G = {
2140
- add: Rs,
2141
- remove: Ns
2142
- }, Se = {
2143
- click: ["click"],
2144
- activate: ["click", "keydown"],
2145
- hover: { enter: ["mouseenter"], leave: ["mouseleave"] },
2146
- interest: {
2147
- enter: ["mouseenter", "focusin"],
2148
- leave: ["mouseleave", "focusout"]
2149
- }
2150
- }, De = {
2151
- click: Se.activate,
2152
- hover: Se.interest
2153
- };
2154
- function ee(t) {
2155
- const e = Se[t];
2156
- return (n, s, i, r, o) => {
2157
- const c = o?.allowA11yTriggers && t in De ? De[t] : e;
2158
- G.add(n, s, i, { eventConfig: c }, o ?? {});
2159
- };
2160
- }
2161
- const R = {
2162
- viewEnter: zn,
2163
- hover: {
2164
- add: ee("hover"),
2165
- remove: G.remove
2166
- },
2167
- click: {
2168
- add: ee("click"),
2169
- remove: G.remove
2170
- },
2171
- animationEnd: As,
2172
- viewProgress: rs,
2173
- pointerMove: Ts,
2174
- activate: {
2175
- add: ee("activate"),
2176
- remove: G.remove
2177
- },
2178
- interest: {
2179
- add: ee("interest"),
2180
- remove: G.remove
2181
- }
2182
- };
2183
- function zs(t) {
2184
- return t.replace(/\[([-\w]+)]/g, "[]");
2185
- }
2186
- class b {
2187
- static defineInteractElement;
2188
- dataCache;
2189
- addedInteractions;
2190
- mediaQueryListeners;
2191
- listInteractionsCache;
2192
- controllers;
2193
- static forceReducedMotion = !1;
2194
- static allowA11yTriggers = !0;
2195
- static instances = [];
2196
- static controllerCache = /* @__PURE__ */ new Map();
2197
- static sequenceCache = /* @__PURE__ */ new Map();
2198
- static elementSequenceMap = /* @__PURE__ */ new WeakMap();
2199
- static plugins = /* @__PURE__ */ new Map();
2200
- constructor() {
2201
- this.dataCache = { effects: {}, sequences: {}, conditions: {}, interactions: {} }, this.addedInteractions = {}, this.mediaQueryListeners = /* @__PURE__ */ new Map(), this.listInteractionsCache = {}, this.controllers = /* @__PURE__ */ new Set();
2202
- }
2203
- init(e, n) {
2204
- if (typeof window > "u" || !window.customElements)
2205
- return;
2206
- const s = n?.useCustomElement ?? !!b.defineInteractElement;
2207
- this.dataCache = Ds(e, s);
2208
- const i = b.defineInteractElement?.();
2209
- s && i === !1 ? document.querySelectorAll("interact-element").forEach((r) => {
2210
- r.connect();
2211
- }) : b.controllerCache.forEach(
2212
- (r, o) => r.connect(o)
2213
- );
2214
- }
2215
- destroy() {
2216
- for (const e of this.controllers)
2217
- e.disconnect();
2218
- for (const [, e] of this.mediaQueryListeners.entries())
2219
- e.mql.removeEventListener("change", e.handler);
2220
- this.mediaQueryListeners.clear(), this.addedInteractions = {}, this.listInteractionsCache = {}, this.controllers.clear(), this.dataCache = { effects: {}, sequences: {}, conditions: {}, interactions: {} }, b.instances.splice(b.instances.indexOf(this), 1);
2221
- }
2222
- setController(e, n) {
2223
- this.controllers.add(n), b.setController(e, n);
2224
- }
2225
- deleteController(e, n = !1) {
2226
- const s = b.controllerCache.get(e);
2227
- this.clearInteractionStateForKey(e), this.clearMediaQueryListenersForKey(e), s && n && (this.controllers.delete(s), b.deleteController(e));
2228
- }
2229
- has(e) {
2230
- return !!this.get(e);
2231
- }
2232
- get(e) {
2233
- const n = zs(e);
2234
- return this.dataCache.interactions[n];
2235
- }
2236
- clearMediaQueryListenersForKey(e) {
2237
- for (const [n, s] of this.mediaQueryListeners.entries())
2238
- s.key === e && (s.mql.removeEventListener("change", s.handler), this.mediaQueryListeners.delete(n));
2239
- }
2240
- clearInteractionStateForKey(e) {
2241
- (this.get(e)?.interactionIds || []).forEach((i) => {
2242
- const r = k(i, e);
2243
- delete this.addedInteractions[r];
2244
- });
2245
- const s = `${e}::seq::`;
2246
- for (const i of b.sequenceCache.keys())
2247
- i.startsWith(s) && (b.sequenceCache.delete(i), delete this.addedInteractions[i]);
2248
- }
2249
- setupMediaQueryListener(e, n, s, i) {
2250
- this.mediaQueryListeners.has(e) || (n.addEventListener("change", i), this.mediaQueryListeners.set(e, {
2251
- mql: n,
2252
- handler: i,
2253
- key: s
2254
- }));
2255
- }
2256
- static create(e, n) {
2257
- const s = new b();
2258
- return b.instances.push(s), s.init(e, n), s;
2259
- }
2260
- static destroy() {
2261
- b.controllerCache.forEach((e) => {
2262
- e.disconnect();
2263
- }), b.instances.length = 0, b.controllerCache.clear(), b.sequenceCache.clear(), b.elementSequenceMap = /* @__PURE__ */ new WeakMap();
2264
- }
2265
- static setup(e) {
2266
- e.scrollOptionsGetter && R.viewProgress.registerOptionsGetter?.(
2267
- e.scrollOptionsGetter
2268
- ), e.pointerOptionsGetter && R.pointerMove.registerOptionsGetter?.(
2269
- e.pointerOptionsGetter
2270
- ), e.viewEnter && R.viewEnter.setOptions(
2271
- e.viewEnter
2272
- ), e.allowA11yTriggers !== void 0 && (b.allowA11yTriggers = e.allowA11yTriggers);
2273
- }
2274
- static getInstance(e) {
2275
- const n = b.instances.find((s) => s.has(e));
2276
- return n || console.warn(`Interact: Instance for key "${e}" not found`), n;
2277
- }
2278
- static getController(e) {
2279
- const n = e ? b.controllerCache.get(e) : void 0;
2280
- return n || console.warn(`Interact: Controller for key "${e}" not found`), n;
2281
- }
2282
- static setController(e, n) {
2283
- b.controllerCache.set(e, n);
2284
- }
2285
- static deleteController(e) {
2286
- b.controllerCache.delete(e);
2287
- }
2288
- static registerEffects = dn;
2289
- /**
2290
- * Registers a plugin under a name. When the config carries a plugin field (e.g. `$splitText`) with a matching key
2291
- * (on an interaction or effect), Interact invokes the plugin with the field's value and a
2292
- * context. Interact is agnostic to what the plugin does — see the `InteractPlugin` type.
2293
- */
2294
- static use(e, n) {
2295
- b.plugins.set(e, n);
2296
- }
2297
- static getPlugin(e) {
2298
- return b.plugins.get(e);
2299
- }
2300
- static getPluginsNames() {
2301
- return new Set(b.plugins.keys());
2302
- }
2303
- static getSequence(e, n, s, i) {
2304
- const r = b.sequenceCache.get(e);
2305
- if (r) return r;
2306
- const o = Tn(n, s, i);
2307
- return b.sequenceCache.set(e, o), b._registerSequenceElements(s, o), o;
2308
- }
2309
- static addToSequence(e, n, s, i) {
2310
- const r = b.sequenceCache.get(e);
2311
- if (!r) return !1;
2312
- const c = et(n, i).map((a, u) => ({
2313
- index: s[u] ?? r.animationGroups.length,
2314
- group: a
2315
- }));
2316
- return r.addGroups(c), b._registerSequenceElements(n, r), !0;
2317
- }
2318
- static _registerSequenceElements(e, n) {
2319
- for (const { target: s } of e) {
2320
- const i = Array.isArray(s) ? s : s instanceof HTMLElement ? [s] : [];
2321
- for (const r of i) {
2322
- let o = b.elementSequenceMap.get(r);
2323
- o || (o = /* @__PURE__ */ new Set(), b.elementSequenceMap.set(r, o)), o.add(n);
2324
- }
2325
- }
2326
- }
2327
- static removeFromSequences(e) {
2328
- for (const n of e) {
2329
- const s = b.elementSequenceMap.get(n);
2330
- if (s) {
2331
- for (const i of s)
2332
- i.removeGroups(
2333
- (r) => r.animations.some((o) => o.effect?.target === n)
2334
- );
2335
- b.elementSequenceMap.delete(n);
2336
- }
2337
- }
2338
- }
2339
- }
2340
- let js = 0;
2341
- function x(t, {
2342
- asCombinator: e = !1,
2343
- addItemFilter: n = !1,
2344
- useFirstChild: s = !1
2345
- } = {}) {
2346
- if (t.listContainer) {
2347
- const i = `${n && t.listItemSelector ? ` > ${t.listItemSelector}` : ""}`;
2348
- return t.selector ? `${t.listContainer}${i} ${t.selector}` : `${t.listContainer}${i || " > *"}`;
2349
- } else if (t.selector)
2350
- return t.selector;
2351
- return s ? e ? "> :first-child" : ":scope > :first-child" : "";
2352
- }
2353
- function Ge(t) {
2354
- return "sequenceId" in t && !("effects" in t);
2355
- }
2356
- function pe(t, e) {
2357
- return t[e] || (t[e] = {
2358
- triggers: [],
2359
- effects: {},
2360
- sequences: {},
2361
- interactionIds: /* @__PURE__ */ new Set(),
2362
- selectors: /* @__PURE__ */ new Set()
2363
- }), t[e];
2364
- }
2365
- function Ds(t, e = !1) {
2366
- const { effects: n = {}, sequences: s = {}, conditions: i = {} } = t, r = {};
2367
- return t.interactions?.forEach((o) => {
2368
- const c = o.key, a = ++js, { effects: u, sequences: f, ...l } = o;
2369
- if (!c) {
2370
- console.error(`Interaction ${a} is missing a key for source element.`);
2371
- return;
2372
- }
2373
- pe(r, c);
2374
- const d = u ? Array.from(u) : [];
2375
- d.reverse();
2376
- const g = f?.map((p) => {
2377
- if (Ge(p)) {
2378
- const y = s[p.sequenceId];
2379
- return y ? { ...y, ...p } : (console.warn(`Interact: Sequence "${p.sequenceId}" not found in config`), p);
2380
- }
2381
- const v = p;
2382
- return v.sequenceId || (v.sequenceId = _()), v;
2383
- }), h = {
2384
- ...l,
2385
- effects: d.length > 0 ? d : void 0,
2386
- sequences: g
2387
- };
2388
- r[c].triggers.push(h), r[c].selectors.add(
2389
- x(h, { useFirstChild: e })
2390
- );
2391
- const m = h.listContainer;
2392
- d.forEach((p) => {
2393
- let v = p.key;
2394
- if (!v && p.effectId) {
2395
- const S = n[p.effectId];
2396
- S && (v = S.key);
2397
- }
2398
- p.effectId || (p.effectId = _()), v = v || c, p.key = v;
2399
- const y = p.effectId;
2400
- if (m && p.listContainer && (v !== c || p.listContainer !== m))
2401
- return;
2402
- const E = `${c}::${v}::${y}::${a}`;
2403
- if (p.interactionId = E, r[c].interactionIds.add(E), v === c)
2404
- return;
2405
- const w = pe(r, v);
2406
- w.effects[E] || (w.effects[E] = [], w.interactionIds.add(E)), w.effects[E].push({ ...l, effect: p }), w.selectors.add(x(p, { useFirstChild: e }));
2407
- }), g?.forEach((p) => {
2408
- if (!p || Ge(p)) return;
2409
- const v = p, y = v.sequenceId || _(), E = v.effects;
2410
- for (const w of E) {
2411
- w.effectId || (w.effectId = _());
2412
- let S = w.key;
2413
- if (!S && w.effectId) {
2414
- const I = n[w.effectId];
2415
- I && (S = I.key);
2416
- }
2417
- S = S || c;
2418
- const T = x(w, { useFirstChild: e });
2419
- if (T && r[c].selectors.add(T), S !== c) {
2420
- const I = pe(r, S), C = `${S}::seq::${y}::${a}`;
2421
- I.sequences[C] || (I.sequences[C] = [], I.interactionIds.add(C)), I.sequences[C].push({
2422
- ...l,
2423
- sequence: v
2424
- }), I.selectors.add(T);
2425
- }
2426
- }
2427
- });
2428
- }), {
2429
- effects: n,
2430
- sequences: s,
2431
- conditions: i,
2432
- interactions: r
2433
- };
2434
- }
2435
- const ft = "$";
2436
- function de(t, e, n, s, i) {
2437
- const r = b.getPluginsNames();
2438
- for (const o of r) {
2439
- const c = `${ft}${o}`;
2440
- if (!(c in n))
2441
- continue;
2442
- const a = n[c];
2443
- if (a !== null && typeof a == "object") {
2444
- if (t._appliedPlugins.has(a))
2445
- continue;
2446
- t._appliedPlugins.add(a);
2447
- }
2448
- const f = b.getPlugin(o)(a, { root: e, key: s, scope: i, config: n });
2449
- typeof f == "function" && t._pluginCleanups.push(f);
2450
- }
2451
- }
2452
- function ue(t, e, n) {
2453
- if (t.listContainer) {
2454
- const s = e.querySelector(t.listContainer);
2455
- return s ? t.selector ? Array.from(s.querySelectorAll(t.selector)) : Array.from(s.children) : (console.warn(`Interact: No container found for list container "${t.listContainer}"`), []);
2456
- }
2457
- if (t.selector) {
2458
- const s = e.querySelectorAll(t.selector);
2459
- if (s.length > 0)
2460
- return Array.from(s);
2461
- console.warn(`Interact: No elements found for selector "${t.selector}"`);
2462
- }
2463
- return n ? e.firstElementChild : e;
2464
- }
2465
- function le(t, e) {
2466
- return e.map((n) => t.selector ? n.querySelector(t.selector) : n).filter(Boolean);
2467
- }
2468
- function ut(t, e, n, s, i, r, o, c) {
2469
- return [
2470
- o ? le(t, o) : ue(t, n, s),
2471
- c ? le(e, c) : ue(e, i, r)
2472
- ];
2473
- }
2474
- function lt(t, e, n, s, i, r, o, c) {
2475
- const a = Array.isArray(s), u = Array.isArray(i);
2476
- a ? s.forEach((f, l) => {
2477
- const d = u ? i[l] : i;
2478
- d && He(
2479
- t,
2480
- f,
2481
- e.trigger,
2482
- d,
2483
- n,
2484
- e.params,
2485
- r,
2486
- o,
2487
- c
2488
- );
2489
- }) : (u ? i : [i]).forEach((l) => {
2490
- He(
2491
- t,
2492
- s,
2493
- e.trigger,
2494
- l,
2495
- n,
2496
- e.params,
2497
- r,
2498
- o,
2499
- c
2500
- );
2501
- });
2502
- }
2503
- function dt(t, e, n, s, i) {
2504
- const r = {}, o = [];
2505
- (s.effects || []).forEach((c) => {
2506
- const a = c.effectId, u = {
2507
- ...n.dataCache.effects[a] || {},
2508
- ...c,
2509
- effectId: a
2510
- }, f = u.key, l = k(c.interactionId, t);
2511
- if (r[l] || n.addedInteractions[l] && !i)
2512
- return;
2513
- const d = $(u.conditions || [], n.dataCache.conditions);
2514
- if (d && n.setupMediaQueryListener(l, d, t, () => {
2515
- e.update();
2516
- }), !d || d.matches) {
2517
- r[l] = !0;
2518
- const g = f && k(f, t);
2519
- let h;
2520
- if (g) {
2521
- if (h = b.getController(g), !h)
2522
- return;
2523
- u.listContainer && h.watchChildList(u.listContainer);
2524
- } else
2525
- h = e;
2526
- de(
2527
- h,
2528
- h.element,
2529
- u,
2530
- g || s.key,
2531
- "effect"
2532
- );
2533
- const [m, p] = ut(
2534
- s,
2535
- u,
2536
- e.element,
2537
- e.useFirstChild,
2538
- h.element,
2539
- h.useFirstChild,
2540
- i
2541
- );
2542
- if (!m || !p)
2543
- return;
2544
- n.addedInteractions[l] = !0;
2545
- const v = g || s.key, y = P(
2546
- u.conditions || [],
2547
- n.dataCache.conditions
2548
- );
2549
- o.push([
2550
- v,
2551
- s,
2552
- u,
2553
- m,
2554
- p,
2555
- y,
2556
- h.useFirstChild,
2557
- t
2558
- ]);
2559
- }
2560
- }), o.reverse().forEach((c) => {
2561
- lt(...c);
2562
- }), Hs(t, e, n, s, i);
2563
- }
2564
- function Gs(t) {
2565
- return "sequenceId" in t && !("effects" in t);
2566
- }
2567
- function ht(t, e, n, s, i, r, o) {
2568
- const c = $(t.conditions || [], i.dataCache.conditions);
2569
- if (c && i.setupMediaQueryListener(e, c, r.updateKey, r.onUpdate), c && !c.matches) return null;
2570
- const a = t.effects || [], u = [];
2571
- let f = !1;
2572
- for (const l of a) {
2573
- const d = l.effectId, h = {
2574
- ...d ? i.dataCache.effects[d] || {} : {},
2575
- ...l
2576
- }, m = $(h.conditions || [], i.dataCache.conditions);
2577
- if (m) {
2578
- const T = `${e}::${d || "eff"}`;
2579
- i.setupMediaQueryListener(
2580
- T,
2581
- m,
2582
- r.updateKey,
2583
- r.onUpdate
2584
- );
2585
- }
2586
- if (m && !m.matches) continue;
2587
- const p = h.key, v = p && k(p, n);
2588
- let y;
2589
- if (v) {
2590
- if (y = b.getController(v), !y) return null;
2591
- } else
2592
- y = s;
2593
- const E = v || n;
2594
- de(
2595
- y,
2596
- y.element,
2597
- h,
2598
- E,
2599
- "effect"
2600
- );
2601
- let w;
2602
- if (o && E === o.controllerKey && h.listContainer === o.listContainer ? (w = le(h, o.elements), w.length > 0 && (f = !0)) : w = ue(
2603
- h,
2604
- y.element,
2605
- y.useFirstChild
2606
- ), !w || Array.isArray(w) && w.length === 0) return null;
2607
- const S = q(h);
2608
- u.push({ target: w, options: S });
2609
- }
2610
- return o && !f ? null : u.length > 0 ? u : null;
2611
- }
2612
- function Te(t, e, n) {
2613
- const s = n ? le(t, n) : ue(t, e.element, e.useFirstChild);
2614
- return Array.isArray(s) && s.length === 0 ? null : s;
2615
- }
2616
- function Ie(t, e, n, s, i) {
2617
- (Array.isArray(n) ? n : [n]).forEach((o) => {
2618
- R[t.trigger]?.add(
2619
- o,
2620
- o,
2621
- { triggerType: e.triggerType },
2622
- t.params || {},
2623
- {
2624
- reducedMotion: b.forceReducedMotion,
2625
- selectorCondition: i,
2626
- animation: s,
2627
- allowA11yTriggers: b.allowA11yTriggers
2628
- }
2629
- );
2630
- });
2631
- }
2632
- function mt(t, e, n) {
2633
- const r = (t.useFirstChild ? t.element.firstElementChild : t.element)?.querySelector(e);
2634
- if (!r) return n.map((c, a) => a);
2635
- const o = Array.from(r.children);
2636
- return n.map((c) => {
2637
- const a = o.indexOf(c);
2638
- return a >= 0 ? a : o.length;
2639
- });
2640
- }
2641
- function Hs(t, e, n, s, i) {
2642
- s.sequences?.forEach((r) => {
2643
- let o;
2644
- if (Gs(r)) {
2645
- const h = n.dataCache.sequences[r.sequenceId];
2646
- if (!h) {
2647
- console.warn(`Interact: Sequence "${r.sequenceId}" not found in cache`);
2648
- return;
2649
- }
2650
- o = { ...h, ...r };
2651
- } else
2652
- o = r;
2653
- const c = o.sequenceId || _(), a = k(`${t}::seq::${c}`, t);
2654
- if (n.addedInteractions[a] && !i) return;
2655
- const u = i && s.listContainer ? { controllerKey: t, listContainer: s.listContainer, elements: i } : void 0, f = ht(
2656
- o,
2657
- a,
2658
- t,
2659
- e,
2660
- n,
2661
- { updateKey: t, onUpdate: () => e.update() },
2662
- u
2663
- );
2664
- if (!f) return;
2665
- if (i && n.addedInteractions[a]) {
2666
- const h = mt(
2667
- e,
2668
- s.listContainer,
2669
- i
2670
- );
2671
- b.addToSequence(a, f, h, {
2672
- reducedMotion: b.forceReducedMotion
2673
- });
2674
- const m = b.getSequence(a, o, f, {
2675
- reducedMotion: b.forceReducedMotion
2676
- }), p = P(
2677
- s.conditions || [],
2678
- n.dataCache.conditions
2679
- ), v = Te(s, e, i);
2680
- v && Ie(
2681
- s,
2682
- o,
2683
- v,
2684
- m,
2685
- p
2686
- );
2687
- return;
2688
- }
2689
- const l = b.getSequence(a, o, f, {
2690
- reducedMotion: b.forceReducedMotion
2691
- }), d = P(
2692
- s.conditions || [],
2693
- n.dataCache.conditions
2694
- ), g = Te(s, e, i);
2695
- g && (n.addedInteractions[a] = !0, Ie(
2696
- s,
2697
- o,
2698
- g,
2699
- l,
2700
- d
2701
- ));
2702
- });
2703
- }
2704
- function Ws(t, e, n, s, i) {
2705
- const r = n.get(t)?.sequences || {};
2706
- Object.keys(r).forEach((c) => {
2707
- r[c].some(({ sequence: u, ...f }) => {
2708
- const l = $(
2709
- f.conditions || [],
2710
- n.dataCache.conditions
2711
- );
2712
- if (l && !l.matches)
2713
- return !1;
2714
- const d = f.key && k(f.key, t), g = b.getController(d);
2715
- if (!g)
2716
- return !0;
2717
- const h = u.sequenceId || _(), m = k(`${d}::seq::${h}`, d);
2718
- if (n.addedInteractions[m] && !i)
2719
- return !0;
2720
- const v = ht(
2721
- u,
2722
- m,
2723
- d,
2724
- g,
2725
- n,
2726
- { updateKey: t, onUpdate: () => e.update() },
2727
- i && s ? { controllerKey: t, listContainer: s, elements: i } : void 0
2728
- );
2729
- if (!v) return !0;
2730
- if (i && n.addedInteractions[m]) {
2731
- const S = mt(e, s, i);
2732
- return b.addToSequence(m, v, S, {
2733
- reducedMotion: b.forceReducedMotion
2734
- }), !0;
2735
- }
2736
- const y = b.getSequence(m, u, v, {
2737
- reducedMotion: b.forceReducedMotion
2738
- }), E = P(
2739
- f.conditions || [],
2740
- n.dataCache.conditions
2741
- ), w = Te(f, g);
2742
- return w && (n.addedInteractions[m] = !0, Ie(
2743
- f,
2744
- u,
2745
- w,
2746
- y,
2747
- E
2748
- )), !0;
2749
- });
2750
- });
2751
- }
2752
- function pt(t, e, n, s, i) {
2753
- const r = n.get(t), o = r?.effects || {}, c = Object.keys(o), a = [];
2754
- c.forEach((f) => {
2755
- const l = k(f, t);
2756
- if (n.addedInteractions[l] && !i)
2757
- return;
2758
- o[f].some(({ effect: g, ...h }) => {
2759
- const m = $(
2760
- h.conditions || [],
2761
- n.dataCache.conditions
2762
- );
2763
- if (m && !m.matches)
2764
- return !1;
2765
- const p = g.effectId, v = {
2766
- ...n.dataCache.effects[p] || {},
2767
- ...g,
2768
- effectId: p
2769
- };
2770
- if (s && v.listContainer !== s)
2771
- return !1;
2772
- const y = $(v.conditions || [], n.dataCache.conditions);
2773
- if (y && n.setupMediaQueryListener(l, y, t, () => {
2774
- e.update();
2775
- }), !y || y.matches) {
2776
- const E = h.key && k(h.key, t), w = b.getController(E);
2777
- if (!w)
2778
- return !0;
2779
- de(
2780
- e,
2781
- e.element,
2782
- v,
2783
- t,
2784
- "effect"
2785
- ), v.listContainer && e.watchChildList(v.listContainer);
2786
- const [S, T] = ut(
2787
- h,
2788
- v,
2789
- w.element,
2790
- w.useFirstChild,
2791
- e.element,
2792
- e.useFirstChild,
2793
- void 0,
2794
- i
2795
- );
2796
- if (!S || !T)
2797
- return !0;
2798
- n.addedInteractions[l] = !0;
2799
- const I = P(
2800
- v.conditions || [],
2801
- n.dataCache.conditions
2802
- );
2803
- return a.push([
2804
- t,
2805
- h,
2806
- v,
2807
- S,
2808
- T,
2809
- I,
2810
- e.useFirstChild,
2811
- E || void 0
2812
- ]), !0;
2813
- }
2814
- return !1;
2815
- });
2816
- }), a.reverse().forEach((f) => {
2817
- lt(...f);
2818
- }), Ws(t, e, n, s, i);
2819
- const u = Object.keys(r?.sequences || {}).length > 0;
2820
- return c.length > 0 || u;
2821
- }
2822
- function He(t, e, n, s, i, r, o, c, a) {
2823
- let u;
2824
- if (i.transition || i.transitionProperties) {
2825
- const l = {
2826
- key: t,
2827
- effectId: i.effectId,
2828
- transition: i.transition,
2829
- transitionProperties: i.transitionProperties,
2830
- childSelector: x(i, {
2831
- asCombinator: !0,
2832
- addItemFilter: !0,
2833
- useFirstChild: c
2834
- }),
2835
- selectorCondition: o
2836
- };
2837
- if (u = b.getController(t), !u)
2838
- return;
2839
- u.renderStyle(kn(l));
2840
- }
2841
- let f;
2842
- if (n === "animationEnd") {
2843
- const l = r.effectId, g = (a ? b.getInstance(a) : void 0)?.dataCache.effects[l];
2844
- g && (f = q(g));
2845
- }
2846
- R[n]?.add(e, s, i, r, {
2847
- reducedMotion: b.forceReducedMotion,
2848
- targetController: u,
2849
- selectorCondition: o,
2850
- allowA11yTriggers: b.allowA11yTriggers,
2851
- sourceAnimationOptions: f
2852
- });
2853
- }
2854
- function Vs(t) {
2855
- const e = t.key, n = b.getInstance(e);
2856
- if (!n)
2857
- return console.warn(`No instance found for key: ${e}`), b.setController(e, t), !1;
2858
- const { triggers: s = [] } = n?.get(e) || {}, i = s.length > 0;
2859
- n.setController(e, t), s.forEach((o, c) => {
2860
- const a = $(o.conditions, n.dataCache.conditions);
2861
- if (a) {
2862
- const u = `${e}::trigger::${c}`;
2863
- n.setupMediaQueryListener(u, a, e, () => {
2864
- t.update();
2865
- });
2866
- }
2867
- (!a || a.matches) && (de(t, t.element, o, e, "interaction"), o.listContainer && t.watchChildList(o.listContainer), dt(e, t, n, o));
2868
- });
2869
- let r = !1;
2870
- return n && (r = pt(e, t, n)), i || r;
2871
- }
2872
- function Ys(t, e, n) {
2873
- const s = t.key, i = b.getInstance(s);
2874
- if (i) {
2875
- const { triggers: r = [] } = i?.get(s) || {};
2876
- r.forEach((o, c) => {
2877
- if (o.listContainer !== e)
2878
- return;
2879
- const a = $(o.conditions, i.dataCache.conditions);
2880
- if (a) {
2881
- const u = `${s}::listTrigger::${e}::${c}`;
2882
- i.setupMediaQueryListener(u, a, s, () => {
2883
- t.update();
2884
- });
2885
- }
2886
- (!a || a.matches) && dt(s, t, i, o, n);
2887
- }), pt(s, t, i, e, n);
2888
- }
2889
- }
2890
- function Ks(t, e = !1) {
2891
- const n = t.key, s = b.getInstance(n);
2892
- if (!s)
2893
- return;
2894
- const i = [...s.get(n)?.selectors.values() || []].filter(Boolean).join(",");
2895
- let r;
2896
- i ? (r = [...t.element.querySelectorAll(i)], t.useFirstChild || r.push(t.element)) : r = [t.element], gt(r), s.deleteController(n, e);
2897
- }
2898
- function gt(t) {
2899
- const e = Object.values(R);
2900
- for (const n of t)
2901
- for (const s of e)
2902
- s.remove(n);
2903
- b.removeFromSequences(t);
2904
- }
2905
- const ge = "interactEffect";
2906
- class Bs {
2907
- element;
2908
- key;
2909
- connected;
2910
- sheet;
2911
- useFirstChild;
2912
- _observers;
2913
- _pluginCleanups;
2914
- _appliedPlugins;
2915
- constructor(e, n, s) {
2916
- this.element = e, this.key = n, this.connected = !1, this.sheet = null, this._observers = /* @__PURE__ */ new WeakMap(), this._pluginCleanups = [], this._appliedPlugins = /* @__PURE__ */ new WeakSet(), this.useFirstChild = s?.useFirstChild ?? !1;
2917
- }
2918
- connect(e) {
2919
- if (this.connected)
2920
- return;
2921
- const n = this.element.dataset.interactKey;
2922
- if (e = e || this.key || n, !e) {
2923
- console.warn("Interact: No key provided");
2924
- return;
2925
- }
2926
- n !== e && (n && console.warn(
2927
- `Interact: Key mismatch between element ${n} and parameter ${e}, updating element key`
2928
- ), this.element.dataset.interactKey = e), this.key = e, this.connected = Vs(this);
2929
- }
2930
- disconnect({ removeFromCache: e = !1 } = {}) {
2931
- if ((this.key || this.element.dataset.interactKey) && Ks(this, e), this._pluginCleanups.length) {
2932
- for (const s of this._pluginCleanups)
2933
- try {
2934
- s();
2935
- } catch (i) {
2936
- console.error(i);
2937
- }
2938
- this._pluginCleanups.length = 0;
2939
- }
2940
- if (this._appliedPlugins = /* @__PURE__ */ new WeakSet(), this.sheet) {
2941
- const s = this.element?.getRootNode(), i = s.host ? s : document;
2942
- i.adoptedStyleSheets.indexOf(this.sheet) !== -1 && (i.adoptedStyleSheets = i.adoptedStyleSheets.filter(
2943
- (o) => o !== this.sheet
2944
- ));
2945
- }
2946
- this._observers = /* @__PURE__ */ new WeakMap(), this.sheet = null, this.connected = !1;
2947
- }
2948
- update() {
2949
- this.disconnect(), this.connect();
2950
- }
2951
- renderStyle(e) {
2952
- const n = this.element?.getRootNode(), s = n.host ? n : document;
2953
- if (!this.sheet)
2954
- this.sheet = new CSSStyleSheet(), this.sheet.replaceSync(e.join(`
2955
- `)), s.adoptedStyleSheets = [...s.adoptedStyleSheets || [], this.sheet];
2956
- else {
2957
- let i = this.sheet.cssRules.length;
2958
- for (const r of e)
2959
- try {
2960
- this.sheet.insertRule(r, i), i++;
2961
- } catch (o) {
2962
- console.error(o);
2963
- }
2964
- }
2965
- }
2966
- toggleEffect(e, n, s, i) {
2967
- if (s === null)
2968
- return;
2969
- if (!i && this.element.toggleEffect) {
2970
- this.element.toggleEffect(e, n, s);
2971
- return;
2972
- }
2973
- const r = new Set(
2974
- this.element.dataset[ge]?.split(" ") || []
2975
- );
2976
- n === "toggle" ? r.has(e) ? r.delete(e) : r.add(e) : n === "add" ? r.add(e) : n === "remove" ? r.delete(e) : n === "clear" && r.clear(), (s || this.element).dataset[ge] = Array.from(r).join(" ");
2977
- }
2978
- getActiveEffects() {
2979
- const n = (this.element.dataset[ge] || "").trim();
2980
- return n ? n.split(/\s+/) : [];
2981
- }
2982
- watchChildList(e) {
2983
- const n = this.element.querySelector(e);
2984
- if (n) {
2985
- let s = this._observers.get(n);
2986
- s || (s = new MutationObserver(this._childListChangeHandler.bind(this, e)), this._observers.set(n, s), s.observe(n, { childList: !0 }));
2987
- }
2988
- }
2989
- _childListChangeHandler(e, n) {
2990
- const s = this.key || this.element.dataset.interactKey, i = [], r = [];
2991
- n.forEach((o) => {
2992
- o.removedNodes.forEach((c) => {
2993
- c instanceof HTMLElement && i.push(c);
2994
- }), o.addedNodes.forEach((c) => {
2995
- c instanceof HTMLElement && r.push(c);
2996
- });
2997
- }), gt(i), s && Ys(this, e, r);
2998
- }
2999
- }
3000
- function li(t, e) {
3001
- new Bs(t, e).connect();
3002
- }
3003
- function di(t) {
3004
- const e = b.getController(t);
3005
- e && e.disconnect({ removeFromCache: !0 });
3006
- }
3007
- const vt = /* @__PURE__ */ new Map([
3008
- ["viewEnter", "once"],
3009
- ["animationEnd", "once"],
3010
- ["hover", "alternate"],
3011
- ["click", "alternate"],
3012
- ["activate", "alternate"],
3013
- ["interest", "alternate"]
3014
- ]);
3015
- function yt(t, e, n) {
3016
- const { effects: s = {}, conditions: i = {} } = n, { key: r, trigger: o } = e, c = o === "pointerMove";
3017
- t.effectId || (t.effectId = _());
3018
- const { effectId: a } = t, u = { ...s[a] || {}, ...t };
3019
- let { key: f, conditions: l, triggerType: d } = u;
3020
- if (!f) {
3021
- if (!r)
3022
- return null;
3023
- f = r;
3024
- }
3025
- if (On(f))
3026
- return null;
3027
- l = [
3028
- ...new Set((l || []).filter((w) => i[w]))
3029
- ], d || (d = vt.get(o));
3030
- const { namedEffect: g, customEffect: h, keyframeEffect: m, transition: p, transitionProperties: v, ...y } = {
3031
- ...u,
3032
- key: f,
3033
- conditions: l,
3034
- effectId: a,
3035
- triggerType: d
3036
- }, E = At(e, y);
3037
- if (g)
3038
- return c || !g.type ? null : { namedEffect: g, initial: E, ...y };
3039
- if (m) {
3040
- if (!m.name) {
3041
- const w = a && !(s[a] && "keyframeEffect" in t);
3042
- m.name = w ? a : _();
3043
- }
3044
- return { keyframeEffect: m, initial: E, ...y };
3045
- } else return h ? c ? null : { initial: E, ...y } : p ? { transition: p, initial: E, ...y } : v ? { transitionProperties: v, initial: E, ...y } : { initial: E, ...y };
3046
- }
3047
- function Us(t, e, n) {
3048
- const { sequences: s = {}, conditions: i = {} } = n;
3049
- t.sequenceId || (t.sequenceId = _());
3050
- const { sequenceId: r } = t, o = { ...s[r] || {}, ...t };
3051
- let {
3052
- effects: c,
3053
- conditions: a,
3054
- triggerType: u,
3055
- delay: f = 0,
3056
- offset: l = 0,
3057
- offsetEasing: d = "linear"
3058
- } = o;
3059
- u || (u = vt.get(e.trigger)), a = [
3060
- ...new Set((a || []).filter((m) => i[m]))
3061
- ];
3062
- const g = c.map((m) => (m.conditions ? m.conditions.push(...a) : m.conditions = [...a], yt({ ...m, triggerType: u }, e, n)));
3063
- typeof d != "function" && (d = Ae(d) || ((m) => m)), _n(g, f, l, d);
3064
- const h = g.filter((m) => m !== null);
3065
- return h.length ? {
3066
- sequenceId: r,
3067
- triggerType: u,
3068
- conditions: a,
3069
- delay: f,
3070
- offset: l,
3071
- offsetEasing: d,
3072
- effects: h
3073
- } : null;
3074
- }
3075
- function Qs(t) {
3076
- return t === "cssFloat" ? "float" : t === "easing" ? "animation-timing-function" : t === "cssOffset" ? "offset" : t === "composite" ? "animation-composition" : ce(t);
3077
- }
3078
- function Xs(t) {
3079
- if (!t.length)
3080
- return [];
3081
- const e = t.map((i) => ({ ...i }));
3082
- e[0].offset === void 0 && (e[0].offset = 0), e.length === 1 ? t[0].offset === void 0 && (e[0].offset = 1) : e[e.length - 1].offset === void 0 && (e[e.length - 1].offset = 1);
3083
- let n = 0, s = e[0].offset;
3084
- for (let i = 1; i < e.length; i++)
3085
- if (e[i].offset !== void 0) {
3086
- const r = e[i].offset;
3087
- if (r < s)
3088
- return console.error("Offsets must be monotonically non-decreasing"), [];
3089
- if (r > 1)
3090
- return console.error("Offsets must be in the range [0,1]"), [];
3091
- const o = i - n;
3092
- for (let c = n + 1; c < i; c++) {
3093
- const a = (c - n) / o;
3094
- e[c].offset = s + (r - s) * a;
3095
- }
3096
- n = i, s = r;
3097
- }
3098
- return e;
3099
- }
3100
- function Zs(t, e) {
3101
- const n = Object.entries(t).filter(([s, i]) => s !== "offset" && i !== void 0 && i !== null).map(([s, i]) => `${Qs(s)}: ${i};`).join(`
3102
- `);
3103
- return `${e}% {
3104
- ${n}
3105
- }`;
3106
- }
3107
- function Js(t, e) {
3108
- const n = Xs(e);
3109
- if (!n.length)
3110
- return "";
3111
- let s = n.map((i) => {
3112
- const r = i.offset, o = In(r * 100);
3113
- return Zs(i, o);
3114
- }).join(`
3115
- `);
3116
- return `@keyframes ${t} {
3117
- ${s}
3118
- }`;
3119
- }
3120
- function ei(t) {
3121
- const { key: e, childSelector: n, declarations: s, media: i, states: r, selectorCondition: o, selectorSuffix: c } = t;
3122
- if (!s.length)
3123
- return "";
3124
- let a = `[data-interact-key="${e}"]`;
3125
- if (r && r.length) {
3126
- const l = r.map((d) => `:state(${d}), :--${d}, [data-interact-effect~="${d}"]`).join(", ");
3127
- a = `${a}:is(${l})`;
3128
- }
3129
- n && (a = `${a} ${n}`), c && (a = `${a}${c}`), o && (a = se(a, o));
3130
- const u = s.map(({ name: l, value: d, important: g }) => `${l}: ${d}${g ? " !important" : ""};`).join(`
3131
- `), f = `${a} {
3132
- ${u}
3133
- }`;
3134
- return i ? `@media ${i} {
3135
- ${f}
3136
- }` : f;
3137
- }
3138
- function Et(t, e, n, s) {
3139
- const { key: i, childSelector: r, properties: o } = t, c = Object.entries(o).filter(
3140
- (u) => u[1] && u[1].varNames.length
3141
- ).map(([u, { fallback: f, varNames: l }]) => ({
3142
- name: u,
3143
- value: l.map((d) => `var(${d}, ${f})`).join(", ")
3144
- })), a = { key: i, childSelector: r, declarations: c };
3145
- return e && a.declarations.forEach((u) => {
3146
- u.name = e[u.name];
3147
- }), n && (a.media = B(n, s || {}, "media"), a.selectorCondition = P(n, s || {})), a;
3148
- }
3149
- const ti = [
3150
- { name: "visibility", value: "hidden" },
3151
- { name: "transform", value: "none", important: !0 },
3152
- { name: "translate", value: "none", important: !0 },
3153
- { name: "scale", value: "none", important: !0 },
3154
- { name: "rotate", value: "none", important: !0 }
3155
- ], re = [
3156
- "animation",
3157
- "animation-composition",
3158
- "animation-timeline",
3159
- "animation-range"
3160
- ], Oe = ["transition", ...re], ni = {
3161
- animation: "animation",
3162
- "animation-composition": "composition",
3163
- "animation-timeline": "animationTimeline",
3164
- "animation-range": "animationRange"
3165
- }, oe = {
3166
- animation: "none",
3167
- "animation-composition": "replace",
3168
- transition: "_",
3169
- "animation-timeline": "auto",
3170
- "animation-range": "normal"
3171
- };
3172
- function wt(t, e, n) {
3173
- const s = t.get(e);
3174
- s ? n.forEach((i) => s.add(i)) : t.set(e, new Set(n));
3175
- }
3176
- function bt(t, e, n, s) {
3177
- const { key: i, childSelector: r } = n, o = s ? Oe.filter((a) => s.has(a)) : Oe;
3178
- t.has(e) || t.set(e, { key: i, childSelector: r, properties: {} });
3179
- const { properties: c } = t.get(e);
3180
- for (const a of o)
3181
- c[a] || (c[a] = { fallback: oe[a], varNames: [] }), c[a].varNames.push(n[a]);
3182
- }
3183
- function St(t, e) {
3184
- return Oe.reduce(
3185
- (n, s) => (n[s] = An([s, ...t, e]), n),
3186
- {}
3187
- );
3188
- }
3189
- function si(t, e, n, s, i) {
3190
- return s.has(t) || s.set(t, {
3191
- key: e,
3192
- childSelector: i,
3193
- ...St([n], We(t))
3194
- }), s.get(t);
3195
- }
3196
- function ii(t, e, n) {
3197
- return St([e, n], We(t));
3198
- }
3199
- function ri(t, e, n, s = !0) {
3200
- const { key: i, conditions: r } = t, o = B(r, e, "media"), c = P(r, e), a = x(t, {
3201
- asCombinator: !0,
3202
- useFirstChild: s,
3203
- addItemFilter: !0
3204
- });
3205
- return {
3206
- key: i,
3207
- media: o,
3208
- selectorCondition: c,
3209
- childSelector: a,
3210
- // invalidating earlier cascaded custom properties affected from earlier transitionEffects
3211
- // to implement same-interaction-cascade
3212
- declarations: [
3213
- {
3214
- name: "view-timeline",
3215
- value: `--${n}`
3216
- }
3217
- ]
3218
- };
3219
- }
3220
- function Tt(t, e, n, s, i) {
3221
- const r = [];
3222
- for (const o of Object.keys(i)) {
3223
- const c = `${ft}${o}`;
3224
- c in e && r.push(
3225
- ...i[o](e[c], {
3226
- key: n,
3227
- scope: t,
3228
- config: e
3229
- }).map((a) => ({ ...a, key: n, media: s }))
3230
- );
3231
- }
3232
- return r;
3233
- }
3234
- function oi(t, e, n, s, i, r) {
3235
- const {
3236
- key: o,
3237
- effectId: c,
3238
- conditions: a,
3239
- namedEffect: u,
3240
- keyframeEffect: f,
3241
- transition: l,
3242
- transitionProperties: d,
3243
- initial: g
3244
- } = t, h = B(a, e, "media"), m = P(a, e), p = [
3245
- {
3246
- key: o,
3247
- media: h,
3248
- selectorCondition: m,
3249
- childSelector: i,
3250
- declarations: []
3251
- }
3252
- ];
3253
- let v = [];
3254
- const { declarations: y } = p[0];
3255
- let E = [];
3256
- if (r && p.push(...Tt("effect", t, o, h, r)), u || f) {
3257
- E = [...re];
3258
- const w = q(t), S = En(null, w, s).filter(
3259
- (I) => I.name
3260
- );
3261
- v = S.map((I) => ({
3262
- name: I.name,
3263
- keyframes: I.keyframes
3264
- })), y.push(
3265
- ...S.flatMap(
3266
- ({ custom: I }) => Object.entries(I || {}).filter(([C, z]) => z !== void 0).map(([C, z]) => ({ name: C, value: z }))
3267
- )
3268
- );
3269
- const T = re.map((I) => ({
3270
- name: n[I],
3271
- value: S.map((C) => {
3272
- const z = ni[I];
3273
- return C[z];
3274
- }).join(", ") || oe[I]
3275
- }));
3276
- g ? (p.push({
3277
- key: o,
3278
- media: h,
3279
- selectorCondition: m,
3280
- childSelector: i,
3281
- declarations: ti,
3282
- selectorSuffix: ":not([data-interact-enter])"
3283
- }), p.push({
3284
- key: o,
3285
- media: h,
3286
- selectorCondition: m,
3287
- childSelector: i,
3288
- declarations: T,
3289
- selectorSuffix: ':not([data-interact-enter="done"])'
3290
- })) : y.push(...T);
3291
- } else if (l || d) {
3292
- E = ["transition"];
3293
- const w = tt(t), S = nt(t);
3294
- y.push({
3295
- name: n.transition,
3296
- value: S.join(", ") || oe.transition
3297
- }), p.push({
3298
- key: o,
3299
- media: h,
3300
- selectorCondition: m,
3301
- childSelector: i,
3302
- states: [c],
3303
- declarations: w
3304
- });
3305
- } else
3306
- y.push(
3307
- ...re.map((w) => ({
3308
- name: n[w],
3309
- value: oe[w]
3310
- }))
3311
- );
3312
- return { rules: p.filter((w) => w.declarations.length), keyframes: v, usedProperties: E };
3313
- }
3314
- function It(t, e, n, s, i, r, o = !0, c, a, u) {
3315
- const { key: f } = n, l = u ?? W(n), d = x(n, {
3316
- asCombinator: !0,
3317
- useFirstChild: o,
3318
- addItemFilter: !0
3319
- }), h = { ...si(
3320
- l,
3321
- f,
3322
- e,
3323
- s,
3324
- d
3325
- ) };
3326
- a && Object.assign(h, a);
3327
- const { rules: m, keyframes: p, usedProperties: v } = oi(
3328
- n,
3329
- t,
3330
- h,
3331
- r,
3332
- d,
3333
- c
3334
- );
3335
- return p.forEach(({ name: y, keyframes: E }) => i.set(y, E)), { rules: m, usedProperties: v };
3336
- }
3337
- function ci(t, e, n, s, i, r, o = !0, c, a) {
3338
- const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), l = [];
3339
- for (const g of n.effects) {
3340
- const h = W(g), { key: m } = g, p = x(g, {
3341
- asCombinator: !0,
3342
- useFirstChild: o,
3343
- addItemFilter: !0
3344
- }), v = f.get(h) || 0;
3345
- f.set(h, v + 1);
3346
- const y = ii(h, e, v), { rules: E, usedProperties: w } = It(
3347
- t,
3348
- e,
3349
- g,
3350
- s,
3351
- i,
3352
- r,
3353
- o,
3354
- a,
3355
- y,
3356
- h
3357
- );
3358
- l.push(...E);
3359
- const S = new Set(w);
3360
- bt(
3361
- u,
3362
- h,
3363
- { key: m, childSelector: p, ...y },
3364
- S
3365
- ), c && wt(c, h, w);
3366
- }
3367
- const { conditions: d } = n;
3368
- return u.forEach((g, h) => {
3369
- const m = s.get(h);
3370
- l.push(Et(g, m, d, t));
3371
- }), l;
3372
- }
3373
- function ai(t, e, n, s, i, r = !0, o) {
3374
- const { key: c, conditions: a, effects: u = [], sequences: f = [] } = e, l = t.conditions || {}, d = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), h = u.map((E) => yt(E, e, t)).filter((E) => E !== null), m = o ? Tt(
3375
- "interaction",
3376
- e,
3377
- c,
3378
- B(a, l, "media"),
3379
- o
3380
- ) : [], { trigger: p } = e, v = {
3381
- trigger: Cn(p),
3382
- id: ["trigger", n].join("-")
3383
- };
3384
- p === "viewProgress" && m.push(ri(e, l, v.id, r));
3385
- for (const E of h) {
3386
- const w = W(E), { rules: S, usedProperties: T } = It(
3387
- l,
3388
- n,
3389
- E,
3390
- d,
3391
- i,
3392
- v,
3393
- r,
3394
- o
3395
- );
3396
- m.push(...S), wt(g, w, T);
3397
- }
3398
- const y = f.map((E) => Us(E, e, t)).filter((E) => E !== null);
3399
- return m.push(
3400
- ...y.flatMap(
3401
- (E) => ci(
3402
- l,
3403
- n,
3404
- E,
3405
- d,
3406
- i,
3407
- v,
3408
- r,
3409
- g,
3410
- o
3411
- )
3412
- )
3413
- ), d.forEach((E, w) => {
3414
- bt(
3415
- s,
3416
- w,
3417
- E,
3418
- g.get(w)
3419
- );
3420
- }), m;
3421
- }
3422
- function fi(t = {}) {
3423
- const { useFirstChild: e = !0, plugins: n } = typeof t == "boolean" ? { useFirstChild: t, plugins: void 0 } : t;
3424
- return { useFirstChild: e, plugins: n };
3425
- }
3426
- function ui(t, e) {
3427
- const { useFirstChild: n, plugins: s } = fi(e), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = t.interactions.flatMap(
3428
- (c, a) => ai(
3429
- t,
3430
- c,
3431
- a,
3432
- i,
3433
- r,
3434
- n,
3435
- s
3436
- )
3437
- );
3438
- return i.forEach((c) => {
3439
- o.push(Et(c));
3440
- }), { keyframes: r, cssRules: o };
3441
- }
3442
- function hi(t, e) {
3443
- const { cssRules: n, keyframes: s } = ui(t, e);
3444
- return [
3445
- ...[...s.entries()].map(([r, o]) => Js(r, o)),
3446
- ...n.map(ei)
3447
- ].join(`
3448
- `);
3449
- }
3450
- export {
3451
- Bs as I,
3452
- b as a,
3453
- li as b,
3454
- hi as g,
3455
- di as r
3456
- };
3457
- //# sourceMappingURL=index-CEt49C5d.mjs.map