@wix/interact 2.0.2 → 2.0.3-dp.20260305184833

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/react.js +1 -1
  3. package/dist/cjs/web.js +1 -1
  4. package/dist/es/index.js +1 -1
  5. package/dist/es/react.js +2 -2
  6. package/dist/es/web.js +2 -2
  7. package/dist/index-BZL18ynN.mjs +2750 -0
  8. package/dist/index-BZL18ynN.mjs.map +1 -0
  9. package/dist/index-IaOsZpFD.js +18 -0
  10. package/dist/index-IaOsZpFD.js.map +1 -0
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/dist/types/core/Interact.d.ts +9 -1
  13. package/dist/types/core/Interact.d.ts.map +1 -1
  14. package/dist/types/core/add.d.ts.map +1 -1
  15. package/dist/types/handlers/animationEnd.d.ts +1 -1
  16. package/dist/types/handlers/animationEnd.d.ts.map +1 -1
  17. package/dist/types/handlers/constants.d.ts +13 -0
  18. package/dist/types/handlers/constants.d.ts.map +1 -0
  19. package/dist/types/handlers/effectHandlers.d.ts +7 -0
  20. package/dist/types/handlers/effectHandlers.d.ts.map +1 -0
  21. package/dist/types/handlers/eventTrigger.d.ts +9 -0
  22. package/dist/types/handlers/eventTrigger.d.ts.map +1 -0
  23. package/dist/types/handlers/index.d.ts.map +1 -1
  24. package/dist/types/handlers/viewEnter.d.ts +1 -1
  25. package/dist/types/handlers/viewEnter.d.ts.map +1 -1
  26. package/dist/types/types.d.ts +39 -2
  27. package/dist/types/types.d.ts.map +1 -1
  28. package/package.json +4 -3
  29. package/rules/MASTER-CLEANUP-PLAN.md +286 -0
  30. package/rules/click.md +12 -31
  31. package/rules/full-lean.md +26 -4
  32. package/rules/hover.md +68 -153
  33. package/rules/integration.md +17 -85
  34. package/rules/pointermove.md +32 -57
  35. package/rules/scroll-list.md +82 -280
  36. package/rules/viewenter.md +65 -90
  37. package/rules/viewprogress.md +139 -845
  38. package/dist/index-BnI6W-7u.mjs +0 -2312
  39. package/dist/index-BnI6W-7u.mjs.map +0 -1
  40. package/dist/index-D2V7_Srb.js +0 -18
  41. package/dist/index-D2V7_Srb.js.map +0 -1
  42. package/dist/types/handlers/click.d.ts +0 -9
  43. package/dist/types/handlers/click.d.ts.map +0 -1
  44. package/dist/types/handlers/hover.d.ts +0 -9
  45. package/dist/types/handlers/hover.d.ts.map +0 -1
