@dogeos/dogeos-sdk 3.0.19-beta.6 → 3.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2610 +0,0 @@
1
- import { E as Kt, F as Bt, f as ee, q as _t, G as oe, H as Ne, a as D, I as kn, h as R, C as Un, n as H, J as Ke, K as Lt, b as U, p as Ve, N as Gn, e as kt, O as Be, d as Y, Q as $n, R as jn, T as Wn, U as ae, c as Ae, V as le, W as Ut, X as Gt, Y as $t, Z as Qe, _ as jt, x as zn, $ as qn, a0 as Hn, a1 as et, a2 as Yn, a3 as Xn, a4 as Zn, a5 as Jn, a6 as Qn, a7 as es, a8 as ts, a9 as ns, aa as ss, ab as is, ac as rs } from "./index-DbZnkm04.js";
2
- import { Fragment as os } from "react";
3
- // @__NO_SIDE_EFFECTS__
4
- function _e(t) {
5
- let e;
6
- return () => (e === void 0 && (e = t()), e);
7
- }
8
- const Le = /* @__NO_SIDE_EFFECTS__ */ (t, e, n) => {
9
- const s = e - t;
10
- return s === 0 ? 1 : (n - t) / s;
11
- }, I = /* @__NO_SIDE_EFFECTS__ */ (t) => t * 1e3, O = /* @__NO_SIDE_EFFECTS__ */ (t) => t / 1e3;
12
- function Wt(t, e) {
13
- if (!Array.isArray(e))
14
- return !1;
15
- const n = e.length;
16
- if (n !== t.length)
17
- return !1;
18
- for (let s = 0; s < n; s++)
19
- if (e[s] !== t[s])
20
- return !1;
21
- return !0;
22
- }
23
- function ue(t, e, n) {
24
- const s = t.getProps();
25
- return Kt(s, e, n !== void 0 ? n : s.custom, t);
26
- }
27
- const as = /* @__PURE__ */ _e(() => window.ScrollTimeline !== void 0);
28
- class ls {
29
- constructor(e) {
30
- this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
31
- }
32
- get finished() {
33
- return Promise.all(this.animations.map((e) => "finished" in e ? e.finished : e));
34
- }
35
- /**
36
- * TODO: Filter out cancelled or stopped animations before returning
37
- */
38
- getAll(e) {
39
- return this.animations[0][e];
40
- }
41
- setAll(e, n) {
42
- for (let s = 0; s < this.animations.length; s++)
43
- this.animations[s][e] = n;
44
- }
45
- attachTimeline(e, n) {
46
- const s = this.animations.map((i) => {
47
- if (as() && i.attachTimeline)
48
- return i.attachTimeline(e);
49
- if (typeof n == "function")
50
- return n(i);
51
- });
52
- return () => {
53
- s.forEach((i, r) => {
54
- i && i(), this.animations[r].stop();
55
- });
56
- };
57
- }
58
- get time() {
59
- return this.getAll("time");
60
- }
61
- set time(e) {
62
- this.setAll("time", e);
63
- }
64
- get speed() {
65
- return this.getAll("speed");
66
- }
67
- set speed(e) {
68
- this.setAll("speed", e);
69
- }
70
- get startTime() {
71
- return this.getAll("startTime");
72
- }
73
- get duration() {
74
- let e = 0;
75
- for (let n = 0; n < this.animations.length; n++)
76
- e = Math.max(e, this.animations[n].duration);
77
- return e;
78
- }
79
- runAll(e) {
80
- this.animations.forEach((n) => n[e]());
81
- }
82
- flatten() {
83
- this.runAll("flatten");
84
- }
85
- play() {
86
- this.runAll("play");
87
- }
88
- pause() {
89
- this.runAll("pause");
90
- }
91
- cancel() {
92
- this.runAll("cancel");
93
- }
94
- complete() {
95
- this.runAll("complete");
96
- }
97
- }
98
- class us extends ls {
99
- then(e, n) {
100
- return Promise.all(this.animations).then(e).catch(n);
101
- }
102
- }
103
- function zt(t, e) {
104
- return t ? t[e] || t.default || t : void 0;
105
- }
106
- const xe = 2e4;
107
- function qt(t) {
108
- let e = 0;
109
- const n = 50;
110
- let s = t.next(e);
111
- for (; !s.done && e < xe; )
112
- e += n, s = t.next(e);
113
- return e >= xe ? 1 / 0 : e;
114
- }
115
- function ke(t) {
116
- return typeof t == "function";
117
- }
118
- function tt(t, e) {
119
- t.timeline = e, t.onfinish = null;
120
- }
121
- const Ue = (t) => Array.isArray(t) && typeof t[0] == "number", cs = {
122
- linearEasing: void 0
123
- };
124
- function hs(t, e) {
125
- const n = /* @__PURE__ */ _e(t);
126
- return () => {
127
- var s;
128
- return (s = cs[e]) !== null && s !== void 0 ? s : n();
129
- };
130
- }
131
- const te = /* @__PURE__ */ hs(() => {
132
- try {
133
- document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
134
- } catch {
135
- return !1;
136
- }
137
- return !0;
138
- }, "linearEasing"), Ht = (t, e, n = 10) => {
139
- let s = "";
140
- const i = Math.max(Math.round(e / n), 2);
141
- for (let r = 0; r < i; r++)
142
- s += t(/* @__PURE__ */ Le(0, i - 1, r)) + ", ";
143
- return `linear(${s.substring(0, s.length - 2)})`;
144
- };
145
- function Yt(t) {
146
- return !!(typeof t == "function" && te() || !t || typeof t == "string" && (t in Se || te()) || Ue(t) || Array.isArray(t) && t.every(Yt));
147
- }
148
- const W = ([t, e, n, s]) => `cubic-bezier(${t}, ${e}, ${n}, ${s})`, Se = {
149
- linear: "linear",
150
- ease: "ease",
151
- easeIn: "ease-in",
152
- easeOut: "ease-out",
153
- easeInOut: "ease-in-out",
154
- circIn: /* @__PURE__ */ W([0, 0.65, 0.55, 1]),
155
- circOut: /* @__PURE__ */ W([0.55, 0, 1, 0.45]),
156
- backIn: /* @__PURE__ */ W([0.31, 0.01, 0.66, -0.59]),
157
- backOut: /* @__PURE__ */ W([0.33, 1.53, 0.69, 0.99])
158
- };
159
- function Xt(t, e) {
160
- if (t)
161
- return typeof t == "function" && te() ? Ht(t, e) : Ue(t) ? W(t) : Array.isArray(t) ? t.map((n) => Xt(n, e) || Se.easeOut) : Se[t];
162
- }
163
- const nt = {
164
- x: !1,
165
- y: !1
166
- };
167
- function Zt() {
168
- return nt.x || nt.y;
169
- }
170
- function ds(t, e, n) {
171
- var s;
172
- if (t instanceof Element)
173
- return [t];
174
- if (typeof t == "string") {
175
- let i = document;
176
- const r = (s = void 0) !== null && s !== void 0 ? s : i.querySelectorAll(t);
177
- return r ? Array.from(r) : [];
178
- }
179
- return Array.from(t);
180
- }
181
- function Jt(t, e) {
182
- const n = ds(t), s = new AbortController(), i = {
183
- passive: !0,
184
- ...e,
185
- signal: s.signal
186
- };
187
- return [n, i, () => s.abort()];
188
- }
189
- function st(t) {
190
- return (e) => {
191
- e.pointerType === "touch" || Zt() || t(e);
192
- };
193
- }
194
- function fs(t, e, n = {}) {
195
- const [s, i, r] = Jt(t, n), o = st((a) => {
196
- const { target: l } = a, u = e(a);
197
- if (typeof u != "function" || !l)
198
- return;
199
- const c = st((h) => {
200
- u(h), l.removeEventListener("pointerleave", c);
201
- });
202
- l.addEventListener("pointerleave", c, i);
203
- });
204
- return s.forEach((a) => {
205
- a.addEventListener("pointerenter", o, i);
206
- }), r;
207
- }
208
- const Qt = (t, e) => e ? t === e ? !0 : Qt(t, e.parentElement) : !1, en = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1, ps = /* @__PURE__ */ new Set([
209
- "BUTTON",
210
- "INPUT",
211
- "SELECT",
212
- "TEXTAREA",
213
- "A"
214
- ]);
215
- function ms(t) {
216
- return ps.has(t.tagName) || t.tabIndex !== -1;
217
- }
218
- const z = /* @__PURE__ */ new WeakSet();
219
- function it(t) {
220
- return (e) => {
221
- e.key === "Enter" && t(e);
222
- };
223
- }
224
- function pe(t, e) {
225
- t.dispatchEvent(new PointerEvent("pointer" + e, { isPrimary: !0, bubbles: !0 }));
226
- }
227
- const gs = (t, e) => {
228
- const n = t.currentTarget;
229
- if (!n)
230
- return;
231
- const s = it(() => {
232
- if (z.has(n))
233
- return;
234
- pe(n, "down");
235
- const i = it(() => {
236
- pe(n, "up");
237
- }), r = () => pe(n, "cancel");
238
- n.addEventListener("keyup", i, e), n.addEventListener("blur", r, e);
239
- });
240
- n.addEventListener("keydown", s, e), n.addEventListener("blur", () => n.removeEventListener("keydown", s), e);
241
- };
242
- function rt(t) {
243
- return en(t) && !Zt();
244
- }
245
- function ys(t, e, n = {}) {
246
- const [s, i, r] = Jt(t, n), o = (a) => {
247
- const l = a.currentTarget;
248
- if (!rt(a) || z.has(l))
249
- return;
250
- z.add(l);
251
- const u = e(a), c = (f, b) => {
252
- window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", d), !(!rt(f) || !z.has(l)) && (z.delete(l), typeof u == "function" && u(f, { success: b }));
253
- }, h = (f) => {
254
- c(f, n.useGlobalTarget || Qt(l, f.target));
255
- }, d = (f) => {
256
- c(f, !1);
257
- };
258
- window.addEventListener("pointerup", h, i), window.addEventListener("pointercancel", d, i);
259
- };
260
- return s.forEach((a) => {
261
- !ms(a) && a.getAttribute("tabindex") === null && (a.tabIndex = 0), (n.useGlobalTarget ? window : a).addEventListener("pointerdown", o, i), a.addEventListener("focus", (u) => gs(u, i), i);
262
- }), r;
263
- }
264
- const tn = /* @__PURE__ */ new Set([
265
- "width",
266
- "height",
267
- "top",
268
- "left",
269
- "right",
270
- "bottom",
271
- ...Bt
272
- ]);
273
- let Q;
274
- function vs() {
275
- Q = void 0;
276
- }
277
- const N = {
278
- now: () => (Q === void 0 && N.set(ee.isProcessing || _t.useManualTiming ? ee.timestamp : performance.now()), Q),
279
- set: (t) => {
280
- Q = t, queueMicrotask(vs);
281
- }
282
- };
283
- function bs(t, e) {
284
- t.indexOf(e) === -1 && t.push(e);
285
- }
286
- function Ts(t, e) {
287
- const n = t.indexOf(e);
288
- n > -1 && t.splice(n, 1);
289
- }
290
- class nn {
291
- constructor() {
292
- this.subscriptions = [];
293
- }
294
- add(e) {
295
- return bs(this.subscriptions, e), () => Ts(this.subscriptions, e);
296
- }
297
- notify(e, n, s) {
298
- const i = this.subscriptions.length;
299
- if (i)
300
- if (i === 1)
301
- this.subscriptions[0](e, n, s);
302
- else
303
- for (let r = 0; r < i; r++) {
304
- const o = this.subscriptions[r];
305
- o && o(e, n, s);
306
- }
307
- }
308
- getSize() {
309
- return this.subscriptions.length;
310
- }
311
- clear() {
312
- this.subscriptions.length = 0;
313
- }
314
- }
315
- function sn(t, e) {
316
- return e ? t * (1e3 / e) : 0;
317
- }
318
- const ot = 30, Vs = (t) => !isNaN(parseFloat(t));
319
- class As {
320
- /**
321
- * @param init - The initiating value
322
- * @param config - Optional configuration options
323
- *
324
- * - `transformer`: A function to transform incoming values with.
325
- *
326
- * @internal
327
- */
328
- constructor(e, n = {}) {
329
- this.version = "11.18.2", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s, i = !0) => {
330
- const r = N.now();
331
- this.updatedAt !== r && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(s), this.current !== this.prev && this.events.change && this.events.change.notify(this.current), i && this.events.renderRequest && this.events.renderRequest.notify(this.current);
332
- }, this.hasAnimated = !1, this.setCurrent(e), this.owner = n.owner;
333
- }
334
- setCurrent(e) {
335
- this.current = e, this.updatedAt = N.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = Vs(this.current));
336
- }
337
- setPrevFrameValue(e = this.current) {
338
- this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt;
339
- }
340
- /**
341
- * Adds a function that will be notified when the `MotionValue` is updated.
342
- *
343
- * It returns a function that, when called, will cancel the subscription.
344
- *
345
- * When calling `onChange` inside a React component, it should be wrapped with the
346
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
347
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
348
- *
349
- * ```jsx
350
- * export const MyComponent = () => {
351
- * const x = useMotionValue(0)
352
- * const y = useMotionValue(0)
353
- * const opacity = useMotionValue(1)
354
- *
355
- * useEffect(() => {
356
- * function updateOpacity() {
357
- * const maxXY = Math.max(x.get(), y.get())
358
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
359
- * opacity.set(newOpacity)
360
- * }
361
- *
362
- * const unsubscribeX = x.on("change", updateOpacity)
363
- * const unsubscribeY = y.on("change", updateOpacity)
364
- *
365
- * return () => {
366
- * unsubscribeX()
367
- * unsubscribeY()
368
- * }
369
- * }, [])
370
- *
371
- * return <motion.div style={{ x }} />
372
- * }
373
- * ```
374
- *
375
- * @param subscriber - A function that receives the latest value.
376
- * @returns A function that, when called, will cancel this subscription.
377
- *
378
- * @deprecated
379
- */
380
- onChange(e) {
381
- return oe.env.NODE_ENV !== "production" && Ne(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e);
382
- }
383
- on(e, n) {
384
- this.events[e] || (this.events[e] = new nn());
385
- const s = this.events[e].add(n);
386
- return e === "change" ? () => {
387
- s(), D.read(() => {
388
- this.events.change.getSize() || this.stop();
389
- });
390
- } : s;
391
- }
392
- clearListeners() {
393
- for (const e in this.events)
394
- this.events[e].clear();
395
- }
396
- /**
397
- * Attaches a passive effect to the `MotionValue`.
398
- *
399
- * @internal
400
- */
401
- attach(e, n) {
402
- this.passiveEffect = e, this.stopPassiveEffect = n;
403
- }
404
- /**
405
- * Sets the state of the `MotionValue`.
406
- *
407
- * @remarks
408
- *
409
- * ```jsx
410
- * const x = useMotionValue(0)
411
- * x.set(10)
412
- * ```
413
- *
414
- * @param latest - Latest value to set.
415
- * @param render - Whether to notify render subscribers. Defaults to `true`
416
- *
417
- * @public
418
- */
419
- set(e, n = !0) {
420
- !n || !this.passiveEffect ? this.updateAndNotify(e, n) : this.passiveEffect(e, this.updateAndNotify);
421
- }
422
- setWithVelocity(e, n, s) {
423
- this.set(n), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - s;
424
- }
425
- /**
426
- * Set the state of the `MotionValue`, stopping any active animations,
427
- * effects, and resets velocity to `0`.
428
- */
429
- jump(e, n = !0) {
430
- this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
431
- }
432
- /**
433
- * Returns the latest state of `MotionValue`
434
- *
435
- * @returns - The latest state of `MotionValue`
436
- *
437
- * @public
438
- */
439
- get() {
440
- return this.current;
441
- }
442
- /**
443
- * @public
444
- */
445
- getPrevious() {
446
- return this.prev;
447
- }
448
- /**
449
- * Returns the latest velocity of `MotionValue`
450
- *
451
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
452
- *
453
- * @public
454
- */
455
- getVelocity() {
456
- const e = N.now();
457
- if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > ot)
458
- return 0;
459
- const n = Math.min(this.updatedAt - this.prevUpdatedAt, ot);
460
- return sn(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
461
- }
462
- /**
463
- * Registers a new animation to control this `MotionValue`. Only one
464
- * animation can drive a `MotionValue` at one time.
465
- *
466
- * ```jsx
467
- * value.start()
468
- * ```
469
- *
470
- * @param animation - A function that starts the provided animation
471
- *
472
- * @internal
473
- */
474
- start(e) {
475
- return this.stop(), new Promise((n) => {
476
- this.hasAnimated = !0, this.animation = e(n), this.events.animationStart && this.events.animationStart.notify();
477
- }).then(() => {
478
- this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
479
- });
480
- }
481
- /**
482
- * Stop the currently active animation.
483
- *
484
- * @public
485
- */
486
- stop() {
487
- this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
488
- }
489
- /**
490
- * Returns `true` if this value is currently animating.
491
- *
492
- * @public
493
- */
494
- isAnimating() {
495
- return !!this.animation;
496
- }
497
- clearAnimation() {
498
- delete this.animation;
499
- }
500
- /**
501
- * Destroy and clean up subscribers to this `MotionValue`.
502
- *
503
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
504
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
505
- * created a `MotionValue` via the `motionValue` function.
506
- *
507
- * @public
508
- */
509
- destroy() {
510
- this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
511
- }
512
- }
513
- function ne(t, e) {
514
- return new As(t, e);
515
- }
516
- function xs(t, e, n) {
517
- t.hasValue(e) ? t.getValue(e).set(n) : t.addValue(e, ne(n));
518
- }
519
- function Ss(t, e) {
520
- const n = ue(t, e);
521
- let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {};
522
- r = { ...r, ...s };
523
- for (const o in r) {
524
- const a = kn(r[o]);
525
- xs(t, o, a);
526
- }
527
- }
528
- function ws(t) {
529
- return !!(R(t) && t.add);
530
- }
531
- function Ps(t, e) {
532
- const n = t.getValue("willChange");
533
- if (ws(n))
534
- return n.add(e);
535
- }
536
- function Cs(t) {
537
- return t.props[Un];
538
- }
539
- const rn = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, Ms = 1e-7, Fs = 12;
540
- function Ds(t, e, n, s, i) {
541
- let r, o, a = 0;
542
- do
543
- o = e + (n - e) / 2, r = rn(o, s, i) - t, r > 0 ? n = o : e = o;
544
- while (Math.abs(r) > Ms && ++a < Fs);
545
- return o;
546
- }
547
- function Z(t, e, n, s) {
548
- if (t === e && n === s)
549
- return H;
550
- const i = (r) => Ds(r, 0, 1, t, n);
551
- return (r) => r === 0 || r === 1 ? r : rn(i(r), e, s);
552
- }
553
- const on = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, an = (t) => (e) => 1 - t(1 - e), ln = /* @__PURE__ */ Z(0.33, 1.53, 0.69, 0.99), Ge = /* @__PURE__ */ an(ln), un = /* @__PURE__ */ on(Ge), cn = (t) => (t *= 2) < 1 ? 0.5 * Ge(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), $e = (t) => 1 - Math.sin(Math.acos(t)), Es = an($e), hn = on($e), dn = (t) => /^0[^.\s]+$/u.test(t);
554
- function Is(t) {
555
- return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || dn(t) : !0;
556
- }
557
- const q = (t) => Math.round(t * 1e5) / 1e5, je = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
558
- function Rs(t) {
559
- return t == null;
560
- }
561
- const Os = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, We = (t, e) => (n) => !!(typeof n == "string" && Os.test(n) && n.startsWith(t) || e && !Rs(n) && Object.prototype.hasOwnProperty.call(n, e)), fn = (t, e, n) => (s) => {
562
- if (typeof s != "string")
563
- return s;
564
- const [i, r, o, a] = s.match(je);
565
- return {
566
- [t]: parseFloat(i),
567
- [e]: parseFloat(r),
568
- [n]: parseFloat(o),
569
- alpha: a !== void 0 ? parseFloat(a) : 1
570
- };
571
- }, Ns = (t) => U(0, 255, t), me = {
572
- ...Ke,
573
- transform: (t) => Math.round(Ns(t))
574
- }, B = {
575
- test: /* @__PURE__ */ We("rgb", "red"),
576
- parse: /* @__PURE__ */ fn("red", "green", "blue"),
577
- transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + me.transform(t) + ", " + me.transform(e) + ", " + me.transform(n) + ", " + q(Lt.transform(s)) + ")"
578
- };
579
- function Ks(t) {
580
- let e = "", n = "", s = "", i = "";
581
- return t.length > 5 ? (e = t.substring(1, 3), n = t.substring(3, 5), s = t.substring(5, 7), i = t.substring(7, 9)) : (e = t.substring(1, 2), n = t.substring(2, 3), s = t.substring(3, 4), i = t.substring(4, 5), e += e, n += n, s += s, i += i), {
582
- red: parseInt(e, 16),
583
- green: parseInt(n, 16),
584
- blue: parseInt(s, 16),
585
- alpha: i ? parseInt(i, 16) / 255 : 1
586
- };
587
- }
588
- const we = {
589
- test: /* @__PURE__ */ We("#"),
590
- parse: Ks,
591
- transform: B.transform
592
- }, k = {
593
- test: /* @__PURE__ */ We("hsl", "hue"),
594
- parse: /* @__PURE__ */ fn("hue", "saturation", "lightness"),
595
- transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + Ve.transform(q(e)) + ", " + Ve.transform(q(n)) + ", " + q(Lt.transform(s)) + ")"
596
- }, w = {
597
- test: (t) => B.test(t) || we.test(t) || k.test(t),
598
- parse: (t) => B.test(t) ? B.parse(t) : k.test(t) ? k.parse(t) : we.parse(t),
599
- transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? B.transform(t) : k.transform(t)
600
- }, Bs = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
601
- function _s(t) {
602
- var e, n;
603
- return isNaN(t) && typeof t == "string" && (((e = t.match(je)) === null || e === void 0 ? void 0 : e.length) || 0) + (((n = t.match(Bs)) === null || n === void 0 ? void 0 : n.length) || 0) > 0;
604
- }
605
- const pn = "number", mn = "color", Ls = "var", ks = "var(", at = "${}", Us = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;
606
- function X(t) {
607
- const e = t.toString(), n = [], s = {
608
- color: [],
609
- number: [],
610
- var: []
611
- }, i = [];
612
- let r = 0;
613
- const a = e.replace(Us, (l) => (w.test(l) ? (s.color.push(r), i.push(mn), n.push(w.parse(l))) : l.startsWith(ks) ? (s.var.push(r), i.push(Ls), n.push(l)) : (s.number.push(r), i.push(pn), n.push(parseFloat(l))), ++r, at)).split(at);
614
- return { values: n, split: a, indexes: s, types: i };
615
- }
616
- function gn(t) {
617
- return X(t).values;
618
- }
619
- function yn(t) {
620
- const { split: e, types: n } = X(t), s = e.length;
621
- return (i) => {
622
- let r = "";
623
- for (let o = 0; o < s; o++)
624
- if (r += e[o], i[o] !== void 0) {
625
- const a = n[o];
626
- a === pn ? r += q(i[o]) : a === mn ? r += w.transform(i[o]) : r += i[o];
627
- }
628
- return r;
629
- };
630
- }
631
- const Gs = (t) => typeof t == "number" ? 0 : t;
632
- function $s(t) {
633
- const e = gn(t);
634
- return yn(t)(e.map(Gs));
635
- }
636
- const $ = {
637
- test: _s,
638
- parse: gn,
639
- createTransformer: yn,
640
- getAnimatableNone: $s
641
- }, js = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
642
- function Ws(t) {
643
- const [e, n] = t.slice(0, -1).split("(");
644
- if (e === "drop-shadow")
645
- return t;
646
- const [s] = n.match(je) || [];
647
- if (!s)
648
- return t;
649
- const i = n.replace(s, "");
650
- let r = js.has(e) ? 1 : 0;
651
- return s !== n && (r *= 100), e + "(" + r + i + ")";
652
- }
653
- const zs = /\b([a-z-]*)\(.*?\)/gu, Pe = {
654
- ...$,
655
- getAnimatableNone: (t) => {
656
- const e = t.match(zs);
657
- return e ? e.map(Ws).join(" ") : t;
658
- }
659
- }, qs = {
660
- ...Gn,
661
- // Color props
662
- color: w,
663
- backgroundColor: w,
664
- outlineColor: w,
665
- fill: w,
666
- stroke: w,
667
- // Border props
668
- borderColor: w,
669
- borderTopColor: w,
670
- borderRightColor: w,
671
- borderBottomColor: w,
672
- borderLeftColor: w,
673
- filter: Pe,
674
- WebkitFilter: Pe
675
- }, ze = (t) => qs[t];
676
- function vn(t, e) {
677
- let n = ze(t);
678
- return n !== Pe && (n = $), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0;
679
- }
680
- const Hs = /* @__PURE__ */ new Set(["auto", "none", "0"]);
681
- function Ys(t, e, n) {
682
- let s = 0, i;
683
- for (; s < t.length && !i; ) {
684
- const r = t[s];
685
- typeof r == "string" && !Hs.has(r) && X(r).values.length && (i = t[s]), s++;
686
- }
687
- if (i && n)
688
- for (const r of e)
689
- t[r] = vn(n, i);
690
- }
691
- const lt = (t) => t === Ke || t === kt, ut = (t, e) => parseFloat(t.split(", ")[e]), ct = (t, e) => (n, { transform: s }) => {
692
- if (s === "none" || !s)
693
- return 0;
694
- const i = s.match(/^matrix3d\((.+)\)$/u);
695
- if (i)
696
- return ut(i[1], e);
697
- {
698
- const r = s.match(/^matrix\((.+)\)$/u);
699
- return r ? ut(r[1], t) : 0;
700
- }
701
- }, Xs = /* @__PURE__ */ new Set(["x", "y", "z"]), Zs = Bt.filter((t) => !Xs.has(t));
702
- function Js(t) {
703
- const e = [];
704
- return Zs.forEach((n) => {
705
- const s = t.getValue(n);
706
- s !== void 0 && (e.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
707
- }), e;
708
- }
709
- const G = {
710
- // Dimensions
711
- width: ({ x: t }, { paddingLeft: e = "0", paddingRight: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
712
- height: ({ y: t }, { paddingTop: e = "0", paddingBottom: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
713
- top: (t, { top: e }) => parseFloat(e),
714
- left: (t, { left: e }) => parseFloat(e),
715
- bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min),
716
- right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min),
717
- // Transform
718
- x: ct(4, 13),
719
- y: ct(5, 14)
720
- };
721
- G.translateX = G.x;
722
- G.translateY = G.y;
723
- const _ = /* @__PURE__ */ new Set();
724
- let Ce = !1, Me = !1;
725
- function bn() {
726
- if (Me) {
727
- const t = Array.from(_).filter((s) => s.needsMeasurement), e = new Set(t.map((s) => s.element)), n = /* @__PURE__ */ new Map();
728
- e.forEach((s) => {
729
- const i = Js(s);
730
- i.length && (n.set(s, i), s.render());
731
- }), t.forEach((s) => s.measureInitialState()), e.forEach((s) => {
732
- s.render();
733
- const i = n.get(s);
734
- i && i.forEach(([r, o]) => {
735
- var a;
736
- (a = s.getValue(r)) === null || a === void 0 || a.set(o);
737
- });
738
- }), t.forEach((s) => s.measureEndState()), t.forEach((s) => {
739
- s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
740
- });
741
- }
742
- Me = !1, Ce = !1, _.forEach((t) => t.complete()), _.clear();
743
- }
744
- function Tn() {
745
- _.forEach((t) => {
746
- t.readKeyframes(), t.needsMeasurement && (Me = !0);
747
- });
748
- }
749
- function Qs() {
750
- Tn(), bn();
751
- }
752
- class qe {
753
- constructor(e, n, s, i, r, o = !1) {
754
- this.isComplete = !1, this.isAsync = !1, this.needsMeasurement = !1, this.isScheduled = !1, this.unresolvedKeyframes = [...e], this.onComplete = n, this.name = s, this.motionValue = i, this.element = r, this.isAsync = o;
755
- }
756
- scheduleResolve() {
757
- this.isScheduled = !0, this.isAsync ? (_.add(this), Ce || (Ce = !0, D.read(Tn), D.resolveKeyframes(bn))) : (this.readKeyframes(), this.complete());
758
- }
759
- readKeyframes() {
760
- const { unresolvedKeyframes: e, name: n, element: s, motionValue: i } = this;
761
- for (let r = 0; r < e.length; r++)
762
- if (e[r] === null)
763
- if (r === 0) {
764
- const o = i?.get(), a = e[e.length - 1];
765
- if (o !== void 0)
766
- e[0] = o;
767
- else if (s && n) {
768
- const l = s.readValue(n, a);
769
- l != null && (e[0] = l);
770
- }
771
- e[0] === void 0 && (e[0] = a), i && o === void 0 && i.set(e[0]);
772
- } else
773
- e[r] = e[r - 1];
774
- }
775
- setFinalKeyframe() {
776
- }
777
- measureInitialState() {
778
- }
779
- renderEndStyles() {
780
- }
781
- measureEndState() {
782
- }
783
- complete() {
784
- this.isComplete = !0, this.onComplete(this.unresolvedKeyframes, this.finalKeyframe), _.delete(this);
785
- }
786
- cancel() {
787
- this.isComplete || (this.isScheduled = !1, _.delete(this));
788
- }
789
- resume() {
790
- this.isComplete || this.scheduleResolve();
791
- }
792
- }
793
- const Vn = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), ei = (
794
- // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
795
- /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
796
- );
797
- function ti(t) {
798
- const e = ei.exec(t);
799
- if (!e)
800
- return [,];
801
- const [, n, s, i] = e;
802
- return [`--${n ?? s}`, i];
803
- }
804
- const ni = 4;
805
- function An(t, e, n = 1) {
806
- Y(n <= ni, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);
807
- const [s, i] = ti(t);
808
- if (!s)
809
- return;
810
- const r = window.getComputedStyle(e).getPropertyValue(s);
811
- if (r) {
812
- const o = r.trim();
813
- return Vn(o) ? parseFloat(o) : o;
814
- }
815
- return Be(i) ? An(i, e, n + 1) : i;
816
- }
817
- const xn = (t) => (e) => e.test(t), si = {
818
- test: (t) => t === "auto",
819
- parse: (t) => t
820
- }, Sn = [Ke, kt, Ve, $n, jn, Wn, si], ht = (t) => Sn.find(xn(t));
821
- class wn extends qe {
822
- constructor(e, n, s, i, r) {
823
- super(e, n, s, i, r, !0);
824
- }
825
- readKeyframes() {
826
- const { unresolvedKeyframes: e, element: n, name: s } = this;
827
- if (!n || !n.current)
828
- return;
829
- super.readKeyframes();
830
- for (let l = 0; l < e.length; l++) {
831
- let u = e[l];
832
- if (typeof u == "string" && (u = u.trim(), Be(u))) {
833
- const c = An(u, n.current);
834
- c !== void 0 && (e[l] = c), l === e.length - 1 && (this.finalKeyframe = u);
835
- }
836
- }
837
- if (this.resolveNoneKeyframes(), !tn.has(s) || e.length !== 2)
838
- return;
839
- const [i, r] = e, o = ht(i), a = ht(r);
840
- if (o !== a)
841
- if (lt(o) && lt(a))
842
- for (let l = 0; l < e.length; l++) {
843
- const u = e[l];
844
- typeof u == "string" && (e[l] = parseFloat(u));
845
- }
846
- else
847
- this.needsMeasurement = !0;
848
- }
849
- resolveNoneKeyframes() {
850
- const { unresolvedKeyframes: e, name: n } = this, s = [];
851
- for (let i = 0; i < e.length; i++)
852
- Is(e[i]) && s.push(i);
853
- s.length && Ys(e, s, n);
854
- }
855
- measureInitialState() {
856
- const { element: e, unresolvedKeyframes: n, name: s } = this;
857
- if (!e || !e.current)
858
- return;
859
- s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = G[s](e.measureViewportBox(), window.getComputedStyle(e.current)), n[0] = this.measuredOrigin;
860
- const i = n[n.length - 1];
861
- i !== void 0 && e.getValue(s, i).jump(i, !1);
862
- }
863
- measureEndState() {
864
- var e;
865
- const { element: n, name: s, unresolvedKeyframes: i } = this;
866
- if (!n || !n.current)
867
- return;
868
- const r = n.getValue(s);
869
- r && r.jump(this.measuredOrigin, !1);
870
- const o = i.length - 1, a = i[o];
871
- i[o] = G[s](n.measureViewportBox(), window.getComputedStyle(n.current)), a !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = a), !((e = this.removedTransforms) === null || e === void 0) && e.length && this.removedTransforms.forEach(([l, u]) => {
872
- n.getValue(l).set(u);
873
- }), this.resolveNoneKeyframes();
874
- }
875
- }
876
- const dt = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string
877
- ($.test(t) || t === "0") && // And it contains numbers and/or colors
878
- !t.startsWith("url("));
879
- function ii(t) {
880
- const e = t[0];
881
- if (t.length === 1)
882
- return !0;
883
- for (let n = 0; n < t.length; n++)
884
- if (t[n] !== e)
885
- return !0;
886
- }
887
- function ri(t, e, n, s) {
888
- const i = t[0];
889
- if (i === null)
890
- return !1;
891
- if (e === "display" || e === "visibility")
892
- return !0;
893
- const r = t[t.length - 1], o = dt(i, e), a = dt(r, e);
894
- return ae(o === a, `You are trying to animate ${e} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`), !o || !a ? !1 : ii(t) || (n === "spring" || ke(n)) && s;
895
- }
896
- const oi = (t) => t !== null;
897
- function ce(t, { repeat: e, repeatType: n = "loop" }, s) {
898
- const i = t.filter(oi), r = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1;
899
- return !r || s === void 0 ? i[r] : s;
900
- }
901
- const ai = 40;
902
- class Pn {
903
- constructor({ autoplay: e = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: r = 0, repeatType: o = "loop", ...a }) {
904
- this.isStopped = !1, this.hasAttemptedResolve = !1, this.createdAt = N.now(), this.options = {
905
- autoplay: e,
906
- delay: n,
907
- type: s,
908
- repeat: i,
909
- repeatDelay: r,
910
- repeatType: o,
911
- ...a
912
- }, this.updateFinishedPromise();
913
- }
914
- /**
915
- * This method uses the createdAt and resolvedAt to calculate the
916
- * animation startTime. *Ideally*, we would use the createdAt time as t=0
917
- * as the following frame would then be the first frame of the animation in
918
- * progress, which would feel snappier.
919
- *
920
- * However, if there's a delay (main thread work) between the creation of
921
- * the animation and the first commited frame, we prefer to use resolvedAt
922
- * to avoid a sudden jump into the animation.
923
- */
924
- calcStartTime() {
925
- return this.resolvedAt ? this.resolvedAt - this.createdAt > ai ? this.resolvedAt : this.createdAt : this.createdAt;
926
- }
927
- /**
928
- * A getter for resolved data. If keyframes are not yet resolved, accessing
929
- * this.resolved will synchronously flush all pending keyframe resolvers.
930
- * This is a deoptimisation, but at its worst still batches read/writes.
931
- */
932
- get resolved() {
933
- return !this._resolved && !this.hasAttemptedResolve && Qs(), this._resolved;
934
- }
935
- /**
936
- * A method to be called when the keyframes resolver completes. This method
937
- * will check if its possible to run the animation and, if not, skip it.
938
- * Otherwise, it will call initPlayback on the implementing class.
939
- */
940
- onKeyframesResolved(e, n) {
941
- this.resolvedAt = N.now(), this.hasAttemptedResolve = !0;
942
- const { name: s, type: i, velocity: r, delay: o, onComplete: a, onUpdate: l, isGenerator: u } = this.options;
943
- if (!u && !ri(e, s, i, r))
944
- if (o)
945
- this.options.duration = 0;
946
- else {
947
- l && l(ce(e, this.options, n)), a && a(), this.resolveFinishedPromise();
948
- return;
949
- }
950
- const c = this.initPlayback(e, n);
951
- c !== !1 && (this._resolved = {
952
- keyframes: e,
953
- finalKeyframe: n,
954
- ...c
955
- }, this.onPostResolved());
956
- }
957
- onPostResolved() {
958
- }
959
- /**
960
- * Allows the returned animation to be awaited or promise-chained. Currently
961
- * resolves when the animation finishes at all but in a future update could/should
962
- * reject if its cancels.
963
- */
964
- then(e, n) {
965
- return this.currentFinishedPromise.then(e, n);
966
- }
967
- flatten() {
968
- this.options.type = "keyframes", this.options.ease = "linear";
969
- }
970
- updateFinishedPromise() {
971
- this.currentFinishedPromise = new Promise((e) => {
972
- this.resolveFinishedPromise = e;
973
- });
974
- }
975
- }
976
- const J = (t, e, n) => t + (e - t) * n;
977
- function ge(t, e, n) {
978
- return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (e - t) * 6 * n : n < 1 / 2 ? e : n < 2 / 3 ? t + (e - t) * (2 / 3 - n) * 6 : t;
979
- }
980
- function li({ hue: t, saturation: e, lightness: n, alpha: s }) {
981
- t /= 360, e /= 100, n /= 100;
982
- let i = 0, r = 0, o = 0;
983
- if (!e)
984
- i = r = o = n;
985
- else {
986
- const a = n < 0.5 ? n * (1 + e) : n + e - n * e, l = 2 * n - a;
987
- i = ge(l, a, t + 1 / 3), r = ge(l, a, t), o = ge(l, a, t - 1 / 3);
988
- }
989
- return {
990
- red: Math.round(i * 255),
991
- green: Math.round(r * 255),
992
- blue: Math.round(o * 255),
993
- alpha: s
994
- };
995
- }
996
- function se(t, e) {
997
- return (n) => n > 0 ? e : t;
998
- }
999
- const ye = (t, e, n) => {
1000
- const s = t * t, i = n * (e * e - s) + s;
1001
- return i < 0 ? 0 : Math.sqrt(i);
1002
- }, ui = [we, B, k], ci = (t) => ui.find((e) => e.test(t));
1003
- function ft(t) {
1004
- const e = ci(t);
1005
- if (ae(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`), !e)
1006
- return !1;
1007
- let n = e.parse(t);
1008
- return e === k && (n = li(n)), n;
1009
- }
1010
- const pt = (t, e) => {
1011
- const n = ft(t), s = ft(e);
1012
- if (!n || !s)
1013
- return se(t, e);
1014
- const i = { ...n };
1015
- return (r) => (i.red = ye(n.red, s.red, r), i.green = ye(n.green, s.green, r), i.blue = ye(n.blue, s.blue, r), i.alpha = J(n.alpha, s.alpha, r), B.transform(i));
1016
- }, hi = (t, e) => (n) => e(t(n)), he = (...t) => t.reduce(hi), Fe = /* @__PURE__ */ new Set(["none", "hidden"]);
1017
- function di(t, e) {
1018
- return Fe.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
1019
- }
1020
- function fi(t, e) {
1021
- return (n) => J(t, e, n);
1022
- }
1023
- function He(t) {
1024
- return typeof t == "number" ? fi : typeof t == "string" ? Be(t) ? se : w.test(t) ? pt : gi : Array.isArray(t) ? Cn : typeof t == "object" ? w.test(t) ? pt : pi : se;
1025
- }
1026
- function Cn(t, e) {
1027
- const n = [...t], s = n.length, i = t.map((r, o) => He(r)(r, e[o]));
1028
- return (r) => {
1029
- for (let o = 0; o < s; o++)
1030
- n[o] = i[o](r);
1031
- return n;
1032
- };
1033
- }
1034
- function pi(t, e) {
1035
- const n = { ...t, ...e }, s = {};
1036
- for (const i in n)
1037
- t[i] !== void 0 && e[i] !== void 0 && (s[i] = He(t[i])(t[i], e[i]));
1038
- return (i) => {
1039
- for (const r in s)
1040
- n[r] = s[r](i);
1041
- return n;
1042
- };
1043
- }
1044
- function mi(t, e) {
1045
- var n;
1046
- const s = [], i = { color: 0, var: 0, number: 0 };
1047
- for (let r = 0; r < e.values.length; r++) {
1048
- const o = e.types[r], a = t.indexes[o][i[o]], l = (n = t.values[a]) !== null && n !== void 0 ? n : 0;
1049
- s[r] = l, i[o]++;
1050
- }
1051
- return s;
1052
- }
1053
- const gi = (t, e) => {
1054
- const n = $.createTransformer(e), s = X(t), i = X(e);
1055
- return s.indexes.var.length === i.indexes.var.length && s.indexes.color.length === i.indexes.color.length && s.indexes.number.length >= i.indexes.number.length ? Fe.has(t) && !i.values.length || Fe.has(e) && !s.values.length ? di(t, e) : he(Cn(mi(s, i), i.values), n) : (ae(!0, `Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), se(t, e));
1056
- };
1057
- function Mn(t, e, n) {
1058
- return typeof t == "number" && typeof e == "number" && typeof n == "number" ? J(t, e, n) : He(t)(t, e);
1059
- }
1060
- const yi = 5;
1061
- function Fn(t, e, n) {
1062
- const s = Math.max(e - yi, 0);
1063
- return sn(n - t(s), e - s);
1064
- }
1065
- const x = {
1066
- // Default spring physics
1067
- stiffness: 100,
1068
- damping: 10,
1069
- mass: 1,
1070
- velocity: 0,
1071
- // Default duration/bounce-based options
1072
- duration: 800,
1073
- // in ms
1074
- bounce: 0.3,
1075
- visualDuration: 0.3,
1076
- // in seconds
1077
- // Rest thresholds
1078
- restSpeed: {
1079
- granular: 0.01,
1080
- default: 2
1081
- },
1082
- restDelta: {
1083
- granular: 5e-3,
1084
- default: 0.5
1085
- },
1086
- // Limits
1087
- minDuration: 0.01,
1088
- // in seconds
1089
- maxDuration: 10,
1090
- // in seconds
1091
- minDamping: 0.05,
1092
- maxDamping: 1
1093
- }, ve = 1e-3;
1094
- function vi({ duration: t = x.duration, bounce: e = x.bounce, velocity: n = x.velocity, mass: s = x.mass }) {
1095
- let i, r;
1096
- ae(t <= /* @__PURE__ */ I(x.maxDuration), "Spring duration must be 10 seconds or less");
1097
- let o = 1 - e;
1098
- o = U(x.minDamping, x.maxDamping, o), t = U(x.minDuration, x.maxDuration, /* @__PURE__ */ O(t)), o < 1 ? (i = (u) => {
1099
- const c = u * o, h = c * t, d = c - n, f = De(u, o), b = Math.exp(-h);
1100
- return ve - d / f * b;
1101
- }, r = (u) => {
1102
- const h = u * o * t, d = h * n + n, f = Math.pow(o, 2) * Math.pow(u, 2) * t, b = Math.exp(-h), y = De(Math.pow(u, 2), o);
1103
- return (-i(u) + ve > 0 ? -1 : 1) * ((d - f) * b) / y;
1104
- }) : (i = (u) => {
1105
- const c = Math.exp(-u * t), h = (u - n) * t + 1;
1106
- return -ve + c * h;
1107
- }, r = (u) => {
1108
- const c = Math.exp(-u * t), h = (n - u) * (t * t);
1109
- return c * h;
1110
- });
1111
- const a = 5 / t, l = Ti(i, r, a);
1112
- if (t = /* @__PURE__ */ I(t), isNaN(l))
1113
- return {
1114
- stiffness: x.stiffness,
1115
- damping: x.damping,
1116
- duration: t
1117
- };
1118
- {
1119
- const u = Math.pow(l, 2) * s;
1120
- return {
1121
- stiffness: u,
1122
- damping: o * 2 * Math.sqrt(s * u),
1123
- duration: t
1124
- };
1125
- }
1126
- }
1127
- const bi = 12;
1128
- function Ti(t, e, n) {
1129
- let s = n;
1130
- for (let i = 1; i < bi; i++)
1131
- s = s - t(s) / e(s);
1132
- return s;
1133
- }
1134
- function De(t, e) {
1135
- return t * Math.sqrt(1 - e * e);
1136
- }
1137
- const Vi = ["duration", "bounce"], Ai = ["stiffness", "damping", "mass"];
1138
- function mt(t, e) {
1139
- return e.some((n) => t[n] !== void 0);
1140
- }
1141
- function xi(t) {
1142
- let e = {
1143
- velocity: x.velocity,
1144
- stiffness: x.stiffness,
1145
- damping: x.damping,
1146
- mass: x.mass,
1147
- isResolvedFromDuration: !1,
1148
- ...t
1149
- };
1150
- if (!mt(t, Ai) && mt(t, Vi))
1151
- if (t.visualDuration) {
1152
- const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * U(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(i);
1153
- e = {
1154
- ...e,
1155
- mass: x.mass,
1156
- stiffness: i,
1157
- damping: r
1158
- };
1159
- } else {
1160
- const n = vi(t);
1161
- e = {
1162
- ...e,
1163
- ...n,
1164
- mass: x.mass
1165
- }, e.isResolvedFromDuration = !0;
1166
- }
1167
- return e;
1168
- }
1169
- function Dn(t = x.visualDuration, e = x.bounce) {
1170
- const n = typeof t != "object" ? {
1171
- visualDuration: t,
1172
- keyframes: [0, 1],
1173
- bounce: e
1174
- } : t;
1175
- let { restSpeed: s, restDelta: i } = n;
1176
- const r = n.keyframes[0], o = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: r }, { stiffness: l, damping: u, mass: c, duration: h, velocity: d, isResolvedFromDuration: f } = xi({
1177
- ...n,
1178
- velocity: -/* @__PURE__ */ O(n.velocity || 0)
1179
- }), b = d || 0, y = u / (2 * Math.sqrt(l * c)), v = o - r, g = /* @__PURE__ */ O(Math.sqrt(l / c)), T = Math.abs(v) < 5;
1180
- s || (s = T ? x.restSpeed.granular : x.restSpeed.default), i || (i = T ? x.restDelta.granular : x.restDelta.default);
1181
- let V;
1182
- if (y < 1) {
1183
- const m = De(g, y);
1184
- V = (A) => {
1185
- const S = Math.exp(-y * g * A);
1186
- return o - S * ((b + y * g * v) / m * Math.sin(m * A) + v * Math.cos(m * A));
1187
- };
1188
- } else if (y === 1)
1189
- V = (m) => o - Math.exp(-g * m) * (v + (b + g * v) * m);
1190
- else {
1191
- const m = g * Math.sqrt(y * y - 1);
1192
- V = (A) => {
1193
- const S = Math.exp(-y * g * A), p = Math.min(m * A, 300);
1194
- return o - S * ((b + y * g * v) * Math.sinh(p) + m * v * Math.cosh(p)) / m;
1195
- };
1196
- }
1197
- const M = {
1198
- calculatedDuration: f && h || null,
1199
- next: (m) => {
1200
- const A = V(m);
1201
- if (f)
1202
- a.done = m >= h;
1203
- else {
1204
- let S = 0;
1205
- y < 1 && (S = m === 0 ? /* @__PURE__ */ I(b) : Fn(V, m, A));
1206
- const p = Math.abs(S) <= s, C = Math.abs(o - A) <= i;
1207
- a.done = p && C;
1208
- }
1209
- return a.value = a.done ? o : A, a;
1210
- },
1211
- toString: () => {
1212
- const m = Math.min(qt(M), xe), A = Ht((S) => M.next(m * S).value, m, 30);
1213
- return m + "ms " + A;
1214
- }
1215
- };
1216
- return M;
1217
- }
1218
- function gt({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: r = 500, modifyTarget: o, min: a, max: l, restDelta: u = 0.5, restSpeed: c }) {
1219
- const h = t[0], d = {
1220
- done: !1,
1221
- value: h
1222
- }, f = (p) => a !== void 0 && p < a || l !== void 0 && p > l, b = (p) => a === void 0 ? l : l === void 0 || Math.abs(a - p) < Math.abs(l - p) ? a : l;
1223
- let y = n * e;
1224
- const v = h + y, g = o === void 0 ? v : o(v);
1225
- g !== v && (y = g - h);
1226
- const T = (p) => -y * Math.exp(-p / s), V = (p) => g + T(p), M = (p) => {
1227
- const C = T(p), F = V(p);
1228
- d.done = Math.abs(C) <= u, d.value = d.done ? g : F;
1229
- };
1230
- let m, A;
1231
- const S = (p) => {
1232
- f(d.value) && (m = p, A = Dn({
1233
- keyframes: [d.value, b(d.value)],
1234
- velocity: Fn(V, p, d.value),
1235
- // TODO: This should be passing * 1000
1236
- damping: i,
1237
- stiffness: r,
1238
- restDelta: u,
1239
- restSpeed: c
1240
- }));
1241
- };
1242
- return S(0), {
1243
- calculatedDuration: null,
1244
- next: (p) => {
1245
- let C = !1;
1246
- return !A && m === void 0 && (C = !0, M(p), S(p)), m !== void 0 && p >= m ? A.next(p - m) : (!C && M(p), d);
1247
- }
1248
- };
1249
- }
1250
- const Si = /* @__PURE__ */ Z(0.42, 0, 1, 1), wi = /* @__PURE__ */ Z(0, 0, 0.58, 1), En = /* @__PURE__ */ Z(0.42, 0, 0.58, 1), Pi = (t) => Array.isArray(t) && typeof t[0] != "number", yt = {
1251
- linear: H,
1252
- easeIn: Si,
1253
- easeInOut: En,
1254
- easeOut: wi,
1255
- circIn: $e,
1256
- circInOut: hn,
1257
- circOut: Es,
1258
- backIn: Ge,
1259
- backInOut: un,
1260
- backOut: ln,
1261
- anticipate: cn
1262
- }, vt = (t) => {
1263
- if (Ue(t)) {
1264
- Y(t.length === 4, "Cubic bezier arrays must contain four numerical values.");
1265
- const [e, n, s, i] = t;
1266
- return Z(e, n, s, i);
1267
- } else if (typeof t == "string")
1268
- return Y(yt[t] !== void 0, `Invalid easing type '${t}'`), yt[t];
1269
- return t;
1270
- };
1271
- function Ci(t, e, n) {
1272
- const s = [], i = n || Mn, r = t.length - 1;
1273
- for (let o = 0; o < r; o++) {
1274
- let a = i(t[o], t[o + 1]);
1275
- if (e) {
1276
- const l = Array.isArray(e) ? e[o] || H : e;
1277
- a = he(l, a);
1278
- }
1279
- s.push(a);
1280
- }
1281
- return s;
1282
- }
1283
- function Mi(t, e, { clamp: n = !0, ease: s, mixer: i } = {}) {
1284
- const r = t.length;
1285
- if (Y(r === e.length, "Both input and output ranges must be the same length"), r === 1)
1286
- return () => e[0];
1287
- if (r === 2 && e[0] === e[1])
1288
- return () => e[1];
1289
- const o = t[0] === t[1];
1290
- t[0] > t[r - 1] && (t = [...t].reverse(), e = [...e].reverse());
1291
- const a = Ci(e, s, i), l = a.length, u = (c) => {
1292
- if (o && c < t[0])
1293
- return e[0];
1294
- let h = 0;
1295
- if (l > 1)
1296
- for (; h < t.length - 2 && !(c < t[h + 1]); h++)
1297
- ;
1298
- const d = /* @__PURE__ */ Le(t[h], t[h + 1], c);
1299
- return a[h](d);
1300
- };
1301
- return n ? (c) => u(U(t[0], t[r - 1], c)) : u;
1302
- }
1303
- function Fi(t, e) {
1304
- const n = t[t.length - 1];
1305
- for (let s = 1; s <= e; s++) {
1306
- const i = /* @__PURE__ */ Le(0, e, s);
1307
- t.push(J(n, 1, i));
1308
- }
1309
- }
1310
- function Di(t) {
1311
- const e = [0];
1312
- return Fi(e, t.length - 1), e;
1313
- }
1314
- function Ei(t, e) {
1315
- return t.map((n) => n * e);
1316
- }
1317
- function Ii(t, e) {
1318
- return t.map(() => e || En).splice(0, t.length - 1);
1319
- }
1320
- function ie({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) {
1321
- const i = Pi(s) ? s.map(vt) : vt(s), r = {
1322
- done: !1,
1323
- value: e[0]
1324
- }, o = Ei(
1325
- // Only use the provided offsets if they're the correct length
1326
- // TODO Maybe we should warn here if there's a length mismatch
1327
- n && n.length === e.length ? n : Di(e),
1328
- t
1329
- ), a = Mi(o, e, {
1330
- ease: Array.isArray(i) ? i : Ii(e, i)
1331
- });
1332
- return {
1333
- calculatedDuration: t,
1334
- next: (l) => (r.value = a(l), r.done = l >= t, r)
1335
- };
1336
- }
1337
- const Ri = (t) => {
1338
- const e = ({ timestamp: n }) => t(n);
1339
- return {
1340
- start: () => D.update(e, !0),
1341
- stop: () => Ae(e),
1342
- /**
1343
- * If we're processing this frame we can use the
1344
- * framelocked timestamp to keep things in sync.
1345
- */
1346
- now: () => ee.isProcessing ? ee.timestamp : N.now()
1347
- };
1348
- }, Oi = {
1349
- decay: gt,
1350
- inertia: gt,
1351
- tween: ie,
1352
- keyframes: ie,
1353
- spring: Dn
1354
- }, Ni = (t) => t / 100;
1355
- class Ye extends Pn {
1356
- constructor(e) {
1357
- super(e), this.holdTime = null, this.cancelTime = null, this.currentTime = 0, this.playbackSpeed = 1, this.pendingPlayState = "running", this.startTime = null, this.state = "idle", this.stop = () => {
1358
- if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle")
1359
- return;
1360
- this.teardown();
1361
- const { onStop: l } = this.options;
1362
- l && l();
1363
- };
1364
- const { name: n, motionValue: s, element: i, keyframes: r } = this.options, o = i?.KeyframeResolver || qe, a = (l, u) => this.onKeyframesResolved(l, u);
1365
- this.resolver = new o(r, a, n, s, i), this.resolver.scheduleResolve();
1366
- }
1367
- flatten() {
1368
- super.flatten(), this._resolved && Object.assign(this._resolved, this.initPlayback(this._resolved.keyframes));
1369
- }
1370
- initPlayback(e) {
1371
- const { type: n = "keyframes", repeat: s = 0, repeatDelay: i = 0, repeatType: r, velocity: o = 0 } = this.options, a = ke(n) ? n : Oi[n] || ie;
1372
- let l, u;
1373
- a !== ie && typeof e[0] != "number" && (oe.env.NODE_ENV !== "production" && Y(e.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`), l = he(Ni, Mn(e[0], e[1])), e = [0, 100]);
1374
- const c = a({ ...this.options, keyframes: e });
1375
- r === "mirror" && (u = a({
1376
- ...this.options,
1377
- keyframes: [...e].reverse(),
1378
- velocity: -o
1379
- })), c.calculatedDuration === null && (c.calculatedDuration = qt(c));
1380
- const { calculatedDuration: h } = c, d = h + i, f = d * (s + 1) - i;
1381
- return {
1382
- generator: c,
1383
- mirroredGenerator: u,
1384
- mapPercentToKeyframes: l,
1385
- calculatedDuration: h,
1386
- resolvedDuration: d,
1387
- totalDuration: f
1388
- };
1389
- }
1390
- onPostResolved() {
1391
- const { autoplay: e = !0 } = this.options;
1392
- this.play(), this.pendingPlayState === "paused" || !e ? this.pause() : this.state = this.pendingPlayState;
1393
- }
1394
- tick(e, n = !1) {
1395
- const { resolved: s } = this;
1396
- if (!s) {
1397
- const { keyframes: p } = this.options;
1398
- return { done: !0, value: p[p.length - 1] };
1399
- }
1400
- const { finalKeyframe: i, generator: r, mirroredGenerator: o, mapPercentToKeyframes: a, keyframes: l, calculatedDuration: u, totalDuration: c, resolvedDuration: h } = s;
1401
- if (this.startTime === null)
1402
- return r.next(0);
1403
- const { delay: d, repeat: f, repeatType: b, repeatDelay: y, onUpdate: v } = this.options;
1404
- this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - c / this.speed, this.startTime)), n ? this.currentTime = e : this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = Math.round(e - this.startTime) * this.speed;
1405
- const g = this.currentTime - d * (this.speed >= 0 ? 1 : -1), T = this.speed >= 0 ? g < 0 : g > c;
1406
- this.currentTime = Math.max(g, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = c);
1407
- let V = this.currentTime, M = r;
1408
- if (f) {
1409
- const p = Math.min(this.currentTime, c) / h;
1410
- let C = Math.floor(p), F = p % 1;
1411
- !F && p >= 1 && (F = 1), F === 1 && C--, C = Math.min(C, f + 1), C % 2 && (b === "reverse" ? (F = 1 - F, y && (F -= y / h)) : b === "mirror" && (M = o)), V = U(0, 1, F) * h;
1412
- }
1413
- const m = T ? { done: !1, value: l[0] } : M.next(V);
1414
- a && (m.value = a(m.value));
1415
- let { done: A } = m;
1416
- !T && u !== null && (A = this.speed >= 0 ? this.currentTime >= c : this.currentTime <= 0);
1417
- const S = this.holdTime === null && (this.state === "finished" || this.state === "running" && A);
1418
- return S && i !== void 0 && (m.value = ce(l, this.options, i)), v && v(m.value), S && this.finish(), m;
1419
- }
1420
- get duration() {
1421
- const { resolved: e } = this;
1422
- return e ? /* @__PURE__ */ O(e.calculatedDuration) : 0;
1423
- }
1424
- get time() {
1425
- return /* @__PURE__ */ O(this.currentTime);
1426
- }
1427
- set time(e) {
1428
- e = /* @__PURE__ */ I(e), this.currentTime = e, this.holdTime !== null || this.speed === 0 ? this.holdTime = e : this.driver && (this.startTime = this.driver.now() - e / this.speed);
1429
- }
1430
- get speed() {
1431
- return this.playbackSpeed;
1432
- }
1433
- set speed(e) {
1434
- const n = this.playbackSpeed !== e;
1435
- this.playbackSpeed = e, n && (this.time = /* @__PURE__ */ O(this.currentTime));
1436
- }
1437
- play() {
1438
- if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) {
1439
- this.pendingPlayState = "running";
1440
- return;
1441
- }
1442
- if (this.isStopped)
1443
- return;
1444
- const { driver: e = Ri, onPlay: n, startTime: s } = this.options;
1445
- this.driver || (this.driver = e((r) => this.tick(r))), n && n();
1446
- const i = this.driver.now();
1447
- this.holdTime !== null ? this.startTime = i - this.holdTime : this.startTime ? this.state === "finished" && (this.startTime = i) : this.startTime = s ?? this.calcStartTime(), this.state === "finished" && this.updateFinishedPromise(), this.cancelTime = this.startTime, this.holdTime = null, this.state = "running", this.driver.start();
1448
- }
1449
- pause() {
1450
- var e;
1451
- if (!this._resolved) {
1452
- this.pendingPlayState = "paused";
1453
- return;
1454
- }
1455
- this.state = "paused", this.holdTime = (e = this.currentTime) !== null && e !== void 0 ? e : 0;
1456
- }
1457
- complete() {
1458
- this.state !== "running" && this.play(), this.pendingPlayState = this.state = "finished", this.holdTime = null;
1459
- }
1460
- finish() {
1461
- this.teardown(), this.state = "finished";
1462
- const { onComplete: e } = this.options;
1463
- e && e();
1464
- }
1465
- cancel() {
1466
- this.cancelTime !== null && this.tick(this.cancelTime), this.teardown(), this.updateFinishedPromise();
1467
- }
1468
- teardown() {
1469
- this.state = "idle", this.stopDriver(), this.resolveFinishedPromise(), this.updateFinishedPromise(), this.startTime = this.cancelTime = null, this.resolver.cancel();
1470
- }
1471
- stopDriver() {
1472
- this.driver && (this.driver.stop(), this.driver = void 0);
1473
- }
1474
- sample(e) {
1475
- return this.startTime = 0, this.tick(e, !0);
1476
- }
1477
- }
1478
- const Ki = /* @__PURE__ */ new Set([
1479
- "opacity",
1480
- "clipPath",
1481
- "filter",
1482
- "transform"
1483
- // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
1484
- // or until we implement support for linear() easing.
1485
- // "background-color"
1486
- ]);
1487
- function Bi(t, e, n, { delay: s = 0, duration: i = 300, repeat: r = 0, repeatType: o = "loop", ease: a = "easeInOut", times: l } = {}) {
1488
- const u = { [e]: n };
1489
- l && (u.offset = l);
1490
- const c = Xt(a, i);
1491
- return Array.isArray(c) && (u.easing = c), t.animate(u, {
1492
- delay: s,
1493
- duration: i,
1494
- easing: Array.isArray(c) ? "linear" : c,
1495
- fill: "both",
1496
- iterations: r + 1,
1497
- direction: o === "reverse" ? "alternate" : "normal"
1498
- });
1499
- }
1500
- const _i = /* @__PURE__ */ _e(() => Object.hasOwnProperty.call(Element.prototype, "animate")), re = 10, Li = 2e4;
1501
- function ki(t) {
1502
- return ke(t.type) || t.type === "spring" || !Yt(t.ease);
1503
- }
1504
- function Ui(t, e) {
1505
- const n = new Ye({
1506
- ...e,
1507
- keyframes: t,
1508
- repeat: 0,
1509
- delay: 0,
1510
- isGenerator: !0
1511
- });
1512
- let s = { done: !1, value: t[0] };
1513
- const i = [];
1514
- let r = 0;
1515
- for (; !s.done && r < Li; )
1516
- s = n.sample(r), i.push(s.value), r += re;
1517
- return {
1518
- times: void 0,
1519
- keyframes: i,
1520
- duration: r - re,
1521
- ease: "linear"
1522
- };
1523
- }
1524
- const In = {
1525
- anticipate: cn,
1526
- backInOut: un,
1527
- circInOut: hn
1528
- };
1529
- function Gi(t) {
1530
- return t in In;
1531
- }
1532
- class bt extends Pn {
1533
- constructor(e) {
1534
- super(e);
1535
- const { name: n, motionValue: s, element: i, keyframes: r } = this.options;
1536
- this.resolver = new wn(r, (o, a) => this.onKeyframesResolved(o, a), n, s, i), this.resolver.scheduleResolve();
1537
- }
1538
- initPlayback(e, n) {
1539
- let { duration: s = 300, times: i, ease: r, type: o, motionValue: a, name: l, startTime: u } = this.options;
1540
- if (!a.owner || !a.owner.current)
1541
- return !1;
1542
- if (typeof r == "string" && te() && Gi(r) && (r = In[r]), ki(this.options)) {
1543
- const { onComplete: h, onUpdate: d, motionValue: f, element: b, ...y } = this.options, v = Ui(e, y);
1544
- e = v.keyframes, e.length === 1 && (e[1] = e[0]), s = v.duration, i = v.times, r = v.ease, o = "keyframes";
1545
- }
1546
- const c = Bi(a.owner.current, l, e, { ...this.options, duration: s, times: i, ease: r });
1547
- return c.startTime = u ?? this.calcStartTime(), this.pendingTimeline ? (tt(c, this.pendingTimeline), this.pendingTimeline = void 0) : c.onfinish = () => {
1548
- const { onComplete: h } = this.options;
1549
- a.set(ce(e, this.options, n)), h && h(), this.cancel(), this.resolveFinishedPromise();
1550
- }, {
1551
- animation: c,
1552
- duration: s,
1553
- times: i,
1554
- type: o,
1555
- ease: r,
1556
- keyframes: e
1557
- };
1558
- }
1559
- get duration() {
1560
- const { resolved: e } = this;
1561
- if (!e)
1562
- return 0;
1563
- const { duration: n } = e;
1564
- return /* @__PURE__ */ O(n);
1565
- }
1566
- get time() {
1567
- const { resolved: e } = this;
1568
- if (!e)
1569
- return 0;
1570
- const { animation: n } = e;
1571
- return /* @__PURE__ */ O(n.currentTime || 0);
1572
- }
1573
- set time(e) {
1574
- const { resolved: n } = this;
1575
- if (!n)
1576
- return;
1577
- const { animation: s } = n;
1578
- s.currentTime = /* @__PURE__ */ I(e);
1579
- }
1580
- get speed() {
1581
- const { resolved: e } = this;
1582
- if (!e)
1583
- return 1;
1584
- const { animation: n } = e;
1585
- return n.playbackRate;
1586
- }
1587
- set speed(e) {
1588
- const { resolved: n } = this;
1589
- if (!n)
1590
- return;
1591
- const { animation: s } = n;
1592
- s.playbackRate = e;
1593
- }
1594
- get state() {
1595
- const { resolved: e } = this;
1596
- if (!e)
1597
- return "idle";
1598
- const { animation: n } = e;
1599
- return n.playState;
1600
- }
1601
- get startTime() {
1602
- const { resolved: e } = this;
1603
- if (!e)
1604
- return null;
1605
- const { animation: n } = e;
1606
- return n.startTime;
1607
- }
1608
- /**
1609
- * Replace the default DocumentTimeline with another AnimationTimeline.
1610
- * Currently used for scroll animations.
1611
- */
1612
- attachTimeline(e) {
1613
- if (!this._resolved)
1614
- this.pendingTimeline = e;
1615
- else {
1616
- const { resolved: n } = this;
1617
- if (!n)
1618
- return H;
1619
- const { animation: s } = n;
1620
- tt(s, e);
1621
- }
1622
- return H;
1623
- }
1624
- play() {
1625
- if (this.isStopped)
1626
- return;
1627
- const { resolved: e } = this;
1628
- if (!e)
1629
- return;
1630
- const { animation: n } = e;
1631
- n.playState === "finished" && this.updateFinishedPromise(), n.play();
1632
- }
1633
- pause() {
1634
- const { resolved: e } = this;
1635
- if (!e)
1636
- return;
1637
- const { animation: n } = e;
1638
- n.pause();
1639
- }
1640
- stop() {
1641
- if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle")
1642
- return;
1643
- this.resolveFinishedPromise(), this.updateFinishedPromise();
1644
- const { resolved: e } = this;
1645
- if (!e)
1646
- return;
1647
- const { animation: n, keyframes: s, duration: i, type: r, ease: o, times: a } = e;
1648
- if (n.playState === "idle" || n.playState === "finished")
1649
- return;
1650
- if (this.time) {
1651
- const { motionValue: u, onUpdate: c, onComplete: h, element: d, ...f } = this.options, b = new Ye({
1652
- ...f,
1653
- keyframes: s,
1654
- duration: i,
1655
- type: r,
1656
- ease: o,
1657
- times: a,
1658
- isGenerator: !0
1659
- }), y = /* @__PURE__ */ I(this.time);
1660
- u.setWithVelocity(b.sample(y - re).value, b.sample(y).value, re);
1661
- }
1662
- const { onStop: l } = this.options;
1663
- l && l(), this.cancel();
1664
- }
1665
- complete() {
1666
- const { resolved: e } = this;
1667
- e && e.animation.finish();
1668
- }
1669
- cancel() {
1670
- const { resolved: e } = this;
1671
- e && e.animation.cancel();
1672
- }
1673
- static supports(e) {
1674
- const { motionValue: n, name: s, repeatDelay: i, repeatType: r, damping: o, type: a } = e;
1675
- if (!n || !n.owner || !(n.owner.current instanceof HTMLElement))
1676
- return !1;
1677
- const { onUpdate: l, transformTemplate: u } = n.owner.getProps();
1678
- return _i() && s && Ki.has(s) && /**
1679
- * If we're outputting values to onUpdate then we can't use WAAPI as there's
1680
- * no way to read the value from WAAPI every frame.
1681
- */
1682
- !l && !u && !i && r !== "mirror" && o !== 0 && a !== "inertia";
1683
- }
1684
- }
1685
- const $i = {
1686
- type: "spring",
1687
- stiffness: 500,
1688
- damping: 25,
1689
- restSpeed: 10
1690
- }, ji = (t) => ({
1691
- type: "spring",
1692
- stiffness: 550,
1693
- damping: t === 0 ? 2 * Math.sqrt(550) : 30,
1694
- restSpeed: 10
1695
- }), Wi = {
1696
- type: "keyframes",
1697
- duration: 0.8
1698
- }, zi = {
1699
- type: "keyframes",
1700
- ease: [0.25, 0.1, 0.35, 1],
1701
- duration: 0.3
1702
- }, qi = (t, { keyframes: e }) => e.length > 2 ? Wi : le.has(t) ? t.startsWith("scale") ? ji(e[1]) : $i : zi;
1703
- function Hi({ when: t, delay: e, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: r, repeatType: o, repeatDelay: a, from: l, elapsed: u, ...c }) {
1704
- return !!Object.keys(c).length;
1705
- }
1706
- const Yi = (t, e, n, s = {}, i, r) => (o) => {
1707
- const a = zt(s, t) || {}, l = a.delay || s.delay || 0;
1708
- let { elapsed: u = 0 } = s;
1709
- u = u - /* @__PURE__ */ I(l);
1710
- let c = {
1711
- keyframes: Array.isArray(n) ? n : [null, n],
1712
- ease: "easeOut",
1713
- velocity: e.getVelocity(),
1714
- ...a,
1715
- delay: -u,
1716
- onUpdate: (d) => {
1717
- e.set(d), a.onUpdate && a.onUpdate(d);
1718
- },
1719
- onComplete: () => {
1720
- o(), a.onComplete && a.onComplete();
1721
- },
1722
- name: t,
1723
- motionValue: e,
1724
- element: r ? void 0 : i
1725
- };
1726
- Hi(a) || (c = {
1727
- ...c,
1728
- ...qi(t, c)
1729
- }), c.duration && (c.duration = /* @__PURE__ */ I(c.duration)), c.repeatDelay && (c.repeatDelay = /* @__PURE__ */ I(c.repeatDelay)), c.from !== void 0 && (c.keyframes[0] = c.from);
1730
- let h = !1;
1731
- if ((c.type === !1 || c.duration === 0 && !c.repeatDelay) && (c.duration = 0, c.delay === 0 && (h = !0)), _t.skipAnimations && (h = !0, c.duration = 0, c.delay = 0), h && !r && e.get() !== void 0) {
1732
- const d = ce(c.keyframes, a);
1733
- if (d !== void 0)
1734
- return D.update(() => {
1735
- c.onUpdate(d), c.onComplete();
1736
- }), new us([]);
1737
- }
1738
- return !r && bt.supports(c) ? new bt(c) : new Ye(c);
1739
- };
1740
- function Xi({ protectedKeys: t, needsAnimating: e }, n) {
1741
- const s = t.hasOwnProperty(n) && e[n] !== !0;
1742
- return e[n] = !1, s;
1743
- }
1744
- function Rn(t, e, { delay: n = 0, transitionOverride: s, type: i } = {}) {
1745
- var r;
1746
- let { transition: o = t.getDefaultTransition(), transitionEnd: a, ...l } = e;
1747
- s && (o = s);
1748
- const u = [], c = i && t.animationState && t.animationState.getState()[i];
1749
- for (const h in l) {
1750
- const d = t.getValue(h, (r = t.latestValues[h]) !== null && r !== void 0 ? r : null), f = l[h];
1751
- if (f === void 0 || c && Xi(c, h))
1752
- continue;
1753
- const b = {
1754
- delay: n,
1755
- ...zt(o || {}, h)
1756
- };
1757
- let y = !1;
1758
- if (window.MotionHandoffAnimation) {
1759
- const g = Cs(t);
1760
- if (g) {
1761
- const T = window.MotionHandoffAnimation(g, h, D);
1762
- T !== null && (b.startTime = T, y = !0);
1763
- }
1764
- }
1765
- Ps(t, h), d.start(Yi(h, d, f, t.shouldReduceMotion && tn.has(h) ? { type: !1 } : b, t, y));
1766
- const v = d.animation;
1767
- v && u.push(v);
1768
- }
1769
- return a && Promise.all(u).then(() => {
1770
- D.update(() => {
1771
- a && Ss(t, a);
1772
- });
1773
- }), u;
1774
- }
1775
- function Ee(t, e, n = {}) {
1776
- var s;
1777
- const i = ue(t, e, n.type === "exit" ? (s = t.presenceContext) === null || s === void 0 ? void 0 : s.custom : void 0);
1778
- let { transition: r = t.getDefaultTransition() || {} } = i || {};
1779
- n.transitionOverride && (r = n.transitionOverride);
1780
- const o = i ? () => Promise.all(Rn(t, i, n)) : () => Promise.resolve(), a = t.variantChildren && t.variantChildren.size ? (u = 0) => {
1781
- const { delayChildren: c = 0, staggerChildren: h, staggerDirection: d } = r;
1782
- return Zi(t, e, c + u, h, d, n);
1783
- } : () => Promise.resolve(), { when: l } = r;
1784
- if (l) {
1785
- const [u, c] = l === "beforeChildren" ? [o, a] : [a, o];
1786
- return u().then(() => c());
1787
- } else
1788
- return Promise.all([o(), a(n.delay)]);
1789
- }
1790
- function Zi(t, e, n = 0, s = 0, i = 1, r) {
1791
- const o = [], a = (t.variantChildren.size - 1) * s, l = i === 1 ? (u = 0) => u * s : (u = 0) => a - u * s;
1792
- return Array.from(t.variantChildren).sort(Ji).forEach((u, c) => {
1793
- u.notify("AnimationStart", e), o.push(Ee(u, e, {
1794
- ...r,
1795
- delay: n + l(c)
1796
- }).then(() => u.notify("AnimationComplete", e)));
1797
- }), Promise.all(o);
1798
- }
1799
- function Ji(t, e) {
1800
- return t.sortNodePosition(e);
1801
- }
1802
- function Qi(t, e, n = {}) {
1803
- t.notify("AnimationStart", e);
1804
- let s;
1805
- if (Array.isArray(e)) {
1806
- const i = e.map((r) => Ee(t, r, n));
1807
- s = Promise.all(i);
1808
- } else if (typeof e == "string")
1809
- s = Ee(t, e, n);
1810
- else {
1811
- const i = typeof e == "function" ? ue(t, e, n.custom) : e;
1812
- s = Promise.all(Rn(t, i, n));
1813
- }
1814
- return s.then(() => {
1815
- t.notify("AnimationComplete", e);
1816
- });
1817
- }
1818
- const er = Gt.length;
1819
- function On(t) {
1820
- if (!t)
1821
- return;
1822
- if (!t.isControllingVariants) {
1823
- const n = t.parent ? On(t.parent) || {} : {};
1824
- return t.props.initial !== void 0 && (n.initial = t.props.initial), n;
1825
- }
1826
- const e = {};
1827
- for (let n = 0; n < er; n++) {
1828
- const s = Gt[n], i = t.props[s];
1829
- (Ut(i) || i === !1) && (e[s] = i);
1830
- }
1831
- return e;
1832
- }
1833
- const tr = [...jt].reverse(), nr = jt.length;
1834
- function sr(t) {
1835
- return (e) => Promise.all(e.map(({ animation: n, options: s }) => Qi(t, n, s)));
1836
- }
1837
- function ir(t) {
1838
- let e = sr(t), n = Tt(), s = !0;
1839
- const i = (l) => (u, c) => {
1840
- var h;
1841
- const d = ue(t, c, l === "exit" ? (h = t.presenceContext) === null || h === void 0 ? void 0 : h.custom : void 0);
1842
- if (d) {
1843
- const { transition: f, transitionEnd: b, ...y } = d;
1844
- u = { ...u, ...y, ...b };
1845
- }
1846
- return u;
1847
- };
1848
- function r(l) {
1849
- e = l(t);
1850
- }
1851
- function o(l) {
1852
- const { props: u } = t, c = On(t.parent) || {}, h = [], d = /* @__PURE__ */ new Set();
1853
- let f = {}, b = 1 / 0;
1854
- for (let v = 0; v < nr; v++) {
1855
- const g = tr[v], T = n[g], V = u[g] !== void 0 ? u[g] : c[g], M = Ut(V), m = g === l ? T.isActive : null;
1856
- m === !1 && (b = v);
1857
- let A = V === c[g] && V !== u[g] && M;
1858
- if (A && s && t.manuallyAnimateOnMount && (A = !1), T.protectedKeys = { ...f }, // If it isn't active and hasn't *just* been set as inactive
1859
- !T.isActive && m === null || // If we didn't and don't have any defined prop for this animation type
1860
- !V && !T.prevProp || // Or if the prop doesn't define an animation
1861
- $t(V) || typeof V == "boolean")
1862
- continue;
1863
- const S = rr(T.prevProp, V);
1864
- let p = S || // If we're making this variant active, we want to always make it active
1865
- g === l && T.isActive && !A && M || // If we removed a higher-priority variant (i is in reverse order)
1866
- v > b && M, C = !1;
1867
- const F = Array.isArray(V) ? V : [V];
1868
- let L = F.reduce(i(g), {});
1869
- m === !1 && (L = {});
1870
- const { prevResolvedValues: Ze = {} } = T, Ln = {
1871
- ...Ze,
1872
- ...L
1873
- }, Je = (P) => {
1874
- p = !0, d.has(P) && (C = !0, d.delete(P)), T.needsAnimating[P] = !0;
1875
- const E = t.getValue(P);
1876
- E && (E.liveStyle = !1);
1877
- };
1878
- for (const P in Ln) {
1879
- const E = L[P], de = Ze[P];
1880
- if (f.hasOwnProperty(P))
1881
- continue;
1882
- let fe = !1;
1883
- Qe(E) && Qe(de) ? fe = !Wt(E, de) : fe = E !== de, fe ? E != null ? Je(P) : d.add(P) : E !== void 0 && d.has(P) ? Je(P) : T.protectedKeys[P] = !0;
1884
- }
1885
- T.prevProp = V, T.prevResolvedValues = L, T.isActive && (f = { ...f, ...L }), s && t.blockInitialAnimation && (p = !1), p && (!(A && S) || C) && h.push(...F.map((P) => ({
1886
- animation: P,
1887
- options: { type: g }
1888
- })));
1889
- }
1890
- if (d.size) {
1891
- const v = {};
1892
- d.forEach((g) => {
1893
- const T = t.getBaseTarget(g), V = t.getValue(g);
1894
- V && (V.liveStyle = !0), v[g] = T ?? null;
1895
- }), h.push({ animation: v });
1896
- }
1897
- let y = !!h.length;
1898
- return s && (u.initial === !1 || u.initial === u.animate) && !t.manuallyAnimateOnMount && (y = !1), s = !1, y ? e(h) : Promise.resolve();
1899
- }
1900
- function a(l, u) {
1901
- var c;
1902
- if (n[l].isActive === u)
1903
- return Promise.resolve();
1904
- (c = t.variantChildren) === null || c === void 0 || c.forEach((d) => {
1905
- var f;
1906
- return (f = d.animationState) === null || f === void 0 ? void 0 : f.setActive(l, u);
1907
- }), n[l].isActive = u;
1908
- const h = o(l);
1909
- for (const d in n)
1910
- n[d].protectedKeys = {};
1911
- return h;
1912
- }
1913
- return {
1914
- animateChanges: o,
1915
- setActive: a,
1916
- setAnimateFunction: r,
1917
- getState: () => n,
1918
- reset: () => {
1919
- n = Tt(), s = !0;
1920
- }
1921
- };
1922
- }
1923
- function rr(t, e) {
1924
- return typeof e == "string" ? e !== t : Array.isArray(e) ? !Wt(e, t) : !1;
1925
- }
1926
- function K(t = !1) {
1927
- return {
1928
- isActive: t,
1929
- protectedKeys: {},
1930
- needsAnimating: {},
1931
- prevResolvedValues: {}
1932
- };
1933
- }
1934
- function Tt() {
1935
- return {
1936
- animate: K(!0),
1937
- whileInView: K(),
1938
- whileHover: K(),
1939
- whileTap: K(),
1940
- whileDrag: K(),
1941
- whileFocus: K(),
1942
- exit: K()
1943
- };
1944
- }
1945
- class j {
1946
- constructor(e) {
1947
- this.isMounted = !1, this.node = e;
1948
- }
1949
- update() {
1950
- }
1951
- }
1952
- class or extends j {
1953
- /**
1954
- * We dynamically generate the AnimationState manager as it contains a reference
1955
- * to the underlying animation library. We only want to load that if we load this,
1956
- * so people can optionally code split it out using the `m` component.
1957
- */
1958
- constructor(e) {
1959
- super(e), e.animationState || (e.animationState = ir(e));
1960
- }
1961
- updateAnimationControlsSubscription() {
1962
- const { animate: e } = this.node.getProps();
1963
- $t(e) && (this.unmountControls = e.subscribe(this.node));
1964
- }
1965
- /**
1966
- * Subscribe any provided AnimationControls to the component's VisualElement
1967
- */
1968
- mount() {
1969
- this.updateAnimationControlsSubscription();
1970
- }
1971
- update() {
1972
- const { animate: e } = this.node.getProps(), { animate: n } = this.node.prevProps || {};
1973
- e !== n && this.updateAnimationControlsSubscription();
1974
- }
1975
- unmount() {
1976
- var e;
1977
- this.node.animationState.reset(), (e = this.unmountControls) === null || e === void 0 || e.call(this);
1978
- }
1979
- }
1980
- let ar = 0;
1981
- class lr extends j {
1982
- constructor() {
1983
- super(...arguments), this.id = ar++;
1984
- }
1985
- update() {
1986
- if (!this.node.presenceContext)
1987
- return;
1988
- const { isPresent: e, onExitComplete: n } = this.node.presenceContext, { isPresent: s } = this.node.prevPresenceContext || {};
1989
- if (!this.node.animationState || e === s)
1990
- return;
1991
- const i = this.node.animationState.setActive("exit", !e);
1992
- n && !e && i.then(() => n(this.id));
1993
- }
1994
- mount() {
1995
- const { register: e } = this.node.presenceContext || {};
1996
- e && (this.unmount = e(this.id));
1997
- }
1998
- unmount() {
1999
- }
2000
- }
2001
- const ur = {
2002
- animation: {
2003
- Feature: or
2004
- },
2005
- exit: {
2006
- Feature: lr
2007
- }
2008
- };
2009
- function Vt(t, e, n, s = { passive: !0 }) {
2010
- return t.addEventListener(e, n, s), () => t.removeEventListener(e, n);
2011
- }
2012
- function Xe(t) {
2013
- return {
2014
- point: {
2015
- x: t.pageX,
2016
- y: t.pageY
2017
- }
2018
- };
2019
- }
2020
- const kr = (t) => (e) => en(e) && t(e, Xe(e)), At = () => ({
2021
- translate: 0,
2022
- scale: 1,
2023
- origin: 0,
2024
- originPoint: 0
2025
- }), Ur = () => ({
2026
- x: At(),
2027
- y: At()
2028
- }), xt = () => ({ min: 0, max: 0 }), Nn = () => ({
2029
- x: xt(),
2030
- y: xt()
2031
- });
2032
- function cr({ top: t, left: e, right: n, bottom: s }) {
2033
- return {
2034
- x: { min: e, max: n },
2035
- y: { min: t, max: s }
2036
- };
2037
- }
2038
- function Gr({ x: t, y: e }) {
2039
- return { top: e.min, right: t.max, bottom: e.max, left: t.min };
2040
- }
2041
- function hr(t, e) {
2042
- if (!e)
2043
- return t;
2044
- const n = e({ x: t.left, y: t.top }), s = e({ x: t.right, y: t.bottom });
2045
- return {
2046
- top: n.y,
2047
- left: n.x,
2048
- bottom: s.y,
2049
- right: s.x
2050
- };
2051
- }
2052
- function be(t) {
2053
- return t === void 0 || t === 1;
2054
- }
2055
- function dr({ scale: t, scaleX: e, scaleY: n }) {
2056
- return !be(t) || !be(e) || !be(n);
2057
- }
2058
- function fr(t) {
2059
- return dr(t) || pr(t) || t.z || t.rotate || t.rotateX || t.rotateY || t.skewX || t.skewY;
2060
- }
2061
- function pr(t) {
2062
- return St(t.x) || St(t.y);
2063
- }
2064
- function St(t) {
2065
- return t && t !== "0%";
2066
- }
2067
- function wt(t, e, n) {
2068
- const s = t - n, i = e * s;
2069
- return n + i;
2070
- }
2071
- function Pt(t, e, n, s, i) {
2072
- return i !== void 0 && (t = wt(t, i, s)), wt(t, n, s) + e;
2073
- }
2074
- function Ie(t, e = 0, n = 1, s, i) {
2075
- t.min = Pt(t.min, e, n, s, i), t.max = Pt(t.max, e, n, s, i);
2076
- }
2077
- function mr(t, { x: e, y: n }) {
2078
- Ie(t.x, e.translate, e.scale, e.originPoint), Ie(t.y, n.translate, n.scale, n.originPoint);
2079
- }
2080
- const Ct = 0.999999999999, Mt = 1.0000000000001;
2081
- function $r(t, e, n, s = !1) {
2082
- const i = n.length;
2083
- if (!i)
2084
- return;
2085
- e.x = e.y = 1;
2086
- let r, o;
2087
- for (let a = 0; a < i; a++) {
2088
- r = n[a], o = r.projectionDelta;
2089
- const { visualElement: l } = r.options;
2090
- l && l.props.style && l.props.style.display === "contents" || (s && r.options.layoutScroll && r.scroll && r !== r.root && Et(t, {
2091
- x: -r.scroll.offset.x,
2092
- y: -r.scroll.offset.y
2093
- }), o && (e.x *= o.x.scale, e.y *= o.y.scale, mr(t, o)), s && fr(r.latestValues) && Et(t, r.latestValues));
2094
- }
2095
- e.x < Mt && e.x > Ct && (e.x = 1), e.y < Mt && e.y > Ct && (e.y = 1);
2096
- }
2097
- function Ft(t, e) {
2098
- t.min = t.min + e, t.max = t.max + e;
2099
- }
2100
- function Dt(t, e, n, s, i = 0.5) {
2101
- const r = J(t.min, t.max, i);
2102
- Ie(t, e, n, r, s);
2103
- }
2104
- function Et(t, e) {
2105
- Dt(t.x, e.x, e.scaleX, e.scale, e.originX), Dt(t.y, e.y, e.scaleY, e.scale, e.originY);
2106
- }
2107
- function Kn(t, e) {
2108
- return cr(hr(t.getBoundingClientRect(), e));
2109
- }
2110
- function jr(t, e, n) {
2111
- const s = Kn(t, n), { scroll: i } = e;
2112
- return i && (Ft(s.x, i.offset.x), Ft(s.y, i.offset.y)), s;
2113
- }
2114
- function It(t, e, n) {
2115
- const { props: s } = t;
2116
- t.animationState && s.whileHover && t.animationState.setActive("whileHover", n === "Start");
2117
- const i = "onHover" + n, r = s[i];
2118
- r && D.postRender(() => r(e, Xe(e)));
2119
- }
2120
- class gr extends j {
2121
- mount() {
2122
- const { current: e } = this.node;
2123
- e && (this.unmount = fs(e, (n) => (It(this.node, n, "Start"), (s) => It(this.node, s, "End"))));
2124
- }
2125
- unmount() {
2126
- }
2127
- }
2128
- class yr extends j {
2129
- constructor() {
2130
- super(...arguments), this.isActive = !1;
2131
- }
2132
- onFocus() {
2133
- let e = !1;
2134
- try {
2135
- e = this.node.current.matches(":focus-visible");
2136
- } catch {
2137
- e = !0;
2138
- }
2139
- !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
2140
- }
2141
- onBlur() {
2142
- !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
2143
- }
2144
- mount() {
2145
- this.unmount = he(Vt(this.node.current, "focus", () => this.onFocus()), Vt(this.node.current, "blur", () => this.onBlur()));
2146
- }
2147
- unmount() {
2148
- }
2149
- }
2150
- function Rt(t, e, n) {
2151
- const { props: s } = t;
2152
- t.animationState && s.whileTap && t.animationState.setActive("whileTap", n === "Start");
2153
- const i = "onTap" + (n === "End" ? "" : n), r = s[i];
2154
- r && D.postRender(() => r(e, Xe(e)));
2155
- }
2156
- class vr extends j {
2157
- mount() {
2158
- const { current: e } = this.node;
2159
- e && (this.unmount = ys(e, (n) => (Rt(this.node, n, "Start"), (s, { success: i }) => Rt(this.node, s, i ? "End" : "Cancel")), { useGlobalTarget: this.node.props.globalTapTarget }));
2160
- }
2161
- unmount() {
2162
- }
2163
- }
2164
- const Re = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), br = (t) => {
2165
- const e = Re.get(t.target);
2166
- e && e(t);
2167
- }, Tr = (t) => {
2168
- t.forEach(br);
2169
- };
2170
- function Vr({ root: t, ...e }) {
2171
- const n = t || document;
2172
- Te.has(n) || Te.set(n, {});
2173
- const s = Te.get(n), i = JSON.stringify(e);
2174
- return s[i] || (s[i] = new IntersectionObserver(Tr, { root: t, ...e })), s[i];
2175
- }
2176
- function Ar(t, e, n) {
2177
- const s = Vr(e);
2178
- return Re.set(t, n), s.observe(t), () => {
2179
- Re.delete(t), s.unobserve(t);
2180
- };
2181
- }
2182
- const xr = {
2183
- some: 0,
2184
- all: 1
2185
- };
2186
- class Sr extends j {
2187
- constructor() {
2188
- super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
2189
- }
2190
- startObserver() {
2191
- this.unmount();
2192
- const { viewport: e = {} } = this.node.getProps(), { root: n, margin: s, amount: i = "some", once: r } = e, o = {
2193
- root: n ? n.current : void 0,
2194
- rootMargin: s,
2195
- threshold: typeof i == "number" ? i : xr[i]
2196
- }, a = (l) => {
2197
- const { isIntersecting: u } = l;
2198
- if (this.isInView === u || (this.isInView = u, r && !u && this.hasEnteredView))
2199
- return;
2200
- u && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", u);
2201
- const { onViewportEnter: c, onViewportLeave: h } = this.node.getProps(), d = u ? c : h;
2202
- d && d(l);
2203
- };
2204
- return Ar(this.node.current, o, a);
2205
- }
2206
- mount() {
2207
- this.startObserver();
2208
- }
2209
- update() {
2210
- if (typeof IntersectionObserver > "u")
2211
- return;
2212
- const { props: e, prevProps: n } = this.node;
2213
- ["amount", "margin", "root"].some(wr(e, n)) && this.startObserver();
2214
- }
2215
- unmount() {
2216
- }
2217
- }
2218
- function wr({ viewport: t = {} }, { viewport: e = {} } = {}) {
2219
- return (n) => t[n] !== e[n];
2220
- }
2221
- const Pr = {
2222
- inView: {
2223
- Feature: Sr
2224
- },
2225
- tap: {
2226
- Feature: vr
2227
- },
2228
- focus: {
2229
- Feature: yr
2230
- },
2231
- hover: {
2232
- Feature: gr
2233
- }
2234
- }, Oe = { current: null }, Bn = { current: !1 };
2235
- function Cr() {
2236
- if (Bn.current = !0, !!zn)
2237
- if (window.matchMedia) {
2238
- const t = window.matchMedia("(prefers-reduced-motion)"), e = () => Oe.current = t.matches;
2239
- t.addListener(e), e();
2240
- } else
2241
- Oe.current = !1;
2242
- }
2243
- const Mr = [...Sn, w, $], Fr = (t) => Mr.find(xn(t)), Ot = /* @__PURE__ */ new WeakMap();
2244
- function Dr(t, e, n) {
2245
- for (const s in e) {
2246
- const i = e[s], r = n[s];
2247
- if (R(i))
2248
- t.addValue(s, i), oe.env.NODE_ENV === "development" && Ne(i.version === "11.18.2", `Attempting to mix Motion versions ${i.version} with 11.18.2 may not work as expected.`);
2249
- else if (R(r))
2250
- t.addValue(s, ne(i, { owner: t }));
2251
- else if (r !== i)
2252
- if (t.hasValue(s)) {
2253
- const o = t.getValue(s);
2254
- o.liveStyle === !0 ? o.jump(i) : o.hasAnimated || o.set(i);
2255
- } else {
2256
- const o = t.getStaticValue(s);
2257
- t.addValue(s, ne(o !== void 0 ? o : i, { owner: t }));
2258
- }
2259
- }
2260
- for (const s in n)
2261
- e[s] === void 0 && t.removeValue(s);
2262
- return e;
2263
- }
2264
- const Nt = [
2265
- "AnimationStart",
2266
- "AnimationComplete",
2267
- "Update",
2268
- "BeforeLayoutMeasure",
2269
- "LayoutMeasure",
2270
- "LayoutAnimationStart",
2271
- "LayoutAnimationComplete"
2272
- ];
2273
- class Er {
2274
- /**
2275
- * This method takes React props and returns found MotionValues. For example, HTML
2276
- * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
2277
- *
2278
- * This isn't an abstract method as it needs calling in the constructor, but it is
2279
- * intended to be one.
2280
- */
2281
- scrapeMotionValuesFromProps(e, n, s) {
2282
- return {};
2283
- }
2284
- constructor({ parent: e, props: n, presenceContext: s, reducedMotionConfig: i, blockInitialAnimation: r, visualState: o }, a = {}) {
2285
- this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = qe, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => {
2286
- this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
2287
- }, this.renderScheduledAt = 0, this.scheduleRender = () => {
2288
- const f = N.now();
2289
- this.renderScheduledAt < f && (this.renderScheduledAt = f, D.render(this.render, !1, !0));
2290
- };
2291
- const { latestValues: l, renderState: u, onUpdate: c } = o;
2292
- this.onUpdate = c, this.latestValues = l, this.baseTarget = { ...l }, this.initialValues = n.initial ? { ...l } : {}, this.renderState = u, this.parent = e, this.props = n, this.presenceContext = s, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!r, this.isControllingVariants = qn(n), this.isVariantNode = Hn(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current);
2293
- const { willChange: h, ...d } = this.scrapeMotionValuesFromProps(n, {}, this);
2294
- for (const f in d) {
2295
- const b = d[f];
2296
- l[f] !== void 0 && R(b) && b.set(l[f], !1);
2297
- }
2298
- }
2299
- mount(e) {
2300
- this.current = e, Ot.set(e, this), this.projection && !this.projection.instance && this.projection.mount(e), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((n, s) => this.bindToMotionValue(s, n)), Bn.current || Cr(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : Oe.current, oe.env.NODE_ENV !== "production" && Ne(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected."), this.parent && this.parent.children.add(this), this.update(this.props, this.presenceContext);
2301
- }
2302
- unmount() {
2303
- Ot.delete(this.current), this.projection && this.projection.unmount(), Ae(this.notifyUpdate), Ae(this.render), this.valueSubscriptions.forEach((e) => e()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent && this.parent.children.delete(this);
2304
- for (const e in this.events)
2305
- this.events[e].clear();
2306
- for (const e in this.features) {
2307
- const n = this.features[e];
2308
- n && (n.unmount(), n.isMounted = !1);
2309
- }
2310
- this.current = null;
2311
- }
2312
- bindToMotionValue(e, n) {
2313
- this.valueSubscriptions.has(e) && this.valueSubscriptions.get(e)();
2314
- const s = le.has(e), i = n.on("change", (a) => {
2315
- this.latestValues[e] = a, this.props.onUpdate && D.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0);
2316
- }), r = n.on("renderRequest", this.scheduleRender);
2317
- let o;
2318
- window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, e, n)), this.valueSubscriptions.set(e, () => {
2319
- i(), r(), o && o(), n.owner && n.stop();
2320
- });
2321
- }
2322
- sortNodePosition(e) {
2323
- return !this.current || !this.sortInstanceNodePosition || this.type !== e.type ? 0 : this.sortInstanceNodePosition(this.current, e.current);
2324
- }
2325
- updateFeatures() {
2326
- let e = "animation";
2327
- for (e in et) {
2328
- const n = et[e];
2329
- if (!n)
2330
- continue;
2331
- const { isEnabled: s, Feature: i } = n;
2332
- if (!this.features[e] && i && s(this.props) && (this.features[e] = new i(this)), this.features[e]) {
2333
- const r = this.features[e];
2334
- r.isMounted ? r.update() : (r.mount(), r.isMounted = !0);
2335
- }
2336
- }
2337
- }
2338
- triggerBuild() {
2339
- this.build(this.renderState, this.latestValues, this.props);
2340
- }
2341
- /**
2342
- * Measure the current viewport box with or without transforms.
2343
- * Only measures axis-aligned boxes, rotate and skew must be manually
2344
- * removed with a re-render to work.
2345
- */
2346
- measureViewportBox() {
2347
- return this.current ? this.measureInstanceViewportBox(this.current, this.props) : Nn();
2348
- }
2349
- getStaticValue(e) {
2350
- return this.latestValues[e];
2351
- }
2352
- setStaticValue(e, n) {
2353
- this.latestValues[e] = n;
2354
- }
2355
- /**
2356
- * Update the provided props. Ensure any newly-added motion values are
2357
- * added to our map, old ones removed, and listeners updated.
2358
- */
2359
- update(e, n) {
2360
- (e.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = e, this.prevPresenceContext = this.presenceContext, this.presenceContext = n;
2361
- for (let s = 0; s < Nt.length; s++) {
2362
- const i = Nt[s];
2363
- this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]);
2364
- const r = "on" + i, o = e[r];
2365
- o && (this.propEventSubscriptions[i] = this.on(i, o));
2366
- }
2367
- this.prevMotionValues = Dr(this, this.scrapeMotionValuesFromProps(e, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue(), this.onUpdate && this.onUpdate(this);
2368
- }
2369
- getProps() {
2370
- return this.props;
2371
- }
2372
- /**
2373
- * Returns the variant definition with a given name.
2374
- */
2375
- getVariant(e) {
2376
- return this.props.variants ? this.props.variants[e] : void 0;
2377
- }
2378
- /**
2379
- * Returns the defined default transition on this component.
2380
- */
2381
- getDefaultTransition() {
2382
- return this.props.transition;
2383
- }
2384
- getTransformPagePoint() {
2385
- return this.props.transformPagePoint;
2386
- }
2387
- getClosestVariantNode() {
2388
- return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0;
2389
- }
2390
- /**
2391
- * Add a child visual element to our set of children.
2392
- */
2393
- addVariantChild(e) {
2394
- const n = this.getClosestVariantNode();
2395
- if (n)
2396
- return n.variantChildren && n.variantChildren.add(e), () => n.variantChildren.delete(e);
2397
- }
2398
- /**
2399
- * Add a motion value and bind it to this visual element.
2400
- */
2401
- addValue(e, n) {
2402
- const s = this.values.get(e);
2403
- n !== s && (s && this.removeValue(e), this.bindToMotionValue(e, n), this.values.set(e, n), this.latestValues[e] = n.get());
2404
- }
2405
- /**
2406
- * Remove a motion value and unbind any active subscriptions.
2407
- */
2408
- removeValue(e) {
2409
- this.values.delete(e);
2410
- const n = this.valueSubscriptions.get(e);
2411
- n && (n(), this.valueSubscriptions.delete(e)), delete this.latestValues[e], this.removeValueFromRenderState(e, this.renderState);
2412
- }
2413
- /**
2414
- * Check whether we have a motion value for this key
2415
- */
2416
- hasValue(e) {
2417
- return this.values.has(e);
2418
- }
2419
- getValue(e, n) {
2420
- if (this.props.values && this.props.values[e])
2421
- return this.props.values[e];
2422
- let s = this.values.get(e);
2423
- return s === void 0 && n !== void 0 && (s = ne(n === null ? void 0 : n, { owner: this }), this.addValue(e, s)), s;
2424
- }
2425
- /**
2426
- * If we're trying to animate to a previously unencountered value,
2427
- * we need to check for it in our state and as a last resort read it
2428
- * directly from the instance (which might have performance implications).
2429
- */
2430
- readValue(e, n) {
2431
- var s;
2432
- let i = this.latestValues[e] !== void 0 || !this.current ? this.latestValues[e] : (s = this.getBaseTargetFromProps(this.props, e)) !== null && s !== void 0 ? s : this.readValueFromInstance(this.current, e, this.options);
2433
- return i != null && (typeof i == "string" && (Vn(i) || dn(i)) ? i = parseFloat(i) : !Fr(i) && $.test(n) && (i = vn(e, n)), this.setBaseTarget(e, R(i) ? i.get() : i)), R(i) ? i.get() : i;
2434
- }
2435
- /**
2436
- * Set the base target to later animate back to. This is currently
2437
- * only hydrated on creation and when we first read a value.
2438
- */
2439
- setBaseTarget(e, n) {
2440
- this.baseTarget[e] = n;
2441
- }
2442
- /**
2443
- * Find the base target for a value thats been removed from all animation
2444
- * props.
2445
- */
2446
- getBaseTarget(e) {
2447
- var n;
2448
- const { initial: s } = this.props;
2449
- let i;
2450
- if (typeof s == "string" || typeof s == "object") {
2451
- const o = Kt(this.props, s, (n = this.presenceContext) === null || n === void 0 ? void 0 : n.custom);
2452
- o && (i = o[e]);
2453
- }
2454
- if (s && i !== void 0)
2455
- return i;
2456
- const r = this.getBaseTargetFromProps(this.props, e);
2457
- return r !== void 0 && !R(r) ? r : this.initialValues[e] !== void 0 && i === void 0 ? void 0 : this.baseTarget[e];
2458
- }
2459
- on(e, n) {
2460
- return this.events[e] || (this.events[e] = new nn()), this.events[e].add(n);
2461
- }
2462
- notify(e, ...n) {
2463
- this.events[e] && this.events[e].notify(...n);
2464
- }
2465
- }
2466
- class _n extends Er {
2467
- constructor() {
2468
- super(...arguments), this.KeyframeResolver = wn;
2469
- }
2470
- sortInstanceNodePosition(e, n) {
2471
- return e.compareDocumentPosition(n) & 2 ? 1 : -1;
2472
- }
2473
- getBaseTargetFromProps(e, n) {
2474
- return e.style ? e.style[n] : void 0;
2475
- }
2476
- removeValueFromRenderState(e, { vars: n, style: s }) {
2477
- delete n[e], delete s[e];
2478
- }
2479
- handleChildMotionValue() {
2480
- this.childSubscription && (this.childSubscription(), delete this.childSubscription);
2481
- const { children: e } = this.props;
2482
- R(e) && (this.childSubscription = e.on("change", (n) => {
2483
- this.current && (this.current.textContent = `${n}`);
2484
- }));
2485
- }
2486
- }
2487
- function Ir(t) {
2488
- return window.getComputedStyle(t);
2489
- }
2490
- class Rr extends _n {
2491
- constructor() {
2492
- super(...arguments), this.type = "html", this.renderInstance = Yn;
2493
- }
2494
- readValueFromInstance(e, n) {
2495
- if (le.has(n)) {
2496
- const s = ze(n);
2497
- return s && s.default || 0;
2498
- } else {
2499
- const s = Ir(e), i = (Xn(n) ? s.getPropertyValue(n) : s[n]) || 0;
2500
- return typeof i == "string" ? i.trim() : i;
2501
- }
2502
- }
2503
- measureInstanceViewportBox(e, { transformPagePoint: n }) {
2504
- return Kn(e, n);
2505
- }
2506
- build(e, n, s) {
2507
- Zn(e, n, s.transformTemplate);
2508
- }
2509
- scrapeMotionValuesFromProps(e, n, s) {
2510
- return Jn(e, n, s);
2511
- }
2512
- }
2513
- class Or extends _n {
2514
- constructor() {
2515
- super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = Nn;
2516
- }
2517
- getBaseTargetFromProps(e, n) {
2518
- return e[n];
2519
- }
2520
- readValueFromInstance(e, n) {
2521
- if (le.has(n)) {
2522
- const s = ze(n);
2523
- return s && s.default || 0;
2524
- }
2525
- return n = Qn.has(n) ? n : es(n), e.getAttribute(n);
2526
- }
2527
- scrapeMotionValuesFromProps(e, n, s) {
2528
- return ts(e, n, s);
2529
- }
2530
- build(e, n, s) {
2531
- ns(e, n, this.isSVGTag, s.transformTemplate);
2532
- }
2533
- renderInstance(e, n, s, i) {
2534
- ss(e, n, s, i);
2535
- }
2536
- mount(e) {
2537
- this.isSVGTag = is(e.tagName), super.mount(e);
2538
- }
2539
- }
2540
- const Nr = (t, e) => rs(t) ? new Or(e) : new Rr(e, {
2541
- allowProjection: t !== os
2542
- }), Wr = {
2543
- renderer: Nr,
2544
- ...ur,
2545
- ...Pr
2546
- };
2547
- export {
2548
- gt as $,
2549
- Et as A,
2550
- dr as B,
2551
- mr as C,
2552
- pr as D,
2553
- $r as E,
2554
- j as F,
2555
- Ur as G,
2556
- Cs as H,
2557
- Wr as I,
2558
- bt as J,
2559
- Qi as K,
2560
- ur as L,
2561
- As as M,
2562
- cn as N,
2563
- Ge as O,
2564
- un as P,
2565
- ln as Q,
2566
- $e as R,
2567
- nn as S,
2568
- hn as T,
2569
- w as U,
2570
- Er as V,
2571
- Z as W,
2572
- Si as X,
2573
- En as Y,
2574
- wi as Z,
2575
- vi as _,
2576
- Vt as a,
2577
- Mi as a0,
2578
- Zt as a1,
2579
- ie as a2,
2580
- on as a3,
2581
- Mn as a4,
2582
- an as a5,
2583
- Dn as a6,
2584
- Ot as a7,
2585
- kr as b,
2586
- en as c,
2587
- J as d,
2588
- Xe as e,
2589
- Le as f,
2590
- Nn as g,
2591
- jr as h,
2592
- nt as i,
2593
- Gr as j,
2594
- cr as k,
2595
- Ps as l,
2596
- O as m,
2597
- Yi as n,
2598
- $ as o,
2599
- he as p,
2600
- ne as q,
2601
- bs as r,
2602
- I as s,
2603
- Ts as t,
2604
- N as u,
2605
- Es as v,
2606
- wt as w,
2607
- zt as x,
2608
- fr as y,
2609
- Ft as z
2610
- };