@@ -1,2312 +0,0 @@
1
- function Ge(e) {
2
- return [...e.matchAll(/\[([-\w]+)]/g)].map(([t, n]) => n);
3
- }
4
- function R(e, t) {
5
- const n = Ge(t);
6
- let s = 0;
7
- return n.length ? e.replace(/\[]/g, () => {
8
- const r = n[s++];
9
- return r !== void 0 ? `[${r}]` : "[]";
10
- }) : e;
11
- }
12
- class le {
13
- animations;
14
- options;
15
- ready;
16
- isCSS;
17
- constructor(t, n) {
18
- this.animations = t, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = t[0] instanceof CSSAnimation;
19
- }
20
- getProgress() {
21
- return this.animations[0]?.effect?.getComputedTiming().progress || 0;
22
- }
23
- async play(t) {
24
- await this.ready;
25
- for (const n of this.animations)
26
- n.play();
27
- await Promise.all(this.animations.map((n) => n.ready)), t && t();
28
- }
29
- pause() {
30
- for (const t of this.animations)
31
- t.pause();
32
- }
33
- async reverse(t) {
34
- await this.ready;
35
- for (const n of this.animations)
36
- n.reverse();
37
- await Promise.all(this.animations.map((n) => n.ready)), t && t();
38
- }
39
- progress(t) {
40
- for (const n of this.animations) {
41
- const { delay: s, duration: r, iterations: i } = n.effect.getTiming(), o = (Number.isFinite(r) ? r : 0) * (Number.isFinite(i) ? i : 1);
42
- n.currentTime = ((s || 0) + o) * t;
43
- }
44
- }
45
- cancel() {
46
- for (const t of this.animations)
47
- t.cancel();
48
- }
49
- setPlaybackRate(t) {
50
- for (const n of this.animations)
51
- n.playbackRate = t;
52
- }
53
- async onFinish(t) {
54
- try {
55
- await Promise.all(this.animations.map((s) => s.finished));
56
- const n = this.animations[0];
57
- if (n && !this.isCSS) {
58
- const s = n.effect?.target;
59
- if (s) {
60
- const r = new Event("animationend");
61
- s.dispatchEvent(r);
62
- }
63
- }
64
- t();
65
- } catch (n) {
66
- console.warn("animation was interrupted - aborting onFinish callback - ", n);
67
- }
68
- }
69
- get finished() {
70
- return Promise.all(this.animations.map((t) => t.finished));
71
- }
72
- get playState() {
73
- return this.animations[0]?.playState;
74
- }
75
- }
76
- const Qe = (e) => e, Be = (e) => 1 - Math.cos(e * Math.PI / 2), Xe = (e) => Math.sin(e * Math.PI / 2), Ue = (e) => -(Math.cos(Math.PI * e) - 1) / 2, Je = (e) => e ** 2, Ze = (e) => 1 - (1 - e) ** 2, et = (e) => e < 0.5 ? 2 * e ** 2 : 1 - (-2 * e + 2) ** 2 / 2, tt = (e) => e ** 3, nt = (e) => 1 - (1 - e) ** 3, st = (e) => e < 0.5 ? 4 * e ** 3 : 1 - (-2 * e + 2) ** 3 / 2, it = (e) => e ** 4, rt = (e) => 1 - (1 - e) ** 4, ot = (e) => e < 0.5 ? 8 * e ** 4 : 1 - (-2 * e + 2) ** 4 / 2, at = (e) => e ** 5, ct = (e) => 1 - (1 - e) ** 5, ft = (e) => e < 0.5 ? 16 * e ** 5 : 1 - (-2 * e + 2) ** 5 / 2, lt = (e) => e === 0 ? 0 : 2 ** (10 * e - 10), ut = (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e), dt = (e) => e === 0 ? 0 : e === 1 ? 1 : e < 0.5 ? 2 ** (20 * e - 10) / 2 : (2 - 2 ** (-20 * e + 10)) / 2, ht = (e) => 1 - Math.sqrt(1 - e ** 2), mt = (e) => Math.sqrt(1 - (e - 1) ** 2), pt = (e) => e < 0.5 ? (1 - Math.sqrt(1 - 4 * e ** 2)) / 2 : (Math.sqrt(-(2 * e - 3) * (2 * e - 1)) + 1) / 2, gt = (e) => 2.70158 * e ** 3 - 1.70158 * e ** 2, vt = (e) => 1 + 2.70158 * (e - 1) ** 3 + 1.70158 * (e - 1) ** 2, yt = (e, t = 1.70158 * 1.525) => e < 0.5 ? (2 * e) ** 2 * ((t + 1) * 2 * e - t) / 2 : ((2 * e - 2) ** 2 * ((t + 1) * (e * 2 - 2) + t) + 2) / 2, wt = {
77
- linear: Qe,
78
- sineIn: Be,
79
- sineOut: Xe,
80
- sineInOut: Ue,
81
- quadIn: Je,
82
- quadOut: Ze,
83
- quadInOut: et,
84
- cubicIn: tt,
85
- cubicOut: nt,
86
- cubicInOut: st,
87
- quartIn: it,
88
- quartOut: rt,
89
- quartInOut: ot,
90
- quintIn: at,
91
- quintOut: ct,
92
- quintInOut: ft,
93
- expoIn: lt,
94
- expoOut: ut,
95
- expoInOut: dt,
96
- circIn: ht,
97
- circOut: mt,
98
- circInOut: pt,
99
- backIn: gt,
100
- backOut: vt,
101
- backInOut: yt
102
- }, me = {
103
- linear: "linear",
104
- ease: "ease",
105
- easeIn: "ease-in",
106
- easeOut: "ease-out",
107
- easeInOut: "ease-in-out",
108
- sineIn: "cubic-bezier(0.47, 0, 0.745, 0.715)",
109
- sineOut: "cubic-bezier(0.39, 0.575, 0.565, 1)",
110
- sineInOut: "cubic-bezier(0.445, 0.05, 0.55, 0.95)",
111
- quadIn: "cubic-bezier(0.55, 0.085, 0.68, 0.53)",
112
- quadOut: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
113
- quadInOut: "cubic-bezier(0.455, 0.03, 0.515, 0.955)",
114
- cubicIn: "cubic-bezier(0.55, 0.055, 0.675, 0.19)",
115
- cubicOut: "cubic-bezier(0.215, 0.61, 0.355, 1)",
116
- cubicInOut: "cubic-bezier(0.645, 0.045, 0.355, 1)",
117
- quartIn: "cubic-bezier(0.895, 0.03, 0.685, 0.22)",
118
- quartOut: "cubic-bezier(0.165, 0.84, 0.44, 1)",
119
- quartInOut: "cubic-bezier(0.77, 0, 0.175, 1)",
120
- quintIn: "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
121
- quintOut: "cubic-bezier(0.23, 1, 0.32, 1)",
122
- quintInOut: "cubic-bezier(0.86, 0, 0.07, 1)",
123
- expoIn: "cubic-bezier(0.95, 0.05, 0.795, 0.035)",
124
- expoOut: "cubic-bezier(0.19, 1, 0.22, 1)",
125
- expoInOut: "cubic-bezier(1, 0, 0, 1)",
126
- circIn: "cubic-bezier(0.6, 0.04, 0.98, 0.335)",
127
- circOut: "cubic-bezier(0.075, 0.82, 0.165, 1)",
128
- circInOut: "cubic-bezier(0.785, 0.135, 0.15, 0.86)",
129
- backIn: "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
130
- backOut: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
131
- backInOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
132
- };
133
- function Et(e) {
134
- return e === "percentage" ? "%" : e || "px";
135
- }
136
- function D(e) {
137
- return e ? me[e] || e : me.linear;
138
- }
139
- function bt(e) {
140
- return e ? wt[e] : void 0;
141
- }
142
- class St {
143
- _animation;
144
- customEffect;
145
- progress;
146
- _tickCbId;
147
- _finishHandler;
148
- constructor(t, n, s, r) {
149
- const i = new KeyframeEffect(n, [], {
150
- ...s,
151
- composite: "add"
152
- }), { timeline: o } = r;
153
- this._animation = new Animation(i, o), this._tickCbId = null, this.progress = null, this.customEffect = (a) => t(i.target, a), this._finishHandler = (a) => {
154
- this.effect.target?.getAnimations().find((f) => f === this._animation) || this.cancel();
155
- }, this.addEventListener("finish", this._finishHandler), this.addEventListener("remove", this._finishHandler);
156
- }
157
- // private tick method for customEffect loop implementation
158
- _tick() {
159
- try {
160
- const t = this.effect?.getComputedTiming().progress ?? null;
161
- t !== this.progress && (this.customEffect?.(t), this.progress = t), this._tickCbId = requestAnimationFrame(() => {
162
- this._tick();
163
- });
164
- } catch (t) {
165
- this._tickCbId = null, console.error(
166
- `failed to run customEffect! effectId: ${this.id}, error: ${t instanceof Error ? t.message : t}`
167
- );
168
- }
169
- }
170
- // Animation timing properties
171
- get currentTime() {
172
- return this._animation.currentTime;
173
- }
174
- set currentTime(t) {
175
- this._animation.currentTime = t;
176
- }
177
- get startTime() {
178
- return this._animation.startTime;
179
- }
180
- set startTime(t) {
181
- this._animation.startTime = t;
182
- }
183
- get playbackRate() {
184
- return this._animation.playbackRate;
185
- }
186
- set playbackRate(t) {
187
- this._animation.playbackRate = t;
188
- }
189
- // Animation basic properties
190
- get id() {
191
- return this._animation.id;
192
- }
193
- set id(t) {
194
- this._animation.id = t;
195
- }
196
- get effect() {
197
- return this._animation.effect;
198
- }
199
- set effect(t) {
200
- this._animation.effect = t;
201
- }
202
- get timeline() {
203
- return this._animation.timeline;
204
- }
205
- set timeline(t) {
206
- this._animation.timeline = t;
207
- }
208
- // Animation readonly state properties
209
- get finished() {
210
- return this._animation.finished;
211
- }
212
- get pending() {
213
- return this._animation.pending;
214
- }
215
- get playState() {
216
- return this._animation.playState;
217
- }
218
- get ready() {
219
- return this._animation.ready;
220
- }
221
- get replaceState() {
222
- return this._animation.replaceState;
223
- }
224
- // Animation event handlers
225
- get oncancel() {
226
- return this._animation.oncancel;
227
- }
228
- set oncancel(t) {
229
- this._animation.oncancel = t;
230
- }
231
- get onfinish() {
232
- return this._animation.onfinish;
233
- }
234
- set onfinish(t) {
235
- this._animation.onfinish = t;
236
- }
237
- get onremove() {
238
- return this._animation.onremove;
239
- }
240
- set onremove(t) {
241
- this._animation.onremove = t;
242
- }
243
- // CustomAnimation overridden methods
244
- play() {
245
- this._animation.play(), cancelAnimationFrame(this._tickCbId), this._tickCbId = requestAnimationFrame(() => this._tick());
246
- }
247
- pause() {
248
- this._animation.pause(), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
249
- }
250
- cancel() {
251
- this.removeEventListener("finish", this._finishHandler), this.removeEventListener("remove", this._finishHandler), this._animation.cancel(), this.customEffect(null), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
252
- }
253
- commitStyles() {
254
- console.warn(
255
- "CustomEffect animations do not support commitStyles method as they have no style to commit"
256
- );
257
- }
258
- // Animation methods without override
259
- finish() {
260
- this._animation.finish();
261
- }
262
- persist() {
263
- this._animation.persist();
264
- }
265
- reverse() {
266
- this._animation.reverse();
267
- }
268
- updatePlaybackRate(t) {
269
- this._animation.updatePlaybackRate(t);
270
- }
271
- // Animation events API
272
- addEventListener(t, n, s) {
273
- this._animation.addEventListener(t, n, s);
274
- }
275
- removeEventListener(t, n, s) {
276
- this._animation.removeEventListener(t, n, s);
277
- }
278
- dispatchEvent(t) {
279
- return this._animation.dispatchEvent(t);
280
- }
281
- }
282
- function It(e) {
283
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
284
- }
285
- var N = { exports: {} }, pe = N.exports, ge;
286
- function Ot() {
287
- return ge || (ge = 1, (function(e) {
288
- (function(t) {
289
- var n = function() {
290
- }, s = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.msRequestAnimationFrame || function(c) {
291
- return setTimeout(c, 16);
292
- };
293
- function r() {
294
- var c = this;
295
- c.reads = [], c.writes = [], c.raf = s.bind(t);
296
- }
297
- r.prototype = {
298
- constructor: r,
299
- /**
300
- * We run this inside a try catch
301
- * so that if any jobs error, we
302
- * are able to recover and continue
303
- * to flush the batch until it's empty.
304
- *
305
- * @param {Array} tasks
306
- */
307
- runTasks: function(c) {
308
- for (var u; u = c.shift(); ) u();
309
- },
310
- /**
311
- * Adds a job to the read batch and
312
- * schedules a new frame if need be.
313
- *
314
- * @param {Function} fn
315
- * @param {Object} ctx the context to be bound to `fn` (optional).
316
- * @public
317
- */
318
- measure: function(c, u) {
319
- var d = u ? c.bind(u) : c;
320
- return this.reads.push(d), i(this), d;
321
- },
322
- /**
323
- * Adds a job to the
324
- * write batch and schedules
325
- * a new frame if need be.
326
- *
327
- * @param {Function} fn
328
- * @param {Object} ctx the context to be bound to `fn` (optional).
329
- * @public
330
- */
331
- mutate: function(c, u) {
332
- var d = u ? c.bind(u) : c;
333
- return this.writes.push(d), i(this), d;
334
- },
335
- /**
336
- * Clears a scheduled 'read' or 'write' task.
337
- *
338
- * @param {Object} task
339
- * @return {Boolean} success
340
- * @public
341
- */
342
- clear: function(c) {
343
- return a(this.reads, c) || a(this.writes, c);
344
- },
345
- /**
346
- * Extend this FastDom with some
347
- * custom functionality.
348
- *
349
- * Because fastdom must *always* be a
350
- * singleton, we're actually extending
351
- * the fastdom instance. This means tasks
352
- * scheduled by an extension still enter
353
- * fastdom's global task queue.
354
- *
355
- * The 'super' instance can be accessed
356
- * from `this.fastdom`.
357
- *
358
- * @example
359
- *
360
- * var myFastdom = fastdom.extend({
361
- * initialize: function() {
362
- * // runs on creation
363
- * },
364
- *
365
- * // override a method
366
- * measure: function(fn) {
367
- * // do extra stuff ...
368
- *
369
- * // then call the original
370
- * return this.fastdom.measure(fn);
371
- * },
372
- *
373
- * ...
374
- * });
375
- *
376
- * @param {Object} props properties to mixin
377
- * @return {FastDom}
378
- */
379
- extend: function(c) {
380
- if (typeof c != "object") throw new Error("expected object");
381
- var u = Object.create(this);
382
- return f(u, c), u.fastdom = this, u.initialize && u.initialize(), u;
383
- },
384
- // override this with a function
385
- // to prevent Errors in console
386
- // when tasks throw
387
- catch: null
388
- };
389
- function i(c) {
390
- c.scheduled || (c.scheduled = !0, c.raf(o.bind(null, c)));
391
- }
392
- function o(c) {
393
- var u = c.writes, d = c.reads, g;
394
- try {
395
- n("flushing reads", d.length), c.runTasks(d), n("flushing writes", u.length), c.runTasks(u);
396
- } catch (h) {
397
- g = h;
398
- }
399
- if (c.scheduled = !1, (d.length || u.length) && i(c), g)
400
- if (n("task errored", g.message), c.catch) c.catch(g);
401
- else throw g;
402
- }
403
- function a(c, u) {
404
- var d = c.indexOf(u);
405
- return !!~d && !!c.splice(d, 1);
406
- }
407
- function f(c, u) {
408
- for (var d in u)
409
- u.hasOwnProperty(d) && (c[d] = u[d]);
410
- }
411
- var l = t.fastdom = t.fastdom || new r();
412
- e.exports = l;
413
- })(typeof window < "u" ? window : typeof pe < "u" ? pe : globalThis);
414
- })(N)), N.exports;
415
- }
416
- var _t = Ot();
417
- const S = /* @__PURE__ */ It(_t), ie = {};
418
- function kt(e) {
419
- Object.assign(ie, e);
420
- }
421
- function Tt(e) {
422
- return e in ie ? ie[e] : (console.warn(
423
- `${e} not found in registry. Please make sure to import and register the preset.`
424
- ), null);
425
- }
426
- function T(e, t) {
427
- return e ? document.getElementById(e) : null;
428
- }
429
- function xt(e, t) {
430
- return e?.matches(`[data-motion-part~="${t}"]`) ? e : e?.querySelector(`[data-motion-part~="${t}"]`);
431
- }
432
- function Ct(e) {
433
- const t = e.alternate ? "alternate" : "";
434
- return e.reversed ? `${t ? `${t}-` : ""}reverse` : t || "normal";
435
- }
436
- function te(e) {
437
- return `${e.value}${Et(e.unit)}`;
438
- }
439
- function ve(e, t, n) {
440
- return `${e.name || "cover"} ${n && e.offset.unit !== "percentage" ? `calc(100% + ${te(e.offset)}${t ? ` + ${t}` : ""})` : t ? `calc(${te(e.offset)} + ${t})` : te(e.offset)}`;
441
- }
442
- function Lt(e) {
443
- return {
444
- start: ve(e.startOffset, e.startOffsetAdd),
445
- end: ve(e.endOffset, e.endOffsetAdd, !0)
446
- };
447
- }
448
- function Pe(e) {
449
- return (t) => S.measure(() => t(e));
450
- }
451
- function $e(e) {
452
- return (t) => S.mutate(() => t(e));
453
- }
454
- function K(e) {
455
- if (e.namedEffect) {
456
- const t = e.namedEffect.type;
457
- return typeof t == "string" ? Tt(t) : null;
458
- } else if (e.keyframeEffect) {
459
- const t = (s) => {
460
- const { name: r, keyframes: i } = s.keyframeEffect;
461
- return [{ ...s, name: r, keyframes: i }];
462
- };
463
- return { web: t, style: t, getNames: (s) => {
464
- const { effectId: r } = s, { name: i } = s.keyframeEffect, o = i || r;
465
- return o ? [o] : [];
466
- } };
467
- } else if (e.customEffect)
468
- return (t) => [{ ...t, keyframes: [] }];
469
- return null;
470
- }
471
- function At(e, t, n) {
472
- return e.map((s, r) => {
473
- const i = {
474
- fill: s.fill,
475
- easing: D(s.easing),
476
- iterations: s.iterations === 0 ? 1 / 0 : s.iterations || 1,
477
- composite: s.composite,
478
- direction: Ct(s)
479
- };
480
- return Re(t) ? (i.duration = s.duration, i.delay = s.delay || 0) : window.ViewTimeline && t?.trigger === "view-progress" ? i.duration = "auto" : (i.duration = 99.99, i.delay = 0.01), {
481
- effect: s,
482
- options: i,
483
- id: n && `${n}-${r + 1}`,
484
- part: s.part
485
- };
486
- });
487
- }
488
- function Re(e) {
489
- return !e || e.trigger !== "pointer-move" && e.trigger !== "view-progress";
490
- }
491
- function ye(e, t, n, s, r) {
492
- if (e) {
493
- if (Re(s) && (t.duration = t.duration || 1, r?.reducedMotion))
494
- if (t.iterations === 1 || t.iterations == null)
495
- t = { ...t, duration: 1 };
496
- else
497
- return [];
498
- let i;
499
- return n instanceof HTMLElement && (i = { measure: Pe(n), mutate: $e(n) }), e.web ? e.web(t, i, r) : e(t, i, r);
500
- }
501
- return [];
502
- }
503
- function ue(e, t, n, s, r) {
504
- const i = e instanceof HTMLElement ? e : T(e);
505
- if (n?.trigger === "pointer-move" && !t.keyframeEffect) {
506
- let d = t;
507
- t.customEffect && (d = {
508
- ...t,
509
- namedEffect: { id: "", type: "CustomMouse" }
510
- });
511
- const g = K(
512
- d
513
- ), h = ye(
514
- g,
515
- t,
516
- i,
517
- n,
518
- s
519
- );
520
- return typeof h != "function" ? null : h(i);
521
- }
522
- const o = K(t), a = ye(
523
- o,
524
- t,
525
- i,
526
- n,
527
- s
528
- );
529
- if (!a || a.length === 0)
530
- return null;
531
- const f = At(a, n, t.effectId);
532
- let l;
533
- const c = n?.trigger === "view-progress";
534
- c && window.ViewTimeline && (l = new ViewTimeline({
535
- subject: n.element || T(n.componentId)
536
- }));
537
- const u = f.map(({ effect: d, options: g, id: h, part: m }) => {
538
- const p = m ? xt(i, m) : i, v = new KeyframeEffect(p || null, [], g);
539
- S.mutate(() => {
540
- "timing" in d && v.updateTiming(d.timing), v.setKeyframes(d.keyframes);
541
- });
542
- const y = c && l ? { timeline: l } : {}, E = typeof d.customEffect == "function" ? new St(
543
- d.customEffect,
544
- p || null,
545
- g,
546
- y
547
- ) : new Animation(v, y.timeline);
548
- if (c)
549
- if (l)
550
- S.mutate(() => {
551
- const { start: b, end: I } = Lt(d);
552
- E.rangeStart = b, E.rangeEnd = I, E.play();
553
- });
554
- else {
555
- const { startOffset: b, endOffset: I } = t;
556
- S.mutate(() => {
557
- const L = d.startOffset || b, J = d.endOffset || I;
558
- Object.assign(E, {
559
- start: {
560
- name: L.name,
561
- offset: L.offset?.value,
562
- add: d.startOffsetAdd
563
- },
564
- end: {
565
- name: J.name,
566
- offset: J.offset?.value,
567
- add: d.endOffsetAdd
568
- }
569
- });
570
- });
571
- }
572
- return h && (E.id = h), E;
573
- });
574
- return new le(u, {
575
- ...t,
576
- trigger: { ...n || {} },
577
- // make sure the group is ready after all animation targets are measured and mutated
578
- measured: new Promise((d) => S.mutate(d))
579
- });
580
- }
581
- function Pt(e, t, n) {
582
- const s = K(t), r = e instanceof HTMLElement ? e : T(e);
583
- if (s && s.prepare && r) {
584
- const i = { measure: Pe(r), mutate: $e(r) };
585
- s.prepare(t, i);
586
- }
587
- n && S.mutate(n);
588
- }
589
- function $t(e, t) {
590
- const n = K(t);
591
- if (!n)
592
- return null;
593
- if (!n.style)
594
- return t.effectId && e ? Rt(e, t.effectId) : null;
595
- const s = n.getNames(t), i = (typeof e == "string" ? T(e) : e)?.getAnimations(), o = i?.map((f) => f.animationName) || [], a = [];
596
- return s.forEach((f) => {
597
- o.includes(f) && a.push(
598
- i?.find((l) => l.animationName === f)
599
- );
600
- }), a?.length ? new le(a) : null;
601
- }
602
- function Rt(e, t) {
603
- const s = (typeof e == "string" ? T(e) : e)?.getAnimations().filter((r) => {
604
- const i = r.id || r.animationName;
605
- return i ? i.startsWith(t) : !0;
606
- });
607
- return s?.length ? new le(s) : null;
608
- }
609
- function Me(e, t, n, s = {}) {
610
- const { disabled: r, allowActiveEvent: i, ...o } = s, a = ue(e, t, n, o);
611
- if (!a)
612
- return null;
613
- let f = {};
614
- if (n.trigger === "view-progress" && !window.ViewTimeline) {
615
- const l = n.element || T(n.componentId), { ready: c } = a;
616
- return a.animations.map((u) => ({
617
- /* we use getters for start and end in order to access the animation's start and end
618
- only when initializing the scrub scene rather than immediately */
619
- get start() {
620
- return u.start;
621
- },
622
- get end() {
623
- return u.end;
624
- },
625
- viewSource: l,
626
- ready: c,
627
- getProgress() {
628
- return a.getProgress();
629
- },
630
- effect(d, g) {
631
- const { activeDuration: h } = u.effect.getComputedTiming(), { delay: m } = u.effect.getTiming();
632
- u.currentTime = ((m || 0) + (h || 0)) * g;
633
- },
634
- disabled: r,
635
- destroy() {
636
- u.cancel();
637
- }
638
- }));
639
- } else if (n.trigger === "pointer-move") {
640
- const l = t, { centeredToTarget: c, transitionDuration: u, transitionEasing: d } = l, g = n.axis;
641
- if (l.keyframeEffect) {
642
- const h = a;
643
- return h.animations?.length === 0 ? null : {
644
- target: void 0,
645
- centeredToTarget: c,
646
- ready: h.ready,
647
- _currentProgress: 0,
648
- getProgress() {
649
- return this._currentProgress;
650
- },
651
- effect(p, v) {
652
- const y = g === "x" ? v.x : v.y;
653
- this._currentProgress = y, h.progress(y);
654
- },
655
- disabled: r ?? !1,
656
- destroy() {
657
- h.cancel();
658
- }
659
- };
660
- }
661
- f = {
662
- centeredToTarget: c,
663
- allowActiveEvent: i
664
- }, t.customEffect && u && (f.transitionDuration = u, f.transitionEasing = bt(d)), f.target = a.target;
665
- }
666
- return {
667
- ...f,
668
- getProgress() {
669
- return a.getProgress();
670
- },
671
- effect(l, c, u, d) {
672
- a.progress(
673
- u ? {
674
- // @ts-expect-error spread error on p
675
- ...c,
676
- v: u,
677
- active: d
678
- } : c
679
- );
680
- },
681
- disabled: r,
682
- destroy() {
683
- a.cancel();
684
- }
685
- };
686
- }
687
- function U(e, t, n, s = !1) {
688
- const r = $t(e, t);
689
- return r ? (r.ready = new Promise((i) => {
690
- Pt(e, t, i);
691
- }), r) : ue(e, t, n, { reducedMotion: s });
692
- }
693
- function V(e, t) {
694
- return t.includes("&") ? t.replace(/&/g, e) : `${e}${t}`;
695
- }
696
- function Mt() {
697
- return "wi-12343210".replace(
698
- /\d/g,
699
- (e) => String.fromCharCode(
700
- (+e ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +e / 4) + 97
701
- )
702
- // 97 for "a"
703
- );
704
- }
705
- function Ft({
706
- key: e,
707
- effectId: t,
708
- transition: n,
709
- properties: s,
710
- childSelector: r = "> :first-child",
711
- selectorCondition: i
712
- }) {
713
- let o = [];
714
- if (n?.styleProperties) {
715
- const { duration: h, easing: m, delay: p } = n;
716
- h && (n.styleProperties.some(
717
- (y) => y.name.startsWith("--")
718
- ) ? o = [
719
- `all ${h}ms ${D(m || "ease")}${p ? ` ${p}ms` : ""}`,
720
- "visibility 0s"
721
- ] : o = n.styleProperties.map(
722
- (y) => `${y.name} ${h}ms ${D(
723
- m || "ease"
724
- )}${p ? ` ${p}ms` : ""}`
725
- )), s = n.styleProperties;
726
- } else
727
- o = s?.filter((h) => h.duration).map(
728
- (h) => `${h.name} ${h.duration}ms ${D(h.easing) || "ease"}${h.delay ? ` ${h.delay}ms` : ""}`
729
- ) || [];
730
- const a = s?.map((h) => `${h.name}: ${h.value};`) || [], f = e.replace(/"/g, "'"), l = `:is(:state(${t}), :--${t}) ${r}`, c = `[data-interact-effect~="${t}"] ${r}`, u = i ? V(l, i) : l, d = i ? V(c, i) : c, g = [
731
- `${u},
732
- ${d} {
733
- ${a.join(`
734
- `)}
735
- }`
736
- ];
737
- if (o.length) {
738
- const h = `[data-interact-key="${f}"] ${r}`, m = i ? V(h, i) : h;
739
- g.push(`@media (prefers-reduced-motion: no-preference) { ${m} {
740
- transition: ${o.join(", ")};
741
- } }`);
742
- }
743
- return g;
744
- }
745
- function M(e, t) {
746
- const n = (e || []).filter((i) => t[i]?.type === "media" && t[i].predicate).map((i) => t[i].predicate).join(") and ("), s = n && `(${n})`;
747
- return s && window.matchMedia(s);
748
- }
749
- function G(e, t) {
750
- for (const n of e || []) {
751
- const s = t[n];
752
- if (s?.type === "selector" && s.predicate)
753
- return s.predicate;
754
- }
755
- }
756
- const F = {
757
- rangeStart: { name: "cover", offset: { value: 0, unit: "percentage" } },
758
- rangeEnd: { name: "cover", offset: { value: 100, unit: "percentage" } }
759
- };
760
- function Ht(e, t) {
761
- const n = e?.name ?? F.rangeStart.name, s = t?.name ?? e?.name ?? F.rangeEnd.name, r = {
762
- name: n,
763
- offset: e?.offset || F.rangeStart.offset
764
- }, i = {
765
- name: s,
766
- offset: t?.offset || F.rangeEnd.offset
767
- };
768
- return { startOffset: r, endOffset: i };
769
- }
770
- function x(e) {
771
- if ("keyframeEffect" in e && !e.keyframeEffect.name && "effectId" in e && (e.keyframeEffect.name = e.effectId), "duration" in e)
772
- return {
773
- id: "",
774
- ...e
775
- };
776
- const { rangeStart: t, rangeEnd: n, ...s } = e, { startOffset: r, endOffset: i } = Ht(t, n);
777
- return {
778
- id: "",
779
- startOffset: r,
780
- endOffset: i,
781
- ...s
782
- };
783
- }
784
- function O(e, t, n) {
785
- let s = e.get(t);
786
- s || (s = /* @__PURE__ */ new Set(), e.set(t, s)), s.add(n);
787
- }
788
- function C(e, t) {
789
- e.get(t)?.forEach((s) => {
790
- const { source: r, target: i, cleanup: o } = s;
791
- o();
792
- const a = r === t ? i : r;
793
- e.get(a)?.delete(s);
794
- }), e.delete(t);
795
- }
796
- const qt = {
797
- root: null,
798
- rootMargin: "0px 0px -10% 0px",
799
- threshold: [0]
800
- }, zt = {
801
- root: null,
802
- rootMargin: "0px",
803
- threshold: [0]
804
- }, P = {}, Q = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakSet(), j = /* @__PURE__ */ new WeakMap();
805
- let Fe = {}, A = null;
806
- function Dt(e) {
807
- Fe = e;
808
- }
809
- function He(e, t) {
810
- Q.get(e)?.forEach(({ source: s, handler: r }) => {
811
- s === e && r(t);
812
- });
813
- }
814
- function we() {
815
- return A || (A = new IntersectionObserver((e) => {
816
- e.forEach((t) => {
817
- const n = t.target;
818
- t.isIntersecting || He(n, !1);
819
- });
820
- }, zt), A);
821
- }
822
- function qe(e, t = !1) {
823
- const n = JSON.stringify({ ...e, isSafeMode: t });
824
- if (P[n])
825
- return P[n];
826
- const s = t ? qt : {
827
- root: null,
828
- rootMargin: e.inset ? `${e.inset} 0px ${e.inset}` : "0px",
829
- threshold: e.threshold
830
- }, r = new IntersectionObserver((i) => {
831
- i.forEach((o) => {
832
- const a = o.target, f = !W.has(a);
833
- if (f && (W.add(a), e.useSafeViewEnter && !o.isIntersecting)) {
834
- S.measure(() => {
835
- const c = o.boundingClientRect.height, u = o.rootBounds?.height;
836
- if (!u)
837
- return;
838
- const d = Array.isArray(e.threshold) ? Math.min(...e.threshold) : e.threshold;
839
- d && c * d > u && S.mutate(() => {
840
- r.unobserve(a);
841
- const h = qe(e, !0);
842
- j.set(a, h), h.observe(a);
843
- });
844
- });
845
- return;
846
- }
847
- const l = e.type || "once";
848
- (o.isIntersecting || l === "alternate" && !f) && (He(a, o.isIntersecting), l === "once" && (r.unobserve(o.target), W.delete(a)));
849
- });
850
- }, s);
851
- return P[n] = r, r;
852
- }
853
- function Nt(e, t, n, s = {}, { reducedMotion: r, selectorCondition: i } = {}) {
854
- const o = { ...Fe, ...s }, a = o.type || "once", f = U(
855
- t,
856
- x(n),
857
- void 0,
858
- r
859
- );
860
- if (!f)
861
- return;
862
- const l = qe(o);
863
- a !== "once" && f.persist?.();
864
- let c = !0;
865
- const g = { source: e, target: t, handler: (h) => {
866
- i && !t.matches(i) || (a === "once" ? h && f.play(() => {
867
- const m = () => {
868
- t.dataset.interactEnter = "start";
869
- };
870
- f.isCSS ? (S.mutate(() => {
871
- requestAnimationFrame(m);
872
- }), f.onFinish(() => {
873
- S.mutate(() => {
874
- t.dataset.interactEnter = "done";
875
- });
876
- })) : S.mutate(m);
877
- }) : a === "alternate" ? c && h ? (c = !1, f.play()) : c || f.reverse() : a === "repeat" ? h ? (f.progress(0), f.play()) : (f.pause(), f.progress(0)) : a === "state" && (h ? f.play() : f.pause()));
878
- }, cleanup: () => {
879
- (j.get(e) || l).unobserve(e), (a === "repeat" || a === "state") && we().unobserve(e), f.cancel(), W.delete(e), j.delete(e);
880
- } };
881
- O(Q, e, g), O(Q, t, g), j.set(e, l), l.observe(e), (a === "repeat" || a === "state") && we().observe(e);
882
- }
883
- function Vt(e) {
884
- C(Q, e);
885
- }
886
- function Wt() {
887
- A = null, Object.keys(P).forEach((e) => delete P[e]);
888
- }
889
- const Ee = {
890
- add: Nt,
891
- remove: Vt,
892
- setOptions: Dt,
893
- reset: Wt
894
- };
895
- function ze(e, t) {
896
- return Object.assign(Object.create(t), e);
897
- }
898
- function jt(e, t, n, s) {
899
- let r = e * (1 - n) + t * n;
900
- if (s) {
901
- const i = r - e;
902
- Math.abs(i) < s && (r = e + s * Math.sign(i));
903
- const o = t - r;
904
- if (Math.abs(o) < s)
905
- return t;
906
- }
907
- return r;
908
- }
909
- function Yt(e) {
910
- let t = !1;
911
- return function() {
912
- t || (t = !0, window.requestAnimationFrame(() => {
913
- t = !1, e();
914
- }));
915
- };
916
- }
917
- function be(e, t) {
918
- let n = 0;
919
- return function() {
920
- n && window.clearTimeout(n), n = window.setTimeout(() => {
921
- n = 0, e();
922
- }, t);
923
- };
924
- }
925
- function Kt(e, t) {
926
- const n = e.match(/^calc\s*\(\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\+\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\)\s*$/);
927
- return B(n[1], t) + B(n[6], t);
928
- }
929
- function B(e, t) {
930
- return e ? /^-?\d+px$/.test(e) ? parseInt(e) : /^-?\d+[lsd]?vh$/.test(e) ? parseInt(e) * t.viewportHeight / 100 : /^-?\d+[lsd]?vw$/.test(e) ? parseInt(e) * t.viewportWidth / 100 : /^calc\s*\(\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\+\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\)\s*$/.test(e) ? Kt(e, t) : parseInt(e) || 0 : 0;
931
- }
932
- function _(e, t, n) {
933
- const { name: s, offset: r = 0 } = e, { start: i, end: o } = n, a = o - i, f = r / 100;
934
- let l, c;
935
- return s === "entry" ? (l = i - t, c = Math.min(t, a)) : s === "entry-crossing" ? (l = i - t, c = a) : s === "contain" ? (l = Math.min(o - t, i), c = Math.abs(t - a)) : s === "exit" ? (l = Math.max(i, o - t), c = Math.min(t, a)) : s === "exit-crossing" ? (l = i, c = a) : s === "cover" && (l = i - t, c = a + t), l + f * c | 0;
936
- }
937
- function ne(e, t, n, s, r) {
938
- let i = 0;
939
- const o = { start: t, end: n };
940
- return e.forEach((a, f) => {
941
- i += a.offset;
942
- const l = a.sticky;
943
- if (l) {
944
- if ("end" in l && e[f - 1]?.element) {
945
- const d = ((r ? a.element.offsetWidth : a.element.offsetHeight) || 0) + l.end - s, g = i + d - a.offset, h = g < o.start, m = !h && g <= n;
946
- let p = 0;
947
- (h || m) && (p = a.offset, o.end += p), h && (o.start += p);
948
- }
949
- if ("start" in l) {
950
- const c = i - l.start, u = c < o.start, d = !u && c <= o.end;
951
- let g = 0;
952
- const h = e[f - 1]?.element;
953
- if (h) {
954
- if (u || d) {
955
- const m = (r ? h.offsetWidth : h.offsetHeight) || 0, p = a.offset, v = (r ? a.element.offsetWidth : a.element.offsetHeight) || 0;
956
- g = m - (p + v), i += g, o.end += g;
957
- }
958
- u && (o.start += g);
959
- }
960
- }
961
- }
962
- }), o;
963
- }
964
- function Gt(e, t, n, s, r, i) {
965
- const { start: o, end: a, duration: f } = e;
966
- let l = o, c = a, u = e.startRange, d = e.endRange, g;
967
- if (typeof f == "string") {
968
- u = { name: f, offset: 0 }, d = { name: f, offset: 100 }, l = _(u, n, t), c = _(d, n, t), g = c - l;
969
- const h = ne(i, l, c, n, s);
970
- l = h.start, c = h.end;
971
- } else {
972
- if (u || o?.name) {
973
- u = u || o;
974
- const h = B(u.add, r), m = _({ ...u, offset: 0 }, n, t), p = _({ ...u, offset: 100 }, n, t), v = ne(i, m, p, n, s);
975
- l = v.start + u.offset / 100 * (v.end - v.start) + h;
976
- }
977
- if (d || a?.name) {
978
- d = d || a;
979
- const h = B(d.add, r), m = _({ ...d, offset: 0 }, n, t), p = _({ ...d, offset: 100 }, n, t), v = ne(i, m, p, n, s);
980
- c = v.start + d.offset / 100 * (v.end - v.start) + h;
981
- } else typeof f == "number" && (c = l + f);
982
- }
983
- return !g && !f && (g = c - l), { ...e, start: l, end: c, startRange: u, endRange: d, duration: g || f };
984
- }
985
- function Qt(e) {
986
- return e.position === "sticky";
987
- }
988
- function Bt(e, t, n) {
989
- return e.position === "fixed" && (!t || t === window.document.body || t === n);
990
- }
991
- function Xt(e, t) {
992
- return parseInt(t ? e.left : e.top);
993
- }
994
- function Ut(e, t) {
995
- return parseInt(t ? e.right : e.bottom);
996
- }
997
- function Jt(e, t, n) {
998
- n && (e.style.position = "static");
999
- const s = (t ? e.offsetLeft : e.offsetTop) || 0;
1000
- return n && (e.style.position = null), s;
1001
- }
1002
- function Zt(e, t) {
1003
- let n;
1004
- const s = Xt(e, t), r = Ut(e, t), i = !isNaN(s), o = !isNaN(r);
1005
- return (i || o) && (n = {}, i && (n.start = s), o && (n.end = r)), n;
1006
- }
1007
- function H(e, t, n, s, r) {
1008
- const i = e[0].viewSource, o = [];
1009
- let a = (s ? i.offsetWidth : i.offsetHeight) || 0, f = 0, l = i;
1010
- for (; l; ) {
1011
- const u = window.getComputedStyle(l), d = Qt(u), g = d ? Zt(u, s) : void 0, h = Jt(l, s, d);
1012
- if ((!g || !("end" in g)) && (f += h), o.push({ element: l, offset: h, sticky: g }), l = l.offsetParent, Bt(u, l, t))
1013
- break;
1014
- if (l === t) {
1015
- o.push({ element: l, offset: 0 });
1016
- break;
1017
- }
1018
- }
1019
- return o.reverse(), e.map((u) => ({
1020
- ...Gt(
1021
- u,
1022
- { start: f, end: f + a },
1023
- n,
1024
- s,
1025
- r,
1026
- o
1027
- )
1028
- }));
1029
- }
1030
- const Se = 100, en = {
1031
- horizontal: !1,
1032
- observeViewportEntry: !0,
1033
- viewportRootMargin: "7% 7%",
1034
- observeViewportResize: !1,
1035
- observeSourcesResize: !1,
1036
- observeContentResize: !1
1037
- };
1038
- function tn(e, t, n, s) {
1039
- let r = 0;
1040
- return e >= t && e <= n ? r = s ? (e - t) / s : 1 : e > n && (r = 1), r;
1041
- }
1042
- function Ie(e, t) {
1043
- return e === window ? t ? window.document.documentElement.clientWidth : window.document.documentElement.clientHeight : t ? e.clientWidth : e.clientHeight;
1044
- }
1045
- function nn() {
1046
- return {
1047
- viewportWidth: window.document.documentElement.clientWidth,
1048
- viewportHeight: window.document.documentElement.clientHeight
1049
- };
1050
- }
1051
- function sn(e) {
1052
- const t = ze(e, en), n = t.root, s = t.horizontal, r = /* @__PURE__ */ new WeakMap();
1053
- let i = Ie(n, s), o, a, f, l, c;
1054
- const u = [], d = nn();
1055
- if (t.scenes = Object.values(
1056
- // TODO(ameerf): find a polyfill and use groupBy instead of following reduce
1057
- e.scenes.reduce(
1058
- (m, p, v) => {
1059
- const y = p.groupId ? `group-${p.groupId}` : String(v);
1060
- return m[y] ? m[y].push(p) : m[y] = [p], m;
1061
- },
1062
- {}
1063
- )
1064
- ).flatMap((m) => (m.every((p) => p.viewSource && (typeof p.duration == "string" || p.start?.name)) ? (m = H(m, n, i, s, d), (t.observeSourcesResize || t.observeContentResize) && u.push(m)) : m.forEach((p) => {
1065
- p.end == null && (p.end = p.start + p.duration), p.duration == null && (p.duration = p.end - p.start);
1066
- }), m)), t.scenes.forEach((m, p) => {
1067
- m.index = p;
1068
- }), u.length) {
1069
- const m = /* @__PURE__ */ new Map();
1070
- window.ResizeObserver && (f = new window.ResizeObserver(function(p) {
1071
- p.forEach((v) => {
1072
- const y = m.get(v.target), E = H(y, n, i, s, d);
1073
- E.forEach((b, I) => {
1074
- t.scenes[b.index] = E[I];
1075
- }), u.splice(u.indexOf(y), 1, E);
1076
- });
1077
- }), u.forEach((p) => {
1078
- f.observe(p[0].viewSource, { box: "border-box" }), m.set(p[0].viewSource, p);
1079
- }), t.observeContentResize && t.contentRoot && new window.ResizeObserver(be(() => {
1080
- const v = u.map((y) => {
1081
- const E = H(y, n, i, s, d);
1082
- return E.forEach((b, I) => {
1083
- t.scenes[b.index] = E[I];
1084
- }), E;
1085
- });
1086
- u.length = 0, u.push(...v), u.forEach((y) => {
1087
- m.set(y[0].viewSource, y);
1088
- });
1089
- }, Se)).observe(t.contentRoot, { box: "border-box" })), t.observeViewportResize && (l = be(function() {
1090
- i = Ie(n, s);
1091
- const p = u.map((v) => {
1092
- const y = H(v, n, i, s, d);
1093
- return y.forEach((E, b) => {
1094
- t.scenes[E.index] = y[b];
1095
- }), y;
1096
- });
1097
- u.length = 0, u.push(...p), u.forEach((v) => {
1098
- m.set(v[0].viewSource, v);
1099
- });
1100
- }, Se), n === window ? window.addEventListener("resize", l) : window.ResizeObserver && (c = new window.ResizeObserver(l), c.observe(n, { box: "border-box" })));
1101
- }
1102
- t.observeViewportEntry && window.IntersectionObserver && (a = new window.IntersectionObserver(function(m) {
1103
- m.forEach((p) => {
1104
- (r.get(p.target) || []).forEach((v) => {
1105
- v.disabled = !p.isIntersecting;
1106
- });
1107
- });
1108
- }, {
1109
- root: n === window ? window.document : n,
1110
- rootMargin: t.viewportRootMargin,
1111
- threshold: 0
1112
- }), t.scenes.forEach((m) => {
1113
- if (m.viewSource) {
1114
- let p = r.get(m.viewSource);
1115
- p || (p = [], r.set(m.viewSource, p), a.observe(m.viewSource)), p.push(m);
1116
- }
1117
- }));
1118
- function g({ p: m, vp: p }) {
1119
- m = +m.toFixed(1);
1120
- const v = +p.toFixed(4);
1121
- if (m !== o) {
1122
- for (let y of t.scenes)
1123
- if (!y.disabled) {
1124
- const { start: E, end: b, duration: I } = y, L = tn(m, E, b, I);
1125
- y.effect(y, L, v);
1126
- }
1127
- o = m;
1128
- }
1129
- }
1130
- function h() {
1131
- t.scenes.forEach((m) => m.destroy?.()), a && (a.disconnect(), a = null), f && (f.disconnect(), f = null), l && (c ? (c.disconnect(), c = null) : window.removeEventListener("resize", l));
1132
- }
1133
- return {
1134
- tick: g,
1135
- destroy: h
1136
- };
1137
- }
1138
- const rn = {
1139
- transitionActive: !1,
1140
- transitionFriction: 0.9,
1141
- transitionEpsilon: 1,
1142
- velocityActive: !1,
1143
- velocityMax: 1
1144
- };
1145
- class on {
1146
- constructor(t = {}) {
1147
- this.config = ze(t, rn), this.progress = {
1148
- p: 0,
1149
- prevP: 0,
1150
- vp: 0
1151
- }, this.currentProgress = {
1152
- p: 0,
1153
- prevP: 0,
1154
- vp: 0
1155
- }, this._lerpFrameId = 0, this.effect = null;
1156
- const n = !this.config.root || this.config.root === window.document.body;
1157
- 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 || (() => {
1158
- const s = this.config.root;
1159
- this.progress.p = this.config.horizontal ? s.scrollX || s.scrollLeft || 0 : s.scrollY || s.scrollTop || 0;
1160
- }), this._trigger = Yt(() => {
1161
- this._measure?.(), this.tick(!0);
1162
- });
1163
- }
1164
- /**
1165
- * Setup event and effect, and reset progress and frame.
1166
- */
1167
- start() {
1168
- this.setupEffect(), this.setupEvent(), this.resetProgress(), this.tick();
1169
- }
1170
- /**
1171
- * Removes event listener.
1172
- */
1173
- pause() {
1174
- this.removeEvent();
1175
- }
1176
- /**
1177
- * Reset progress in the DOM and inner state to given x and y.
1178
- *
1179
- * @param {Object} [scrollPosition]
1180
- * @param {number} [scrollPosition.x]
1181
- * @param {number} [scrollPosition.y]
1182
- */
1183
- resetProgress(t = {}) {
1184
- const n = this.config.root, s = t.x || t.x === 0 ? t.x : n.scrollX || n.scrollLeft || 0, r = t.y || t.y === 0 ? t.y : n.scrollY || n.scrollTop || 0, i = this.config.horizontal ? s : r;
1185
- this.progress.p = i, this.progress.prevP = i, this.progress.vp = 0, this.config.transitionActive && (this.currentProgress.p = i, this.currentProgress.prevP = i, this.currentProgress.vp = 0), t && this.config.root.scrollTo(s, r);
1186
- }
1187
- /**
1188
- * Handle animation frame work.
1189
- *
1190
- * @param {boolean} [clearLerpFrame] whether to cancel an existing lerp frame
1191
- */
1192
- tick(t) {
1193
- const n = this.config.transitionActive;
1194
- n && this.lerp();
1195
- const s = n ? this.currentProgress : this.progress;
1196
- if (this.config.velocityActive) {
1197
- const r = s.p - s.prevP, i = r < 0 ? -1 : 1;
1198
- s.vp = Math.min(this.config.velocityMax, Math.abs(r)) / this.config.velocityMax * i;
1199
- }
1200
- this.effect.tick(s), n && s.p !== this.progress.p && (t && this._lerpFrameId && window.cancelAnimationFrame(this._lerpFrameId), this._lerpFrameId = window.requestAnimationFrame(() => this.tick())), s.prevP = s.p;
1201
- }
1202
- /**
1203
- * Calculate current progress.
1204
- */
1205
- lerp() {
1206
- this.currentProgress.p = jt(this.currentProgress.p, this.progress.p, +(1 - this.config.transitionFriction).toFixed(3), this.config.transitionEpsilon);
1207
- }
1208
- /**
1209
- * Stop the event and effect, and remove all DOM side-effects.
1210
- */
1211
- destroy() {
1212
- this.pause(), this.removeEffect();
1213
- }
1214
- /**
1215
- * Register to scroll for triggering update.
1216
- */
1217
- setupEvent() {
1218
- this.removeEvent(), this.config.root.addEventListener("scroll", this._trigger);
1219
- }
1220
- /**
1221
- * Remove scroll handler.
1222
- */
1223
- removeEvent() {
1224
- this.config.root.removeEventListener("scroll", this._trigger);
1225
- }
1226
- /**
1227
- * Reset registered effect.
1228
- */
1229
- setupEffect() {
1230
- this.removeEffect(), this.effect = sn(this.config);
1231
- }
1232
- /**
1233
- * Remove registered effect.
1234
- */
1235
- removeEffect() {
1236
- this.effect && this.effect.destroy(), this.effect = null;
1237
- }
1238
- }
1239
- const re = /* @__PURE__ */ new WeakMap();
1240
- let De = () => ({});
1241
- function an(e) {
1242
- De = e;
1243
- }
1244
- function cn(e, t, n, s, { reducedMotion: r }) {
1245
- if (r)
1246
- return;
1247
- const i = {
1248
- trigger: "view-progress",
1249
- element: e
1250
- }, o = x(n);
1251
- let a;
1252
- if ("ViewTimeline" in window) {
1253
- const l = ue(t, o, i);
1254
- l && (l.play(), a = () => {
1255
- l.ready.then(() => {
1256
- l.cancel();
1257
- });
1258
- });
1259
- } else {
1260
- const l = Me(t, o, i);
1261
- if (l) {
1262
- const c = Array.isArray(l) ? l : [l], u = new on({
1263
- viewSource: e,
1264
- scenes: c,
1265
- observeViewportEntry: !1,
1266
- observeViewportResize: !1,
1267
- observeSourcesResize: !0,
1268
- root: document.body,
1269
- ...De()
1270
- });
1271
- a = () => {
1272
- u.destroy();
1273
- }, Promise.all(c.map((d) => d.ready || Promise.resolve())).then(
1274
- () => {
1275
- u.start();
1276
- }
1277
- );
1278
- }
1279
- }
1280
- if (!a) return;
1281
- const f = { source: e, target: t, cleanup: a };
1282
- O(re, e, f), O(re, t, f);
1283
- }
1284
- function fn(e) {
1285
- C(re, e);
1286
- }
1287
- const ln = {
1288
- add: cn,
1289
- remove: fn,
1290
- registerOptionsGetter: an
1291
- }, oe = /* @__PURE__ */ new WeakMap();
1292
- function un(e, t, n, s = !1, r) {
1293
- const i = U(
1294
- e,
1295
- x(t),
1296
- void 0,
1297
- s
1298
- );
1299
- if (!i)
1300
- return null;
1301
- const o = n.type || "alternate";
1302
- let a = !0;
1303
- return (f) => {
1304
- r && !e.matches(r) || (f.type === "mouseenter" || f.type === "focusin" ? o === "alternate" ? a ? (a = !1, i.play()) : i.reverse() : o === "state" ? i.playState !== "finished" && i.play() : (i.progress(0), i.isCSS && i.onFinish(() => {
1305
- S.mutate(() => {
1306
- e.dataset.motionEnter = "done";
1307
- });
1308
- }), i.play()) : (f.type === "mouseleave" || f.type === "focusout") && (o === "alternate" ? i.reverse() : o === "repeat" ? (i.cancel(), S.mutate(() => {
1309
- delete e.dataset.interactEnter;
1310
- })) : o === "state" && i.playState === "running" && i.pause()));
1311
- };
1312
- }
1313
- function dn(e, t, {
1314
- effectId: n,
1315
- listContainer: s,
1316
- listItemSelector: r
1317
- }, i, o) {
1318
- const a = i.method || "toggle", f = a === "toggle", l = !!s;
1319
- return (c) => {
1320
- if (o && !e.matches(o)) return;
1321
- let u;
1322
- if (l && (u = e.closest(
1323
- `${s} > ${r || ""}:has(:scope)`
1324
- )), c.type === "mouseenter" || c.type === "focusin") {
1325
- const d = f ? "add" : a;
1326
- t.toggleEffect(n, d, u);
1327
- } else (c.type === "mouseleave" || c.type === "focusout") && f && t.toggleEffect(n, "remove", u);
1328
- };
1329
- }
1330
- function hn(e, t, n, s = {}, { reducedMotion: r, targetController: i, selectorCondition: o, allowA11yTriggers: a }) {
1331
- let f, l = !1, c = !1;
1332
- if (n.transition || n.transitionProperties ? (f = dn(
1333
- t,
1334
- i,
1335
- n,
1336
- s,
1337
- o
1338
- ), l = !0) : (f = un(
1339
- t,
1340
- n,
1341
- s,
1342
- r,
1343
- o
1344
- ), c = s.type === "once"), !f)
1345
- return;
1346
- const u = (p) => {
1347
- e.contains(p.relatedTarget) || f(p);
1348
- }, d = (p) => {
1349
- e.contains(p.relatedTarget) || f(p);
1350
- }, h = { source: e, target: t, cleanup: () => {
1351
- e.removeEventListener("mouseenter", f), e.removeEventListener("mouseleave", f), a && (e.removeEventListener("focusin", u), e.removeEventListener("focusout", d));
1352
- } };
1353
- O(oe, e, h), O(oe, t, h), a && (e.tabIndex = 0, e.addEventListener("focusin", u, { once: c })), e.addEventListener("mouseenter", f, { passive: !0, once: c }), (l ? (s.method || "toggle") === "toggle" : s.type !== "once") && (e.addEventListener("mouseleave", f, { passive: !0 }), a && e.addEventListener("focusout", d, { once: c }));
1354
- }
1355
- function mn(e) {
1356
- C(oe, e);
1357
- }
1358
- const Oe = {
1359
- add: hn,
1360
- remove: mn
1361
- }, ae = /* @__PURE__ */ new WeakMap();
1362
- function pn(e, t, n, s = !1, r) {
1363
- const i = U(
1364
- e,
1365
- x(t),
1366
- void 0,
1367
- s
1368
- );
1369
- if (!i)
1370
- return null;
1371
- let o = !0;
1372
- const a = n.type || "alternate";
1373
- return (f) => {
1374
- r && !e.matches(r) || (a === "alternate" ? o ? (o = !1, i.play()) : i.reverse() : a === "state" ? o ? (o = !1, i.play()) : i.playState === "running" ? i.pause() : i.playState !== "finished" && i.play() : (i.progress(0), i.isCSS && i.onFinish(() => {
1375
- S.mutate(() => {
1376
- e.dataset.interactEnter = "done";
1377
- });
1378
- }), i.play()));
1379
- };
1380
- }
1381
- function gn(e, t, {
1382
- effectId: n,
1383
- listContainer: s,
1384
- listItemSelector: r
1385
- }, i, o) {
1386
- const a = !!s;
1387
- return (f) => {
1388
- if (o && !e.matches(o)) return;
1389
- let l;
1390
- a && (l = e.closest(
1391
- `${s} > ${r || ""}:has(:scope)`
1392
- )), t.toggleEffect(n, i.method || "toggle", l);
1393
- };
1394
- }
1395
- function vn(e, t, n, s = {}, { reducedMotion: r, targetController: i, selectorCondition: o, allowA11yTriggers: a }) {
1396
- let f, l = !1;
1397
- if (n.transition || n.transitionProperties ? f = gn(
1398
- t,
1399
- i,
1400
- n,
1401
- s,
1402
- o
1403
- ) : (f = pn(
1404
- t,
1405
- n,
1406
- s,
1407
- r,
1408
- o
1409
- ), l = s.type === "once"), !f)
1410
- return;
1411
- const c = (h) => {
1412
- h.pointerType && f(h);
1413
- }, u = (h) => {
1414
- h.code === "Space" ? (h.preventDefault(), f(h)) : h.code === "Enter" && f(h);
1415
- }, g = { source: e, target: t, cleanup: () => {
1416
- e.removeEventListener("click", c), a && e.removeEventListener("keydown", u);
1417
- } };
1418
- O(ae, e, g), O(ae, t, g), e.addEventListener("click", c, { passive: !0, once: l }), a && (e.tabIndex = 0, e.addEventListener("keydown", u, { once: l }));
1419
- }
1420
- function yn(e) {
1421
- C(ae, e);
1422
- }
1423
- const _e = {
1424
- add: vn,
1425
- remove: yn
1426
- };
1427
- function ke(e, t, n) {
1428
- return Math.min(Math.max(e, n), t);
1429
- }
1430
- function Te(e) {
1431
- let t = !1;
1432
- return function() {
1433
- if (!t)
1434
- return t = !0, window.requestAnimationFrame(() => {
1435
- t = !1, e();
1436
- });
1437
- };
1438
- }
1439
- function wn(e) {
1440
- let t = e, n = 0, s = 0;
1441
- if (t.offsetParent)
1442
- do
1443
- n += t.offsetLeft, s += t.offsetTop, t = t.offsetParent;
1444
- while (t);
1445
- return {
1446
- left: n,
1447
- top: s,
1448
- width: e.offsetWidth,
1449
- height: e.offsetHeight
1450
- };
1451
- }
1452
- function En() {
1453
- const e = window.devicePixelRatio;
1454
- let t = !1;
1455
- if (e === 1)
1456
- return !1;
1457
- document.body.addEventListener("pointerdown", (s) => {
1458
- t = s.offsetX !== 10;
1459
- }, { once: !0 });
1460
- const n = new PointerEvent("pointerdown", {
1461
- clientX: 10
1462
- });
1463
- return document.body.dispatchEvent(n), t;
1464
- }
1465
- function bn() {
1466
- return new Promise((e) => {
1467
- const t = window.scrollY;
1468
- let n = !1, s;
1469
- function r() {
1470
- document.body.addEventListener("pointerdown", (a) => {
1471
- s === void 0 ? s = a.offsetY : n = a.offsetY === s;
1472
- }, { once: !0 });
1473
- const o = new PointerEvent("pointerdown", {
1474
- clientY: 500
1475
- });
1476
- document.body.dispatchEvent(o);
1477
- }
1478
- function i() {
1479
- window.scrollY !== t && (window.removeEventListener("scroll", i), r(), e(n));
1480
- }
1481
- r(), window.addEventListener("scroll", i), window.scrollY > 0 && window.scrollBy(0, -1);
1482
- });
1483
- }
1484
- function Sn(e) {
1485
- bn().then((t) => {
1486
- e.fixRequired = t, t && (window.addEventListener("scroll", e.scrollHandler), e.scrollHandler());
1487
- });
1488
- }
1489
- let q = 0;
1490
- const Y = /* @__PURE__ */ new Set();
1491
- function In() {
1492
- const e = (n) => {
1493
- for (let s of n.changedTouches)
1494
- Y.add(s.identifier);
1495
- }, t = (n) => {
1496
- for (let s of n.changedTouches)
1497
- Y.delete(s.identifier);
1498
- };
1499
- return document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("touchend", t, { passive: !0 }), function() {
1500
- Y.clear(), document.removeEventListener("touchstart", e), document.removeEventListener("touchend", t);
1501
- };
1502
- }
1503
- function On(e, t) {
1504
- if ("onscrollend" in window)
1505
- return e.addEventListener("scrollend", t), function() {
1506
- e.removeEventListener("scrollend", t);
1507
- };
1508
- let n = 0, s;
1509
- q || (s = In()), q += 1;
1510
- function r(i) {
1511
- clearTimeout(n), n = setTimeout(() => {
1512
- Y.size ? setTimeout(r, 100) : (t(i), n = 0);
1513
- }, 100);
1514
- }
1515
- return e.addEventListener("scroll", r), function() {
1516
- e.removeEventListener("scroll", r), q -= 1, q || s();
1517
- };
1518
- }
1519
- function _n(e, t, n) {
1520
- return {
1521
- x(s) {
1522
- const r = e.left - n.x + e.width / 2, i = r >= t.width / 2, o = (i ? r : t.width - r) * 2, a = i ? 0 : r - o / 2;
1523
- return (s - a) / o;
1524
- },
1525
- y(s) {
1526
- const r = e.top - n.y + e.height / 2, i = r >= t.height / 2, o = (i ? r : t.height - r) * 2, a = i ? 0 : r - o / 2;
1527
- return (s - a) / o;
1528
- }
1529
- };
1530
- }
1531
- function kn(e, t) {
1532
- this.x = window.scrollX, this.y = window.scrollY, requestAnimationFrame(() => e && e(t));
1533
- }
1534
- function Tn(e) {
1535
- e.rect.width = window.document.documentElement.clientWidth, e.rect.height = window.document.documentElement.clientHeight;
1536
- }
1537
- function xn(e) {
1538
- const t = new ResizeObserver((n) => {
1539
- n.forEach((s) => {
1540
- e.rect.width = s.borderBoxSize[0].inlineSize, e.rect.height = s.borderBoxSize[0].blockSize;
1541
- });
1542
- });
1543
- return t.observe(e.root, { box: "border-box" }), t;
1544
- }
1545
- function Cn(e) {
1546
- let t = !1, n = { x: e.rect.width / 2, y: e.rect.height / 2, vx: 0, vy: 0 }, s, r, i, o, a;
1547
- const f = { x: 0, y: 0 };
1548
- e.scenes.forEach((c) => {
1549
- c.target && c.centeredToTarget && (c.transform = _n(wn(c.target), e.rect, f), t = !0), e.root ? r = xn(e) : (i = Tn.bind(null, e), window.addEventListener("resize", i));
1550
- }), s = function(c) {
1551
- for (let u of e.scenes)
1552
- if (!u.disabled) {
1553
- const d = u.transform?.x(c.x) || c.x / e.rect.width, g = u.transform?.y(c.y) || c.y / e.rect.height, h = +ke(0, 1, d).toPrecision(4), m = +ke(0, 1, g).toPrecision(4), p = { x: c.vx, y: c.vy };
1554
- e.allowActiveEvent && (c.active = d <= 1 && g <= 1 && d >= 0 && g >= 0), u.effect(u, { x: h, y: m }, p, c.active);
1555
- }
1556
- Object.assign(n, c);
1557
- }, t && (o = kn.bind(f, s, n), a = On(document, o));
1558
- function l() {
1559
- e.scenes.forEach((c) => c.destroy?.()), a?.(), r ? (r.disconnect(), r = null) : (window.removeEventListener("resize", i), i = null), s = null, n = null;
1560
- }
1561
- return {
1562
- tick: s,
1563
- destroy: l
1564
- };
1565
- }
1566
- const Ln = 1e3 / 60 * 3;
1567
- let z;
1568
- function An() {
1569
- k.x = window.scrollX, k.y = window.scrollY;
1570
- }
1571
- const k = { x: 0, y: 0, scrollHandler: An, fixRequired: void 0 };
1572
- class Pn {
1573
- constructor(t = {}) {
1574
- this.config = { ...t }, this.effect = null, this._nextTick = null, this._nextTransitionTick = null, this._startTime = 0;
1575
- let n;
1576
- this.config.transitionDuration ? n = this.config.noThrottle ? () => this.transition() : Te(() => this.transition()) : n = this.config.noThrottle ? () => (this.tick(), null) : Te(() => {
1577
- this.tick();
1578
- }), this.config.rect = this.config.root ? {
1579
- width: this.config.root.offsetWidth,
1580
- height: this.config.root.offsetHeight
1581
- } : {
1582
- width: window.document.documentElement.clientWidth,
1583
- height: window.document.documentElement.clientHeight
1584
- }, this.progress = {
1585
- x: this.config.rect.width / 2,
1586
- y: this.config.rect.height / 2,
1587
- vx: 0,
1588
- vy: 0
1589
- }, this.previousProgress = { ...this.progress }, this.currentProgress = null;
1590
- const s = (r) => {
1591
- const i = this.config.root ? r.offsetX : r.x, o = this.config.root ? r.offsetY : r.y;
1592
- this.progress.vx = i - this.progress.x, this.progress.vy = o - this.progress.y, this.progress.x = i, this.progress.y = o, this._nextTick = n();
1593
- };
1594
- if (this._pointerLeave = () => {
1595
- this.progress.active = !1, this.progress.vx = 0, this.progress.vy = 0, this._nextTick = n();
1596
- }, this._pointerEnter = () => {
1597
- this.progress.active = !0, this._nextTick = n();
1598
- }, this.config.root) {
1599
- z = typeof z == "boolean" ? z : En();
1600
- const r = z ? window.devicePixelRatio : 1;
1601
- typeof k.fixRequired > "u" && Sn(k), this._measure = (i) => {
1602
- if (i.target !== this.config.root) {
1603
- const o = new PointerEvent("pointermove", {
1604
- bubbles: !0,
1605
- cancelable: !0,
1606
- clientX: i.x * r + k.x,
1607
- clientY: i.y * r + k.y
1608
- });
1609
- i.stopPropagation(), this.config.root.dispatchEvent(o);
1610
- } else
1611
- s(i);
1612
- };
1613
- } else
1614
- this._measure = s;
1615
- }
1616
- /**
1617
- * Setup event and effect, and reset progress and frame.
1618
- */
1619
- start() {
1620
- this.setupEffect(), this.setupEvent();
1621
- }
1622
- /**
1623
- * Removes event listener.
1624
- */
1625
- pause() {
1626
- this.removeEvent();
1627
- }
1628
- /**
1629
- * Handle animation frame work.
1630
- */
1631
- tick() {
1632
- this.effect.tick(this.progress);
1633
- }
1634
- /**
1635
- * Starts a transition from the previous progress to the current progress.
1636
- *
1637
- * @returns {number} the requestAnimationFrame id for the transition tick.
1638
- */
1639
- transition() {
1640
- const t = this.config.transitionDuration, n = this.config.transitionEasing || ((o) => o), s = performance.now();
1641
- let r = !1;
1642
- const i = (o) => {
1643
- const a = (o - this._startTime) / t, f = n(Math.min(1, a));
1644
- r && (this.progress.vx = 0, this.progress.vy = 0, r = !1), this.currentProgress = Object.entries(this.progress).reduce((l, [c, u]) => (c === "active" ? l[c] = u : l[c] = this.previousProgress[c] + (u - this.previousProgress[c]) * f, l), this.currentProgress || {}), a < 1 && (this._nextTransitionTick = requestAnimationFrame(i), r = o - this._startTime > Ln), this.effect.tick(this.currentProgress);
1645
- };
1646
- return this._startTime ? (this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick), Object.assign(this.previousProgress, this.currentProgress), this._startTime = s, i(s)) : this._startTime = s, this._nextTransitionTick;
1647
- }
1648
- /**
1649
- * Stop the event and effect, and remove all DOM side effects.
1650
- */
1651
- destroy() {
1652
- this.pause(), this.removeEffect(), this._nextTick && cancelAnimationFrame(this._nextTick), this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick);
1653
- }
1654
- /**
1655
- * Register to pointermove for triggering update.
1656
- */
1657
- setupEvent() {
1658
- this.removeEvent();
1659
- const t = this.config.root || window;
1660
- t.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.eventSource && this.config.eventSource.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.allowActiveEvent && (t.addEventListener("pointerleave", this._pointerLeave, { passive: !0 }), t.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 })));
1661
- }
1662
- /**
1663
- * Remove pointermove handler.
1664
- */
1665
- removeEvent() {
1666
- const t = this.config.root || window;
1667
- t.removeEventListener("pointermove", this._measure), this.config.eventSource && this.config.eventSource.removeEventListener("pointermove", this._measure), this.config.allowActiveEvent && (t.removeEventListener("pointerleave", this._pointerLeave), t.removeEventListener("pointerenter", this._pointerEnter), this.config.eventSource && (this.config.eventSource.removeEventListener("pointerleave", this._pointerLeave), this.config.eventSource.removeEventListener("pointerenter", this._pointerEnter)));
1668
- }
1669
- /**
1670
- * Reset registered effect.
1671
- */
1672
- setupEffect() {
1673
- this.removeEffect(), this.effect = Cn(this.config);
1674
- }
1675
- /**
1676
- * Remove registered effect.
1677
- */
1678
- removeEffect() {
1679
- this.effect && this.effect.destroy(), this.effect = null;
1680
- }
1681
- }
1682
- const ce = /* @__PURE__ */ new WeakMap();
1683
- let Ne = () => ({});
1684
- function $n(e) {
1685
- Ne = e;
1686
- }
1687
- function Rn(e, t, n, s = {}, { reducedMotion: r }) {
1688
- if (r)
1689
- return;
1690
- const i = {
1691
- trigger: "pointer-move",
1692
- element: e,
1693
- axis: s.axis ?? "y"
1694
- }, o = Me(t, x(n), i);
1695
- if (o) {
1696
- const a = Array.isArray(o) ? o : [o], f = new Pn({
1697
- root: s.hitArea === "self" ? e : void 0,
1698
- scenes: a,
1699
- ...Ne()
1700
- }), c = { source: e, target: t, cleanup: () => {
1701
- f.destroy();
1702
- } };
1703
- O(ce, e, c), O(ce, t, c), Promise.all(
1704
- a.map((u) => u.ready || Promise.resolve())
1705
- ).then(() => {
1706
- f.start();
1707
- });
1708
- }
1709
- }
1710
- function Mn(e) {
1711
- C(ce, e);
1712
- }
1713
- const Fn = {
1714
- add: Rn,
1715
- remove: Mn,
1716
- registerOptionsGetter: $n
1717
- }, fe = /* @__PURE__ */ new WeakMap();
1718
- function Hn(e, t, n, s, { reducedMotion: r, selectorCondition: i }) {
1719
- const o = U(
1720
- t,
1721
- x(n),
1722
- void 0,
1723
- r
1724
- );
1725
- if (!o)
1726
- return;
1727
- const a = () => {
1728
- i && !t.matches(i) || o.play();
1729
- }, l = { source: e, target: t, cleanup: () => {
1730
- o.cancel(), e.removeEventListener("animationend", a);
1731
- } };
1732
- O(fe, e, l), O(fe, t, l), e.addEventListener("animationend", a);
1733
- }
1734
- function qn(e) {
1735
- C(fe, e);
1736
- }
1737
- const zn = {
1738
- add: Hn,
1739
- remove: qn
1740
- };
1741
- function xe(e) {
1742
- return {
1743
- add: (t, n, s, r, i) => e.add(t, n, s, r, {
1744
- ...i,
1745
- allowA11yTriggers: !0
1746
- }),
1747
- remove: e.remove
1748
- };
1749
- }
1750
- const $ = {
1751
- viewEnter: Ee,
1752
- hover: Oe,
1753
- click: _e,
1754
- pageVisible: Ee,
1755
- animationEnd: zn,
1756
- viewProgress: ln,
1757
- pointerMove: Fn,
1758
- activate: xe(_e),
1759
- interest: xe(Oe)
1760
- };
1761
- function Dn(e) {
1762
- return e.replace(/\[([-\w]+)]/g, "[]");
1763
- }
1764
- class w {
1765
- static defineInteractElement;
1766
- dataCache;
1767
- addedInteractions;
1768
- mediaQueryListeners;
1769
- listInteractionsCache;
1770
- controllers;
1771
- static forceReducedMotion = !1;
1772
- static allowA11yTriggers = !0;
1773
- static instances = [];
1774
- static controllerCache = /* @__PURE__ */ new Map();
1775
- constructor() {
1776
- this.dataCache = { effects: {}, conditions: {}, interactions: {} }, this.addedInteractions = {}, this.mediaQueryListeners = /* @__PURE__ */ new Map(), this.listInteractionsCache = {}, this.controllers = /* @__PURE__ */ new Set();
1777
- }
1778
- init(t, n) {
1779
- if (typeof window > "u" || !window.customElements)
1780
- return;
1781
- const s = n?.useCutsomElement ?? !!w.defineInteractElement;
1782
- this.dataCache = Vn(t, s);
1783
- const r = w.defineInteractElement?.();
1784
- s && r === !1 ? document.querySelectorAll("interact-element").forEach((i) => {
1785
- i.connect();
1786
- }) : w.controllerCache.forEach(
1787
- (i, o) => i.connect(o)
1788
- );
1789
- }
1790
- destroy() {
1791
- for (const t of this.controllers)
1792
- t.disconnect();
1793
- for (const [, t] of this.mediaQueryListeners.entries())
1794
- t.mql.removeEventListener("change", t.handler);
1795
- this.mediaQueryListeners.clear(), this.addedInteractions = {}, this.listInteractionsCache = {}, this.controllers.clear(), this.dataCache = { effects: {}, conditions: {}, interactions: {} }, w.instances.splice(w.instances.indexOf(this), 1);
1796
- }
1797
- setController(t, n) {
1798
- this.controllers.add(n), w.setController(t, n);
1799
- }
1800
- deleteController(t, n = !1) {
1801
- const s = w.controllerCache.get(t);
1802
- this.clearInteractionStateForKey(t), this.clearMediaQueryListenersForKey(t), s && n && (this.controllers.delete(s), w.deleteController(t));
1803
- }
1804
- has(t) {
1805
- return !!this.get(t);
1806
- }
1807
- get(t) {
1808
- const n = Dn(t);
1809
- return this.dataCache.interactions[n];
1810
- }
1811
- clearMediaQueryListenersForKey(t) {
1812
- for (const [n, s] of this.mediaQueryListeners.entries())
1813
- s.key === t && (s.mql.removeEventListener("change", s.handler), this.mediaQueryListeners.delete(n));
1814
- }
1815
- clearInteractionStateForKey(t) {
1816
- (this.get(t)?.interactionIds || []).forEach((s) => {
1817
- const r = R(s, t);
1818
- delete this.addedInteractions[r];
1819
- });
1820
- }
1821
- setupMediaQueryListener(t, n, s, r) {
1822
- this.mediaQueryListeners.has(t) || (n.addEventListener("change", r), this.mediaQueryListeners.set(t, {
1823
- mql: n,
1824
- handler: r,
1825
- key: s
1826
- }));
1827
- }
1828
- static create(t, n) {
1829
- const s = new w();
1830
- return w.instances.push(s), s.init(t, n), s;
1831
- }
1832
- static destroy() {
1833
- w.controllerCache.forEach((t) => {
1834
- t.disconnect();
1835
- }), w.instances.length = 0, w.controllerCache.clear();
1836
- }
1837
- static setup(t) {
1838
- t.scrollOptionsGetter && $.viewProgress.registerOptionsGetter?.(
1839
- t.scrollOptionsGetter
1840
- ), t.pointerOptionsGetter && $.pointerMove.registerOptionsGetter?.(
1841
- t.pointerOptionsGetter
1842
- ), t.viewEnter && $.viewEnter.setOptions(
1843
- t.viewEnter
1844
- ), t.allowA11yTriggers !== void 0 && (w.allowA11yTriggers = t.allowA11yTriggers);
1845
- }
1846
- static getInstance(t) {
1847
- return w.instances.find((n) => n.has(t));
1848
- }
1849
- static getController(t) {
1850
- return t ? w.controllerCache.get(t) : void 0;
1851
- }
1852
- static setController(t, n) {
1853
- w.controllerCache.set(t, n);
1854
- }
1855
- static deleteController(t) {
1856
- w.controllerCache.delete(t);
1857
- }
1858
- static registerEffects = kt;
1859
- }
1860
- let Nn = 0;
1861
- function X(e, {
1862
- asCombinator: t = !1,
1863
- addItemFilter: n = !1,
1864
- useFirstChild: s = !1
1865
- } = {}) {
1866
- if (e.listContainer) {
1867
- const r = `${n && e.listItemSelector ? ` > ${e.listItemSelector}` : ""}`;
1868
- return e.selector ? `${e.listContainer}${r} ${e.selector}` : `${e.listContainer}${r || " > *"}`;
1869
- } else if (e.selector)
1870
- return e.selector;
1871
- return s ? t ? "> :first-child" : ":scope > :first-child" : "";
1872
- }
1873
- function Vn(e, t = !1) {
1874
- const n = e.conditions || {}, s = {};
1875
- return e.interactions?.forEach((r) => {
1876
- const i = r.key, o = ++Nn, { effects: a, ...f } = r;
1877
- if (!i) {
1878
- console.error(`Interaction ${o} is missing a key for source element.`);
1879
- return;
1880
- }
1881
- s[i] || (s[i] = {
1882
- triggers: [],
1883
- effects: {},
1884
- interactionIds: /* @__PURE__ */ new Set(),
1885
- selectors: /* @__PURE__ */ new Set()
1886
- });
1887
- const l = Array.from(a);
1888
- l.reverse();
1889
- const c = { ...f, effects: l };
1890
- s[i].triggers.push(c), s[i].selectors.add(
1891
- X(c, { useFirstChild: t })
1892
- );
1893
- const u = c.listContainer;
1894
- l.forEach((d) => {
1895
- let g = d.key;
1896
- if (!g && d.effectId) {
1897
- const p = e.effects[d.effectId];
1898
- p && (g = p.key);
1899
- }
1900
- d.effectId || (d.effectId = Mt()), g = g || i, d.key = g;
1901
- const h = d.effectId;
1902
- if (u && d.listContainer && (g !== i || d.listContainer !== u))
1903
- return;
1904
- const m = `${g}::${h}::${o}`;
1905
- d.interactionId = m, s[i].interactionIds.add(m), g !== i && (s[g] ? s[g].effects[m] || (s[g].effects[m] = [], s[g].interactionIds.add(m)) : s[g] = {
1906
- triggers: [],
1907
- effects: {
1908
- [m]: []
1909
- },
1910
- interactionIds: /* @__PURE__ */ new Set(),
1911
- selectors: /* @__PURE__ */ new Set()
1912
- }, s[g].effects[m].push({ ...f, effect: d }), s[g].selectors.add(X(d, { useFirstChild: t })));
1913
- });
1914
- }), {
1915
- effects: e.effects || {},
1916
- conditions: n,
1917
- interactions: s
1918
- };
1919
- }
1920
- function Ce(e, t, n) {
1921
- if (e.listContainer) {
1922
- const s = t.querySelector(e.listContainer);
1923
- return s ? e.selector ? Array.from(s.querySelectorAll(e.selector)) : Array.from(s.children) : (console.warn(`Interact: No container found for list container "${e.listContainer}"`), []);
1924
- }
1925
- if (e.selector) {
1926
- const s = t.querySelectorAll(e.selector);
1927
- if (s.length > 0)
1928
- return Array.from(s);
1929
- console.warn(`Interact: No elements found for selector "${e.selector}"`);
1930
- }
1931
- return n ? t.firstElementChild : t;
1932
- }
1933
- function Le(e, t) {
1934
- return t.map((n) => e.selector ? n.querySelector(e.selector) : n).filter(Boolean);
1935
- }
1936
- function Ve(e, t, n, s, r, i, o, a) {
1937
- return [
1938
- o ? Le(e, o) : Ce(e, n, s),
1939
- a ? Le(t, a) : Ce(t, r, i)
1940
- ];
1941
- }
1942
- function We(e, t, n, s, r, i, o) {
1943
- const a = Array.isArray(s), f = Array.isArray(r);
1944
- a ? s.forEach((l, c) => {
1945
- const u = f ? r[c] : r;
1946
- u && Ae(
1947
- e,
1948
- l,
1949
- t.trigger,
1950
- u,
1951
- n,
1952
- t.params,
1953
- i,
1954
- o
1955
- );
1956
- }) : (f ? r : [r]).forEach((c) => {
1957
- Ae(
1958
- e,
1959
- s,
1960
- t.trigger,
1961
- c,
1962
- n,
1963
- t.params,
1964
- i,
1965
- o
1966
- );
1967
- });
1968
- }
1969
- function je(e, t, n, s, r) {
1970
- const i = {}, o = [];
1971
- s.effects.forEach((a) => {
1972
- const f = a.effectId, l = {
1973
- ...n.dataCache.effects[f] || {},
1974
- ...a,
1975
- effectId: f
1976
- }, c = l.key, u = R(a.interactionId, e);
1977
- if (i[u] || n.addedInteractions[u] && !r)
1978
- return;
1979
- const d = M(l.conditions || [], n.dataCache.conditions);
1980
- if (d && n.setupMediaQueryListener(u, d, e, () => {
1981
- t.update();
1982
- }), !d || d.matches) {
1983
- i[u] = !0;
1984
- const g = c && R(c, e);
1985
- let h;
1986
- if (g) {
1987
- if (h = w.getController(g), !h)
1988
- return;
1989
- l.listContainer && h.watchChildList(l.listContainer);
1990
- } else
1991
- h = t;
1992
- const [m, p] = Ve(
1993
- s,
1994
- l,
1995
- t.element,
1996
- t.useFirstChild,
1997
- h.element,
1998
- h.useFirstChild,
1999
- r
2000
- );
2001
- if (!m || !p)
2002
- return;
2003
- n.addedInteractions[u] = !0;
2004
- const v = g || s.key, y = G(
2005
- l.conditions || [],
2006
- n.dataCache.conditions
2007
- );
2008
- o.push([
2009
- v,
2010
- s,
2011
- l,
2012
- m,
2013
- p,
2014
- y,
2015
- h.useFirstChild
2016
- ]);
2017
- }
2018
- }), o.reverse().forEach((a) => {
2019
- We(...a);
2020
- });
2021
- }
2022
- function Ye(e, t, n, s, r) {
2023
- const i = n.get(e)?.effects || {}, o = Object.keys(i), a = [];
2024
- return o.forEach((f) => {
2025
- const l = R(f, e);
2026
- if (n.addedInteractions[l] && !r)
2027
- return;
2028
- i[f].some(({ effect: u, ...d }) => {
2029
- const g = M(
2030
- d.conditions || [],
2031
- n.dataCache.conditions
2032
- );
2033
- if (g && !g.matches)
2034
- return !1;
2035
- const h = u.effectId, m = {
2036
- ...n.dataCache.effects[h] || {},
2037
- ...u,
2038
- effectId: h
2039
- };
2040
- if (s && m.listContainer !== s)
2041
- return !1;
2042
- const p = M(m.conditions || [], n.dataCache.conditions);
2043
- if (p && n.setupMediaQueryListener(l, p, e, () => {
2044
- t.update();
2045
- }), !p || p.matches) {
2046
- const v = d.key && R(d.key, e), y = w.getController(v);
2047
- if (!y)
2048
- return !0;
2049
- m.listContainer && t.watchChildList(m.listContainer);
2050
- const [E, b] = Ve(
2051
- d,
2052
- m,
2053
- y.element,
2054
- y.useFirstChild,
2055
- t.element,
2056
- t.useFirstChild,
2057
- void 0,
2058
- r
2059
- );
2060
- if (!E || !b)
2061
- return !0;
2062
- n.addedInteractions[l] = !0;
2063
- const I = G(
2064
- m.conditions || [],
2065
- n.dataCache.conditions
2066
- );
2067
- return a.push([
2068
- e,
2069
- d,
2070
- m,
2071
- E,
2072
- b,
2073
- I,
2074
- t.useFirstChild
2075
- ]), !0;
2076
- }
2077
- return !1;
2078
- });
2079
- }), a.reverse().forEach((f) => {
2080
- We(...f);
2081
- }), o.length > 0;
2082
- }
2083
- function Ae(e, t, n, s, r, i, o, a) {
2084
- let f;
2085
- if (r.transition || r.transitionProperties) {
2086
- const l = {
2087
- key: e,
2088
- effectId: r.effectId,
2089
- transition: r.transition,
2090
- properties: r.transitionProperties,
2091
- childSelector: X(r, {
2092
- asCombinator: !0,
2093
- addItemFilter: !0,
2094
- useFirstChild: a
2095
- }),
2096
- selectorCondition: o
2097
- };
2098
- if (f = w.getController(e), !f)
2099
- return;
2100
- f.renderStyle(Ft(l));
2101
- }
2102
- $[n]?.add(t, s, r, i, {
2103
- reducedMotion: w.forceReducedMotion,
2104
- targetController: f,
2105
- selectorCondition: o,
2106
- allowA11yTriggers: w.allowA11yTriggers
2107
- });
2108
- }
2109
- function Wn(e) {
2110
- const t = e.key, n = w.getInstance(t);
2111
- if (!n)
2112
- return console.warn(`No instance found for key: ${t}`), w.setController(t, e), !1;
2113
- const { triggers: s = [] } = n?.get(t) || {}, r = s.length > 0;
2114
- n.setController(t, e), s.forEach((o, a) => {
2115
- const f = M(o.conditions, n.dataCache.conditions);
2116
- if (f) {
2117
- const l = `${t}::trigger::${a}`;
2118
- n.setupMediaQueryListener(l, f, t, () => {
2119
- e.update();
2120
- });
2121
- }
2122
- (!f || f.matches) && (o.listContainer && e.watchChildList(o.listContainer), je(t, e, n, o));
2123
- });
2124
- let i = !1;
2125
- return n && (i = Ye(t, e, n)), r || i;
2126
- }
2127
- function jn(e, t, n) {
2128
- const s = e.key, r = w.getInstance(s);
2129
- if (r) {
2130
- const { triggers: i = [] } = r?.get(s) || {};
2131
- i.forEach((o, a) => {
2132
- if (o.listContainer !== t)
2133
- return;
2134
- const f = M(o.conditions, r.dataCache.conditions);
2135
- if (f) {
2136
- const l = `${s}::listTrigger::${t}::${a}`;
2137
- r.setupMediaQueryListener(l, f, s, () => {
2138
- e.update();
2139
- });
2140
- }
2141
- (!f || f.matches) && je(s, e, r, o, n);
2142
- }), Ye(s, e, r, t, n);
2143
- }
2144
- }
2145
- function Yn(e, t = !1) {
2146
- const n = e.key, s = w.getInstance(n);
2147
- if (!s)
2148
- return;
2149
- const r = [...s.get(n)?.selectors.values() || []].filter(Boolean).join(",");
2150
- let i;
2151
- r ? (i = [...e.element.querySelectorAll(r)], e.useFirstChild || i.push(e.element)) : i = [e.element], Ke(i), s.deleteController(n, t);
2152
- }
2153
- function Ke(e) {
2154
- const t = Object.values($);
2155
- for (const n of e)
2156
- for (const s of t)
2157
- s.remove(n);
2158
- }
2159
- const se = "interactEffect";
2160
- class Kn {
2161
- element;
2162
- key;
2163
- connected;
2164
- sheet;
2165
- useFirstChild;
2166
- _observers;
2167
- constructor(t, n, s) {
2168
- this.element = t, this.key = n, this.connected = !1, this.sheet = null, this._observers = /* @__PURE__ */ new WeakMap(), this.useFirstChild = s?.useFirstChild ?? !1;
2169
- }
2170
- connect(t) {
2171
- if (this.connected)
2172
- return;
2173
- const n = this.element.dataset.interactKey;
2174
- if (t = t || this.key || n, !t) {
2175
- console.warn("Interact: No key provided");
2176
- return;
2177
- }
2178
- n !== t && (n && console.warn(
2179
- `Interact: Key mismatch between element ${n} and parameter ${t}, updating element key`
2180
- ), this.element.dataset.interactKey = t), this.key = t, this.connected = Wn(this);
2181
- }
2182
- disconnect({ removeFromCache: t = !1 } = {}) {
2183
- if ((this.key || this.element.dataset.interactKey) && Yn(this, t), this.sheet) {
2184
- const s = document.adoptedStyleSheets.indexOf(this.sheet);
2185
- document.adoptedStyleSheets.splice(s, 1);
2186
- }
2187
- this._observers = /* @__PURE__ */ new WeakMap(), this.sheet = null, this.connected = !1;
2188
- }
2189
- update() {
2190
- this.disconnect(), this.connect();
2191
- }
2192
- renderStyle(t) {
2193
- if (!this.sheet)
2194
- this.sheet = new CSSStyleSheet(), this.sheet.replaceSync(t.join(`
2195
- `)), document.adoptedStyleSheets.push(this.sheet);
2196
- else {
2197
- let n = this.sheet.cssRules.length;
2198
- for (const s of t)
2199
- try {
2200
- this.sheet.insertRule(s, n), n++;
2201
- } catch (r) {
2202
- console.error(r);
2203
- }
2204
- }
2205
- }
2206
- toggleEffect(t, n, s, r) {
2207
- if (s === null)
2208
- return;
2209
- if (!r && this.element.toggleEffect) {
2210
- this.element.toggleEffect(t, n, s);
2211
- return;
2212
- }
2213
- const i = new Set(
2214
- this.element.dataset[se]?.split(" ") || []
2215
- );
2216
- n === "toggle" ? i.has(t) ? i.delete(t) : i.add(t) : n === "add" ? i.add(t) : n === "remove" ? i.delete(t) : n === "clear" && i.clear(), (s || this.element).dataset[se] = Array.from(i).join(" ");
2217
- }
2218
- getActiveEffects() {
2219
- const n = (this.element.dataset[se] || "").trim();
2220
- return n ? n.split(/\s+/) : [];
2221
- }
2222
- watchChildList(t) {
2223
- const n = this.element.querySelector(t);
2224
- if (n) {
2225
- let s = this._observers.get(n);
2226
- s || (s = new MutationObserver(this._childListChangeHandler.bind(this, t)), this._observers.set(n, s), s.observe(n, { childList: !0 }));
2227
- }
2228
- }
2229
- _childListChangeHandler(t, n) {
2230
- const s = this.key || this.element.dataset.interactKey, r = [], i = [];
2231
- n.forEach((o) => {
2232
- o.removedNodes.forEach((a) => {
2233
- a instanceof HTMLElement && r.push(a);
2234
- }), o.addedNodes.forEach((a) => {
2235
- a instanceof HTMLElement && i.push(a);
2236
- });
2237
- }), Ke(r), s && jn(this, t, i);
2238
- }
2239
- }
2240
- function Un(e, t) {
2241
- new Kn(e, t).connect();
2242
- }
2243
- function Jn(e) {
2244
- const t = w.getController(e);
2245
- t && t.disconnect({ removeFromCache: !0 });
2246
- }
2247
- const Gn = (e, t, n, s) => {
2248
- let i = `[data-interact-key="${e.replace(/"/g, "'")}"]`;
2249
- const o = X(t, { asCombinator: !0, useFirstChild: s });
2250
- return o && (i = `${i} ${o}`), n && (i = V(i, n)), i;
2251
- };
2252
- function Zn(e, t = !1) {
2253
- const n = [], s = /* @__PURE__ */ new Set();
2254
- return e.interactions.forEach(
2255
- ({
2256
- key: r,
2257
- selector: i,
2258
- listContainer: o,
2259
- listItemSelector: a,
2260
- trigger: f,
2261
- params: l,
2262
- effects: c,
2263
- conditions: u
2264
- }) => {
2265
- if (f === "viewEnter") {
2266
- const g = l;
2267
- (!g?.type || g.type === "once") && c.forEach((m) => {
2268
- const p = m?.effectId && e.effects[m.effectId] || m, {
2269
- key: v,
2270
- selector: y,
2271
- listContainer: E,
2272
- listItemSelector: b,
2273
- conditions: I
2274
- } = p;
2275
- if (!(!v || v === r) || !(!y && !i || y === i) || !(!E && !o || E === o) || !(!b && !a || b === a)) return;
2276
- const de = e.conditions || {}, he = G(
2277
- I,
2278
- de
2279
- ), Z = G(
2280
- u,
2281
- de
2282
- );
2283
- if (!(!he && !Z || he === Z)) return;
2284
- const ee = Gn(
2285
- r,
2286
- p,
2287
- Z,
2288
- t
2289
- );
2290
- s.has(ee) || (s.add(ee), n.push(`@media (prefers-reduced-motion: no-preference) {
2291
- ${ee}:not([data-interact-enter]) {
2292
- visibility: hidden;
2293
- transform: none;
2294
- translate: none;
2295
- scale: none;
2296
- rotate: none;
2297
- }
2298
- }`));
2299
- });
2300
- }
2301
- }
2302
- ), n.join(`
2303
- `);
2304
- }
2305
- export {
2306
- Kn as I,
2307
- w as a,
2308
- Un as b,
2309
- Zn as g,
2310
- Jn as r
2311
- };
2312
- //# sourceMappingURL=index-BnI6W-7u.mjs.map