hookery 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +72 -11
  2. package/dist/bridges/auth0.d.mts +16 -0
  3. package/dist/bridges/auth0.d.ts +16 -0
  4. package/dist/bridges/auth0.js +3015 -0
  5. package/dist/bridges/auth0.js.map +1 -0
  6. package/dist/bridges/auth0.mjs +2977 -0
  7. package/dist/bridges/auth0.mjs.map +1 -0
  8. package/dist/bridges/axios.d.mts +17 -0
  9. package/dist/bridges/axios.d.ts +17 -0
  10. package/dist/bridges/axios.js +15351 -0
  11. package/dist/bridges/axios.js.map +1 -0
  12. package/dist/bridges/axios.mjs +15347 -0
  13. package/dist/bridges/axios.mjs.map +1 -0
  14. package/dist/bridges/clerk.d.mts +1 -0
  15. package/dist/bridges/clerk.d.ts +1 -0
  16. package/dist/bridges/clerk.js +5991 -0
  17. package/dist/bridges/clerk.js.map +1 -0
  18. package/dist/bridges/clerk.mjs +5985 -0
  19. package/dist/bridges/clerk.mjs.map +1 -0
  20. package/dist/bridges/firebase.d.mts +14 -0
  21. package/dist/bridges/firebase.d.ts +14 -0
  22. package/dist/bridges/firebase.js +52 -0
  23. package/dist/bridges/firebase.js.map +1 -0
  24. package/dist/bridges/firebase.mjs +25 -0
  25. package/dist/bridges/firebase.mjs.map +1 -0
  26. package/dist/bridges/jotai.d.mts +11 -0
  27. package/dist/bridges/jotai.d.ts +11 -0
  28. package/dist/bridges/jotai.js +870 -0
  29. package/dist/bridges/jotai.js.map +1 -0
  30. package/dist/bridges/jotai.mjs +827 -0
  31. package/dist/bridges/jotai.mjs.map +1 -0
  32. package/dist/bridges/motion.d.mts +6 -0
  33. package/dist/bridges/motion.d.ts +6 -0
  34. package/dist/bridges/motion.js +3752 -0
  35. package/dist/bridges/motion.js.map +1 -0
  36. package/dist/bridges/motion.mjs +3721 -0
  37. package/dist/bridges/motion.mjs.map +1 -0
  38. package/dist/bridges/next.d.mts +10 -0
  39. package/dist/bridges/next.d.ts +10 -0
  40. package/dist/bridges/next.js +2588 -0
  41. package/dist/bridges/next.js.map +1 -0
  42. package/dist/bridges/next.mjs +2582 -0
  43. package/dist/bridges/next.mjs.map +1 -0
  44. package/dist/bridges/redux.d.mts +15 -0
  45. package/dist/bridges/redux.d.ts +15 -0
  46. package/dist/bridges/redux.js +410 -0
  47. package/dist/bridges/redux.js.map +1 -0
  48. package/dist/bridges/redux.mjs +402 -0
  49. package/dist/bridges/redux.mjs.map +1 -0
  50. package/dist/bridges/remix.d.mts +1 -0
  51. package/dist/bridges/remix.d.ts +1 -0
  52. package/dist/bridges/remix.js +2215 -0
  53. package/dist/bridges/remix.js.map +1 -0
  54. package/dist/bridges/remix.mjs +2174 -0
  55. package/dist/bridges/remix.mjs.map +1 -0
  56. package/dist/bridges/stripe.d.mts +15 -0
  57. package/dist/bridges/stripe.d.ts +15 -0
  58. package/dist/bridges/stripe.js +1572 -0
  59. package/dist/bridges/stripe.js.map +1 -0
  60. package/dist/bridges/stripe.mjs +1556 -0
  61. package/dist/bridges/stripe.mjs.map +1 -0
  62. package/dist/bridges/supabase.d.mts +13 -0
  63. package/dist/bridges/supabase.d.ts +13 -0
  64. package/dist/bridges/supabase.js +51 -0
  65. package/dist/bridges/supabase.js.map +1 -0
  66. package/dist/bridges/supabase.mjs +24 -0
  67. package/dist/bridges/supabase.mjs.map +1 -0
  68. package/dist/bridges/tanstack.d.mts +3 -0
  69. package/dist/bridges/tanstack.d.ts +3 -0
  70. package/dist/bridges/tanstack.js +1319 -0
  71. package/dist/bridges/tanstack.js.map +1 -0
  72. package/dist/bridges/tanstack.mjs +1281 -0
  73. package/dist/bridges/tanstack.mjs.map +1 -0
  74. package/dist/bridges/yup.d.mts +16 -0
  75. package/dist/bridges/yup.d.ts +16 -0
  76. package/dist/bridges/yup.js +80 -0
  77. package/dist/bridges/yup.js.map +1 -0
  78. package/dist/bridges/yup.mjs +43 -0
  79. package/dist/bridges/yup.mjs.map +1 -0
  80. package/dist/bridges/zod.d.mts +19 -0
  81. package/dist/bridges/zod.d.ts +19 -0
  82. package/dist/bridges/zod.js +66 -0
  83. package/dist/bridges/zod.js.map +1 -0
  84. package/dist/bridges/zod.mjs +39 -0
  85. package/dist/bridges/zod.mjs.map +1 -0
  86. package/dist/bridges/zustand.d.mts +14 -0
  87. package/dist/bridges/zustand.d.ts +14 -0
  88. package/dist/bridges/zustand.js +58 -0
  89. package/dist/bridges/zustand.js.map +1 -0
  90. package/dist/bridges/zustand.mjs +21 -0
  91. package/dist/bridges/zustand.mjs.map +1 -0
  92. package/dist/index.d.mts +3124 -8
  93. package/dist/index.d.ts +3124 -8
  94. package/dist/index.js +4290 -10
  95. package/dist/index.js.map +1 -0
  96. package/dist/index.mjs +4172 -7
  97. package/dist/index.mjs.map +1 -0
  98. package/package.json +131 -6
@@ -0,0 +1,3752 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/bridges/motion/index.ts
21
+ var motion_exports = {};
22
+ __export(motion_exports, {
23
+ useAnimation: () => useAnimation,
24
+ useMotionValue: () => useMotionValue,
25
+ useScrollProgress: () => useScrollProgress,
26
+ useSpring: () => useSpring,
27
+ useTransform: () => useTransform
28
+ });
29
+ module.exports = __toCommonJS(motion_exports);
30
+
31
+ // node_modules/framer-motion/dist/es/utils/use-constant.mjs
32
+ var import_react = require("react");
33
+ function useConstant(init) {
34
+ const ref = (0, import_react.useRef)(null);
35
+ if (ref.current === null) {
36
+ ref.current = init();
37
+ }
38
+ return ref.current;
39
+ }
40
+
41
+ // node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
42
+ var import_react2 = require("react");
43
+
44
+ // node_modules/framer-motion/dist/es/utils/is-browser.mjs
45
+ var isBrowser = typeof window !== "undefined";
46
+
47
+ // node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
48
+ var useIsomorphicLayoutEffect = isBrowser ? import_react2.useLayoutEffect : import_react2.useEffect;
49
+
50
+ // node_modules/motion-utils/dist/es/array.mjs
51
+ function addUniqueItem(arr, item) {
52
+ if (arr.indexOf(item) === -1)
53
+ arr.push(item);
54
+ }
55
+ function removeItem(arr, item) {
56
+ const index = arr.indexOf(item);
57
+ if (index > -1)
58
+ arr.splice(index, 1);
59
+ }
60
+
61
+ // node_modules/motion-utils/dist/es/clamp.mjs
62
+ var clamp = (min, max, v) => {
63
+ if (v > max)
64
+ return max;
65
+ if (v < min)
66
+ return min;
67
+ return v;
68
+ };
69
+
70
+ // node_modules/motion-utils/dist/es/format-error-message.mjs
71
+ function formatErrorMessage(message, errorCode) {
72
+ return errorCode ? `${message}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${errorCode}` : message;
73
+ }
74
+
75
+ // node_modules/motion-utils/dist/es/errors.mjs
76
+ var warning = () => {
77
+ };
78
+ var invariant = () => {
79
+ };
80
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
81
+ warning = (check, message, errorCode) => {
82
+ if (!check && typeof console !== "undefined") {
83
+ console.warn(formatErrorMessage(message, errorCode));
84
+ }
85
+ };
86
+ invariant = (check, message, errorCode) => {
87
+ if (!check) {
88
+ throw new Error(formatErrorMessage(message, errorCode));
89
+ }
90
+ };
91
+ }
92
+
93
+ // node_modules/motion-utils/dist/es/global-config.mjs
94
+ var MotionGlobalConfig = {};
95
+
96
+ // node_modules/motion-utils/dist/es/is-object.mjs
97
+ function isObject(value) {
98
+ return typeof value === "object" && value !== null;
99
+ }
100
+
101
+ // node_modules/motion-utils/dist/es/memo.mjs
102
+ // @__NO_SIDE_EFFECTS__
103
+ function memo(callback) {
104
+ let result;
105
+ return () => {
106
+ if (result === void 0)
107
+ result = callback();
108
+ return result;
109
+ };
110
+ }
111
+
112
+ // node_modules/motion-utils/dist/es/noop.mjs
113
+ var noop = /* @__NO_SIDE_EFFECTS__ */ (any) => any;
114
+
115
+ // node_modules/motion-utils/dist/es/pipe.mjs
116
+ var combineFunctions = (a, b) => (v) => b(a(v));
117
+ var pipe = (...transformers) => transformers.reduce(combineFunctions);
118
+
119
+ // node_modules/motion-utils/dist/es/progress.mjs
120
+ var progress = /* @__NO_SIDE_EFFECTS__ */ (from, to, value) => {
121
+ const toFromDifference = to - from;
122
+ return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
123
+ };
124
+
125
+ // node_modules/motion-utils/dist/es/subscription-manager.mjs
126
+ var SubscriptionManager = class {
127
+ constructor() {
128
+ this.subscriptions = [];
129
+ }
130
+ add(handler) {
131
+ addUniqueItem(this.subscriptions, handler);
132
+ return () => removeItem(this.subscriptions, handler);
133
+ }
134
+ notify(a, b, c) {
135
+ const numSubscriptions = this.subscriptions.length;
136
+ if (!numSubscriptions)
137
+ return;
138
+ if (numSubscriptions === 1) {
139
+ this.subscriptions[0](a, b, c);
140
+ } else {
141
+ for (let i = 0; i < numSubscriptions; i++) {
142
+ const handler = this.subscriptions[i];
143
+ handler && handler(a, b, c);
144
+ }
145
+ }
146
+ }
147
+ getSize() {
148
+ return this.subscriptions.length;
149
+ }
150
+ clear() {
151
+ this.subscriptions.length = 0;
152
+ }
153
+ };
154
+
155
+ // node_modules/motion-utils/dist/es/time-conversion.mjs
156
+ var secondsToMilliseconds = /* @__NO_SIDE_EFFECTS__ */ (seconds) => seconds * 1e3;
157
+ var millisecondsToSeconds = /* @__NO_SIDE_EFFECTS__ */ (milliseconds) => milliseconds / 1e3;
158
+
159
+ // node_modules/motion-utils/dist/es/velocity-per-second.mjs
160
+ function velocityPerSecond(velocity, frameDuration) {
161
+ return frameDuration ? velocity * (1e3 / frameDuration) : 0;
162
+ }
163
+
164
+ // node_modules/motion-utils/dist/es/warn-once.mjs
165
+ var warned = /* @__PURE__ */ new Set();
166
+ function warnOnce(condition, message, errorCode) {
167
+ if (condition || warned.has(message))
168
+ return;
169
+ console.warn(formatErrorMessage(message, errorCode));
170
+ warned.add(message);
171
+ }
172
+
173
+ // node_modules/motion-utils/dist/es/easing/cubic-bezier.mjs
174
+ var calcBezier = (t, a1, a2) => (((1 - 3 * a2 + 3 * a1) * t + (3 * a2 - 6 * a1)) * t + 3 * a1) * t;
175
+ var subdivisionPrecision = 1e-7;
176
+ var subdivisionMaxIterations = 12;
177
+ function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
178
+ let currentX;
179
+ let currentT;
180
+ let i = 0;
181
+ do {
182
+ currentT = lowerBound + (upperBound - lowerBound) / 2;
183
+ currentX = calcBezier(currentT, mX1, mX2) - x;
184
+ if (currentX > 0) {
185
+ upperBound = currentT;
186
+ } else {
187
+ lowerBound = currentT;
188
+ }
189
+ } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
190
+ return currentT;
191
+ }
192
+ function cubicBezier(mX1, mY1, mX2, mY2) {
193
+ if (mX1 === mY1 && mX2 === mY2)
194
+ return noop;
195
+ const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
196
+ return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
197
+ }
198
+
199
+ // node_modules/motion-utils/dist/es/easing/modifiers/mirror.mjs
200
+ var mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
201
+
202
+ // node_modules/motion-utils/dist/es/easing/modifiers/reverse.mjs
203
+ var reverseEasing = (easing) => (p) => 1 - easing(1 - p);
204
+
205
+ // node_modules/motion-utils/dist/es/easing/back.mjs
206
+ var backOut = /* @__PURE__ */ cubicBezier(0.33, 1.53, 0.69, 0.99);
207
+ var backIn = /* @__PURE__ */ reverseEasing(backOut);
208
+ var backInOut = /* @__PURE__ */ mirrorEasing(backIn);
209
+
210
+ // node_modules/motion-utils/dist/es/easing/anticipate.mjs
211
+ var anticipate = (p) => (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
212
+
213
+ // node_modules/motion-utils/dist/es/easing/circ.mjs
214
+ var circIn = (p) => 1 - Math.sin(Math.acos(p));
215
+ var circOut = reverseEasing(circIn);
216
+ var circInOut = mirrorEasing(circIn);
217
+
218
+ // node_modules/motion-utils/dist/es/easing/ease.mjs
219
+ var easeIn = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);
220
+ var easeOut = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);
221
+ var easeInOut = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);
222
+
223
+ // node_modules/motion-utils/dist/es/easing/utils/is-easing-array.mjs
224
+ var isEasingArray = (ease2) => {
225
+ return Array.isArray(ease2) && typeof ease2[0] !== "number";
226
+ };
227
+
228
+ // node_modules/motion-utils/dist/es/easing/utils/is-bezier-definition.mjs
229
+ var isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
230
+
231
+ // node_modules/motion-utils/dist/es/easing/utils/map.mjs
232
+ var easingLookup = {
233
+ linear: noop,
234
+ easeIn,
235
+ easeInOut,
236
+ easeOut,
237
+ circIn,
238
+ circInOut,
239
+ circOut,
240
+ backIn,
241
+ backInOut,
242
+ backOut,
243
+ anticipate
244
+ };
245
+ var isValidEasing = (easing) => {
246
+ return typeof easing === "string";
247
+ };
248
+ var easingDefinitionToFunction = (definition) => {
249
+ if (isBezierDefinition(definition)) {
250
+ invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`, "cubic-bezier-length");
251
+ const [x1, y1, x2, y2] = definition;
252
+ return cubicBezier(x1, y1, x2, y2);
253
+ } else if (isValidEasing(definition)) {
254
+ invariant(easingLookup[definition] !== void 0, `Invalid easing type '${definition}'`, "invalid-easing-type");
255
+ return easingLookup[definition];
256
+ }
257
+ return definition;
258
+ };
259
+
260
+ // node_modules/motion-dom/dist/es/frameloop/order.mjs
261
+ var stepsOrder = [
262
+ "setup",
263
+ // Compute
264
+ "read",
265
+ // Read
266
+ "resolveKeyframes",
267
+ // Write/Read/Write/Read
268
+ "preUpdate",
269
+ // Compute
270
+ "update",
271
+ // Compute
272
+ "preRender",
273
+ // Compute
274
+ "render",
275
+ // Write
276
+ "postRender"
277
+ // Compute
278
+ ];
279
+
280
+ // node_modules/motion-dom/dist/es/stats/buffer.mjs
281
+ var statsBuffer = {
282
+ value: null,
283
+ addProjectionMetrics: null
284
+ };
285
+
286
+ // node_modules/motion-dom/dist/es/frameloop/render-step.mjs
287
+ function createRenderStep(runNextFrame, stepName) {
288
+ let thisFrame = /* @__PURE__ */ new Set();
289
+ let nextFrame = /* @__PURE__ */ new Set();
290
+ let isProcessing = false;
291
+ let flushNextFrame = false;
292
+ const toKeepAlive = /* @__PURE__ */ new WeakSet();
293
+ let latestFrameData = {
294
+ delta: 0,
295
+ timestamp: 0,
296
+ isProcessing: false
297
+ };
298
+ let numCalls = 0;
299
+ function triggerCallback(callback) {
300
+ if (toKeepAlive.has(callback)) {
301
+ step.schedule(callback);
302
+ runNextFrame();
303
+ }
304
+ numCalls++;
305
+ callback(latestFrameData);
306
+ }
307
+ const step = {
308
+ /**
309
+ * Schedule a process to run on the next frame.
310
+ */
311
+ schedule: (callback, keepAlive = false, immediate = false) => {
312
+ const addToCurrentFrame = immediate && isProcessing;
313
+ const queue = addToCurrentFrame ? thisFrame : nextFrame;
314
+ if (keepAlive)
315
+ toKeepAlive.add(callback);
316
+ if (!queue.has(callback))
317
+ queue.add(callback);
318
+ return callback;
319
+ },
320
+ /**
321
+ * Cancel the provided callback from running on the next frame.
322
+ */
323
+ cancel: (callback) => {
324
+ nextFrame.delete(callback);
325
+ toKeepAlive.delete(callback);
326
+ },
327
+ /**
328
+ * Execute all schedule callbacks.
329
+ */
330
+ process: (frameData2) => {
331
+ latestFrameData = frameData2;
332
+ if (isProcessing) {
333
+ flushNextFrame = true;
334
+ return;
335
+ }
336
+ isProcessing = true;
337
+ [thisFrame, nextFrame] = [nextFrame, thisFrame];
338
+ thisFrame.forEach(triggerCallback);
339
+ if (stepName && statsBuffer.value) {
340
+ statsBuffer.value.frameloop[stepName].push(numCalls);
341
+ }
342
+ numCalls = 0;
343
+ thisFrame.clear();
344
+ isProcessing = false;
345
+ if (flushNextFrame) {
346
+ flushNextFrame = false;
347
+ step.process(frameData2);
348
+ }
349
+ }
350
+ };
351
+ return step;
352
+ }
353
+
354
+ // node_modules/motion-dom/dist/es/frameloop/batcher.mjs
355
+ var maxElapsed = 40;
356
+ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
357
+ let runNextFrame = false;
358
+ let useDefaultElapsed = true;
359
+ const state = {
360
+ delta: 0,
361
+ timestamp: 0,
362
+ isProcessing: false
363
+ };
364
+ const flagRunNextFrame = () => runNextFrame = true;
365
+ const steps = stepsOrder.reduce((acc, key) => {
366
+ acc[key] = createRenderStep(flagRunNextFrame, allowKeepAlive ? key : void 0);
367
+ return acc;
368
+ }, {});
369
+ const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender } = steps;
370
+ const processBatch = () => {
371
+ const timestamp = MotionGlobalConfig.useManualTiming ? state.timestamp : performance.now();
372
+ runNextFrame = false;
373
+ if (!MotionGlobalConfig.useManualTiming) {
374
+ state.delta = useDefaultElapsed ? 1e3 / 60 : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
375
+ }
376
+ state.timestamp = timestamp;
377
+ state.isProcessing = true;
378
+ setup.process(state);
379
+ read.process(state);
380
+ resolveKeyframes.process(state);
381
+ preUpdate.process(state);
382
+ update.process(state);
383
+ preRender.process(state);
384
+ render.process(state);
385
+ postRender.process(state);
386
+ state.isProcessing = false;
387
+ if (runNextFrame && allowKeepAlive) {
388
+ useDefaultElapsed = false;
389
+ scheduleNextBatch(processBatch);
390
+ }
391
+ };
392
+ const wake = () => {
393
+ runNextFrame = true;
394
+ useDefaultElapsed = true;
395
+ if (!state.isProcessing) {
396
+ scheduleNextBatch(processBatch);
397
+ }
398
+ };
399
+ const schedule = stepsOrder.reduce((acc, key) => {
400
+ const step = steps[key];
401
+ acc[key] = (process2, keepAlive = false, immediate = false) => {
402
+ if (!runNextFrame)
403
+ wake();
404
+ return step.schedule(process2, keepAlive, immediate);
405
+ };
406
+ return acc;
407
+ }, {});
408
+ const cancel = (process2) => {
409
+ for (let i = 0; i < stepsOrder.length; i++) {
410
+ steps[stepsOrder[i]].cancel(process2);
411
+ }
412
+ };
413
+ return { schedule, cancel, state, steps };
414
+ }
415
+
416
+ // node_modules/motion-dom/dist/es/frameloop/frame.mjs
417
+ var { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
418
+
419
+ // node_modules/motion-dom/dist/es/frameloop/sync-time.mjs
420
+ var now;
421
+ function clearTime() {
422
+ now = void 0;
423
+ }
424
+ var time = {
425
+ now: () => {
426
+ if (now === void 0) {
427
+ time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming ? frameData.timestamp : performance.now());
428
+ }
429
+ return now;
430
+ },
431
+ set: (newTime) => {
432
+ now = newTime;
433
+ queueMicrotask(clearTime);
434
+ }
435
+ };
436
+
437
+ // node_modules/motion-dom/dist/es/stats/animation-count.mjs
438
+ var activeAnimations = {
439
+ layout: 0,
440
+ mainThread: 0,
441
+ waapi: 0
442
+ };
443
+
444
+ // node_modules/motion-dom/dist/es/animation/utils/is-css-variable.mjs
445
+ var checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
446
+ var startsAsVariableToken = /* @__PURE__ */ checkStringStartsWith("var(--");
447
+ var isCSSVariableToken = (value) => {
448
+ const startsWithToken = startsAsVariableToken(value);
449
+ if (!startsWithToken)
450
+ return false;
451
+ return singleCssVariableRegex.test(value.split("/*")[0].trim());
452
+ };
453
+ var singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
454
+
455
+ // node_modules/motion-dom/dist/es/value/types/numbers/index.mjs
456
+ var number = {
457
+ test: (v) => typeof v === "number",
458
+ parse: parseFloat,
459
+ transform: (v) => v
460
+ };
461
+ var alpha = {
462
+ ...number,
463
+ transform: (v) => clamp(0, 1, v)
464
+ };
465
+ var scale = {
466
+ ...number,
467
+ default: 1
468
+ };
469
+
470
+ // node_modules/motion-dom/dist/es/value/types/utils/sanitize.mjs
471
+ var sanitize = (v) => Math.round(v * 1e5) / 1e5;
472
+
473
+ // node_modules/motion-dom/dist/es/value/types/utils/float-regex.mjs
474
+ var floatRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
475
+
476
+ // node_modules/motion-dom/dist/es/value/types/utils/is-nullish.mjs
477
+ function isNullish(v) {
478
+ return v == null;
479
+ }
480
+
481
+ // node_modules/motion-dom/dist/es/value/types/utils/single-color-regex.mjs
482
+ var singleColorRegex = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;
483
+
484
+ // node_modules/motion-dom/dist/es/value/types/color/utils.mjs
485
+ var isColorString = (type, testProp) => (v) => {
486
+ return Boolean(typeof v === "string" && singleColorRegex.test(v) && v.startsWith(type) || testProp && !isNullish(v) && Object.prototype.hasOwnProperty.call(v, testProp));
487
+ };
488
+ var splitColor = (aName, bName, cName) => (v) => {
489
+ if (typeof v !== "string")
490
+ return v;
491
+ const [a, b, c, alpha2] = v.match(floatRegex);
492
+ return {
493
+ [aName]: parseFloat(a),
494
+ [bName]: parseFloat(b),
495
+ [cName]: parseFloat(c),
496
+ alpha: alpha2 !== void 0 ? parseFloat(alpha2) : 1
497
+ };
498
+ };
499
+
500
+ // node_modules/motion-dom/dist/es/value/types/color/rgba.mjs
501
+ var clampRgbUnit = (v) => clamp(0, 255, v);
502
+ var rgbUnit = {
503
+ ...number,
504
+ transform: (v) => Math.round(clampRgbUnit(v))
505
+ };
506
+ var rgba = {
507
+ test: /* @__PURE__ */ isColorString("rgb", "red"),
508
+ parse: /* @__PURE__ */ splitColor("red", "green", "blue"),
509
+ transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => "rgba(" + rgbUnit.transform(red) + ", " + rgbUnit.transform(green) + ", " + rgbUnit.transform(blue) + ", " + sanitize(alpha.transform(alpha$1)) + ")"
510
+ };
511
+
512
+ // node_modules/motion-dom/dist/es/value/types/color/hex.mjs
513
+ function parseHex(v) {
514
+ let r = "";
515
+ let g = "";
516
+ let b = "";
517
+ let a = "";
518
+ if (v.length > 5) {
519
+ r = v.substring(1, 3);
520
+ g = v.substring(3, 5);
521
+ b = v.substring(5, 7);
522
+ a = v.substring(7, 9);
523
+ } else {
524
+ r = v.substring(1, 2);
525
+ g = v.substring(2, 3);
526
+ b = v.substring(3, 4);
527
+ a = v.substring(4, 5);
528
+ r += r;
529
+ g += g;
530
+ b += b;
531
+ a += a;
532
+ }
533
+ return {
534
+ red: parseInt(r, 16),
535
+ green: parseInt(g, 16),
536
+ blue: parseInt(b, 16),
537
+ alpha: a ? parseInt(a, 16) / 255 : 1
538
+ };
539
+ }
540
+ var hex = {
541
+ test: /* @__PURE__ */ isColorString("#"),
542
+ parse: parseHex,
543
+ transform: rgba.transform
544
+ };
545
+
546
+ // node_modules/motion-dom/dist/es/value/types/numbers/units.mjs
547
+ var createUnitType = /* @__NO_SIDE_EFFECTS__ */ (unit) => ({
548
+ test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
549
+ parse: parseFloat,
550
+ transform: (v) => `${v}${unit}`
551
+ });
552
+ var percent = /* @__PURE__ */ createUnitType("%");
553
+
554
+ // node_modules/motion-dom/dist/es/value/types/color/hsla.mjs
555
+ var hsla = {
556
+ test: /* @__PURE__ */ isColorString("hsl", "hue"),
557
+ parse: /* @__PURE__ */ splitColor("hue", "saturation", "lightness"),
558
+ transform: ({ hue, saturation, lightness, alpha: alpha$1 = 1 }) => {
559
+ return "hsla(" + Math.round(hue) + ", " + percent.transform(sanitize(saturation)) + ", " + percent.transform(sanitize(lightness)) + ", " + sanitize(alpha.transform(alpha$1)) + ")";
560
+ }
561
+ };
562
+
563
+ // node_modules/motion-dom/dist/es/value/types/color/index.mjs
564
+ var color = {
565
+ test: (v) => rgba.test(v) || hex.test(v) || hsla.test(v),
566
+ parse: (v) => {
567
+ if (rgba.test(v)) {
568
+ return rgba.parse(v);
569
+ } else if (hsla.test(v)) {
570
+ return hsla.parse(v);
571
+ } else {
572
+ return hex.parse(v);
573
+ }
574
+ },
575
+ transform: (v) => {
576
+ return typeof v === "string" ? v : v.hasOwnProperty("red") ? rgba.transform(v) : hsla.transform(v);
577
+ },
578
+ getAnimatableNone: (v) => {
579
+ const parsed = color.parse(v);
580
+ parsed.alpha = 0;
581
+ return color.transform(parsed);
582
+ }
583
+ };
584
+
585
+ // node_modules/motion-dom/dist/es/value/types/utils/color-regex.mjs
586
+ var colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
587
+
588
+ // node_modules/motion-dom/dist/es/value/types/complex/index.mjs
589
+ function test(v) {
590
+ return isNaN(v) && typeof v === "string" && (v.match(floatRegex)?.length || 0) + (v.match(colorRegex)?.length || 0) > 0;
591
+ }
592
+ var NUMBER_TOKEN = "number";
593
+ var COLOR_TOKEN = "color";
594
+ var VAR_TOKEN = "var";
595
+ var VAR_FUNCTION_TOKEN = "var(";
596
+ var SPLIT_TOKEN = "${}";
597
+ var complexRegex = /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;
598
+ function analyseComplexValue(value) {
599
+ const originalValue = value.toString();
600
+ const values = [];
601
+ const indexes = {
602
+ color: [],
603
+ number: [],
604
+ var: []
605
+ };
606
+ const types = [];
607
+ let i = 0;
608
+ const tokenised = originalValue.replace(complexRegex, (parsedValue) => {
609
+ if (color.test(parsedValue)) {
610
+ indexes.color.push(i);
611
+ types.push(COLOR_TOKEN);
612
+ values.push(color.parse(parsedValue));
613
+ } else if (parsedValue.startsWith(VAR_FUNCTION_TOKEN)) {
614
+ indexes.var.push(i);
615
+ types.push(VAR_TOKEN);
616
+ values.push(parsedValue);
617
+ } else {
618
+ indexes.number.push(i);
619
+ types.push(NUMBER_TOKEN);
620
+ values.push(parseFloat(parsedValue));
621
+ }
622
+ ++i;
623
+ return SPLIT_TOKEN;
624
+ });
625
+ const split = tokenised.split(SPLIT_TOKEN);
626
+ return { values, split, indexes, types };
627
+ }
628
+ function parseComplexValue(v) {
629
+ return analyseComplexValue(v).values;
630
+ }
631
+ function createTransformer(source) {
632
+ const { split, types } = analyseComplexValue(source);
633
+ const numSections = split.length;
634
+ return (v) => {
635
+ let output = "";
636
+ for (let i = 0; i < numSections; i++) {
637
+ output += split[i];
638
+ if (v[i] !== void 0) {
639
+ const type = types[i];
640
+ if (type === NUMBER_TOKEN) {
641
+ output += sanitize(v[i]);
642
+ } else if (type === COLOR_TOKEN) {
643
+ output += color.transform(v[i]);
644
+ } else {
645
+ output += v[i];
646
+ }
647
+ }
648
+ }
649
+ return output;
650
+ };
651
+ }
652
+ var convertNumbersToZero = (v) => typeof v === "number" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v;
653
+ function getAnimatableNone(v) {
654
+ const parsed = parseComplexValue(v);
655
+ const transformer = createTransformer(v);
656
+ return transformer(parsed.map(convertNumbersToZero));
657
+ }
658
+ var complex = {
659
+ test,
660
+ parse: parseComplexValue,
661
+ createTransformer,
662
+ getAnimatableNone
663
+ };
664
+
665
+ // node_modules/motion-dom/dist/es/value/types/color/hsla-to-rgba.mjs
666
+ function hueToRgb(p, q, t) {
667
+ if (t < 0)
668
+ t += 1;
669
+ if (t > 1)
670
+ t -= 1;
671
+ if (t < 1 / 6)
672
+ return p + (q - p) * 6 * t;
673
+ if (t < 1 / 2)
674
+ return q;
675
+ if (t < 2 / 3)
676
+ return p + (q - p) * (2 / 3 - t) * 6;
677
+ return p;
678
+ }
679
+ function hslaToRgba({ hue, saturation, lightness, alpha: alpha2 }) {
680
+ hue /= 360;
681
+ saturation /= 100;
682
+ lightness /= 100;
683
+ let red = 0;
684
+ let green = 0;
685
+ let blue = 0;
686
+ if (!saturation) {
687
+ red = green = blue = lightness;
688
+ } else {
689
+ const q = lightness < 0.5 ? lightness * (1 + saturation) : lightness + saturation - lightness * saturation;
690
+ const p = 2 * lightness - q;
691
+ red = hueToRgb(p, q, hue + 1 / 3);
692
+ green = hueToRgb(p, q, hue);
693
+ blue = hueToRgb(p, q, hue - 1 / 3);
694
+ }
695
+ return {
696
+ red: Math.round(red * 255),
697
+ green: Math.round(green * 255),
698
+ blue: Math.round(blue * 255),
699
+ alpha: alpha2
700
+ };
701
+ }
702
+
703
+ // node_modules/motion-dom/dist/es/utils/mix/immediate.mjs
704
+ function mixImmediate(a, b) {
705
+ return (p) => p > 0 ? b : a;
706
+ }
707
+
708
+ // node_modules/motion-dom/dist/es/utils/mix/number.mjs
709
+ var mixNumber = (from, to, progress2) => {
710
+ return from + (to - from) * progress2;
711
+ };
712
+
713
+ // node_modules/motion-dom/dist/es/utils/mix/color.mjs
714
+ var mixLinearColor = (from, to, v) => {
715
+ const fromExpo = from * from;
716
+ const expo = v * (to * to - fromExpo) + fromExpo;
717
+ return expo < 0 ? 0 : Math.sqrt(expo);
718
+ };
719
+ var colorTypes = [hex, rgba, hsla];
720
+ var getColorType = (v) => colorTypes.find((type) => type.test(v));
721
+ function asRGBA(color2) {
722
+ const type = getColorType(color2);
723
+ warning(Boolean(type), `'${color2}' is not an animatable color. Use the equivalent color code instead.`, "color-not-animatable");
724
+ if (!Boolean(type))
725
+ return false;
726
+ let model = type.parse(color2);
727
+ if (type === hsla) {
728
+ model = hslaToRgba(model);
729
+ }
730
+ return model;
731
+ }
732
+ var mixColor = (from, to) => {
733
+ const fromRGBA = asRGBA(from);
734
+ const toRGBA = asRGBA(to);
735
+ if (!fromRGBA || !toRGBA) {
736
+ return mixImmediate(from, to);
737
+ }
738
+ const blended = { ...fromRGBA };
739
+ return (v) => {
740
+ blended.red = mixLinearColor(fromRGBA.red, toRGBA.red, v);
741
+ blended.green = mixLinearColor(fromRGBA.green, toRGBA.green, v);
742
+ blended.blue = mixLinearColor(fromRGBA.blue, toRGBA.blue, v);
743
+ blended.alpha = mixNumber(fromRGBA.alpha, toRGBA.alpha, v);
744
+ return rgba.transform(blended);
745
+ };
746
+ };
747
+
748
+ // node_modules/motion-dom/dist/es/utils/mix/visibility.mjs
749
+ var invisibleValues = /* @__PURE__ */ new Set(["none", "hidden"]);
750
+ function mixVisibility(origin, target) {
751
+ if (invisibleValues.has(origin)) {
752
+ return (p) => p <= 0 ? origin : target;
753
+ } else {
754
+ return (p) => p >= 1 ? target : origin;
755
+ }
756
+ }
757
+
758
+ // node_modules/motion-dom/dist/es/utils/mix/complex.mjs
759
+ function mixNumber2(a, b) {
760
+ return (p) => mixNumber(a, b, p);
761
+ }
762
+ function getMixer(a) {
763
+ if (typeof a === "number") {
764
+ return mixNumber2;
765
+ } else if (typeof a === "string") {
766
+ return isCSSVariableToken(a) ? mixImmediate : color.test(a) ? mixColor : mixComplex;
767
+ } else if (Array.isArray(a)) {
768
+ return mixArray;
769
+ } else if (typeof a === "object") {
770
+ return color.test(a) ? mixColor : mixObject;
771
+ }
772
+ return mixImmediate;
773
+ }
774
+ function mixArray(a, b) {
775
+ const output = [...a];
776
+ const numValues = output.length;
777
+ const blendValue = a.map((v, i) => getMixer(v)(v, b[i]));
778
+ return (p) => {
779
+ for (let i = 0; i < numValues; i++) {
780
+ output[i] = blendValue[i](p);
781
+ }
782
+ return output;
783
+ };
784
+ }
785
+ function mixObject(a, b) {
786
+ const output = { ...a, ...b };
787
+ const blendValue = {};
788
+ for (const key in output) {
789
+ if (a[key] !== void 0 && b[key] !== void 0) {
790
+ blendValue[key] = getMixer(a[key])(a[key], b[key]);
791
+ }
792
+ }
793
+ return (v) => {
794
+ for (const key in blendValue) {
795
+ output[key] = blendValue[key](v);
796
+ }
797
+ return output;
798
+ };
799
+ }
800
+ function matchOrder(origin, target) {
801
+ const orderedOrigin = [];
802
+ const pointers = { color: 0, var: 0, number: 0 };
803
+ for (let i = 0; i < target.values.length; i++) {
804
+ const type = target.types[i];
805
+ const originIndex = origin.indexes[type][pointers[type]];
806
+ const originValue = origin.values[originIndex] ?? 0;
807
+ orderedOrigin[i] = originValue;
808
+ pointers[type]++;
809
+ }
810
+ return orderedOrigin;
811
+ }
812
+ var mixComplex = (origin, target) => {
813
+ const template = complex.createTransformer(target);
814
+ const originStats = analyseComplexValue(origin);
815
+ const targetStats = analyseComplexValue(target);
816
+ const canInterpolate = originStats.indexes.var.length === targetStats.indexes.var.length && originStats.indexes.color.length === targetStats.indexes.color.length && originStats.indexes.number.length >= targetStats.indexes.number.length;
817
+ if (canInterpolate) {
818
+ if (invisibleValues.has(origin) && !targetStats.values.length || invisibleValues.has(target) && !originStats.values.length) {
819
+ return mixVisibility(origin, target);
820
+ }
821
+ return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
822
+ } else {
823
+ warning(true, `Complex values '${origin}' and '${target}' 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.`, "complex-values-different");
824
+ return mixImmediate(origin, target);
825
+ }
826
+ };
827
+
828
+ // node_modules/motion-dom/dist/es/utils/mix/index.mjs
829
+ function mix(from, to, p) {
830
+ if (typeof from === "number" && typeof to === "number" && typeof p === "number") {
831
+ return mixNumber(from, to, p);
832
+ }
833
+ const mixer = getMixer(from);
834
+ return mixer(from, to);
835
+ }
836
+
837
+ // node_modules/motion-dom/dist/es/animation/drivers/frame.mjs
838
+ var frameloopDriver = (update) => {
839
+ const passTimestamp = ({ timestamp }) => update(timestamp);
840
+ return {
841
+ start: (keepAlive = true) => frame.update(passTimestamp, keepAlive),
842
+ stop: () => cancelFrame(passTimestamp),
843
+ /**
844
+ * If we're processing this frame we can use the
845
+ * framelocked timestamp to keep things in sync.
846
+ */
847
+ now: () => frameData.isProcessing ? frameData.timestamp : time.now()
848
+ };
849
+ };
850
+
851
+ // node_modules/motion-dom/dist/es/animation/waapi/utils/linear.mjs
852
+ var generateLinearEasing = (easing, duration, resolution = 10) => {
853
+ let points = "";
854
+ const numPoints = Math.max(Math.round(duration / resolution), 2);
855
+ for (let i = 0; i < numPoints; i++) {
856
+ points += Math.round(easing(i / (numPoints - 1)) * 1e4) / 1e4 + ", ";
857
+ }
858
+ return `linear(${points.substring(0, points.length - 2)})`;
859
+ };
860
+
861
+ // node_modules/motion-dom/dist/es/animation/generators/utils/calc-duration.mjs
862
+ var maxGeneratorDuration = 2e4;
863
+ function calcGeneratorDuration(generator) {
864
+ let duration = 0;
865
+ const timeStep = 50;
866
+ let state = generator.next(duration);
867
+ while (!state.done && duration < maxGeneratorDuration) {
868
+ duration += timeStep;
869
+ state = generator.next(duration);
870
+ }
871
+ return duration >= maxGeneratorDuration ? Infinity : duration;
872
+ }
873
+
874
+ // node_modules/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs
875
+ function createGeneratorEasing(options, scale2 = 100, createGenerator) {
876
+ const generator = createGenerator({ ...options, keyframes: [0, scale2] });
877
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
878
+ return {
879
+ type: "keyframes",
880
+ ease: (progress2) => {
881
+ return generator.next(duration * progress2).value / scale2;
882
+ },
883
+ duration: millisecondsToSeconds(duration)
884
+ };
885
+ }
886
+
887
+ // node_modules/motion-dom/dist/es/animation/generators/utils/velocity.mjs
888
+ var velocitySampleDuration = 5;
889
+ function calcGeneratorVelocity(resolveValue, t, current) {
890
+ const prevT = Math.max(t - velocitySampleDuration, 0);
891
+ return velocityPerSecond(current - resolveValue(prevT), t - prevT);
892
+ }
893
+
894
+ // node_modules/motion-dom/dist/es/animation/generators/spring/defaults.mjs
895
+ var springDefaults = {
896
+ // Default spring physics
897
+ stiffness: 100,
898
+ damping: 10,
899
+ mass: 1,
900
+ velocity: 0,
901
+ // Default duration/bounce-based options
902
+ duration: 800,
903
+ // in ms
904
+ bounce: 0.3,
905
+ visualDuration: 0.3,
906
+ // in seconds
907
+ // Rest thresholds
908
+ restSpeed: {
909
+ granular: 0.01,
910
+ default: 2
911
+ },
912
+ restDelta: {
913
+ granular: 5e-3,
914
+ default: 0.5
915
+ },
916
+ // Limits
917
+ minDuration: 0.01,
918
+ // in seconds
919
+ maxDuration: 10,
920
+ // in seconds
921
+ minDamping: 0.05,
922
+ maxDamping: 1
923
+ };
924
+
925
+ // node_modules/motion-dom/dist/es/animation/generators/spring/find.mjs
926
+ var safeMin = 1e-3;
927
+ function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
928
+ let envelope;
929
+ let derivative;
930
+ warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
931
+ let dampingRatio = 1 - bounce;
932
+ dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
933
+ duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
934
+ if (dampingRatio < 1) {
935
+ envelope = (undampedFreq2) => {
936
+ const exponentialDecay = undampedFreq2 * dampingRatio;
937
+ const delta = exponentialDecay * duration;
938
+ const a = exponentialDecay - velocity;
939
+ const b = calcAngularFreq(undampedFreq2, dampingRatio);
940
+ const c = Math.exp(-delta);
941
+ return safeMin - a / b * c;
942
+ };
943
+ derivative = (undampedFreq2) => {
944
+ const exponentialDecay = undampedFreq2 * dampingRatio;
945
+ const delta = exponentialDecay * duration;
946
+ const d = delta * velocity + velocity;
947
+ const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq2, 2) * duration;
948
+ const f = Math.exp(-delta);
949
+ const g = calcAngularFreq(Math.pow(undampedFreq2, 2), dampingRatio);
950
+ const factor = -envelope(undampedFreq2) + safeMin > 0 ? -1 : 1;
951
+ return factor * ((d - e) * f) / g;
952
+ };
953
+ } else {
954
+ envelope = (undampedFreq2) => {
955
+ const a = Math.exp(-undampedFreq2 * duration);
956
+ const b = (undampedFreq2 - velocity) * duration + 1;
957
+ return -safeMin + a * b;
958
+ };
959
+ derivative = (undampedFreq2) => {
960
+ const a = Math.exp(-undampedFreq2 * duration);
961
+ const b = (velocity - undampedFreq2) * (duration * duration);
962
+ return a * b;
963
+ };
964
+ }
965
+ const initialGuess = 5 / duration;
966
+ const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
967
+ duration = secondsToMilliseconds(duration);
968
+ if (isNaN(undampedFreq)) {
969
+ return {
970
+ stiffness: springDefaults.stiffness,
971
+ damping: springDefaults.damping,
972
+ duration
973
+ };
974
+ } else {
975
+ const stiffness = Math.pow(undampedFreq, 2) * mass;
976
+ return {
977
+ stiffness,
978
+ damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
979
+ duration
980
+ };
981
+ }
982
+ }
983
+ var rootIterations = 12;
984
+ function approximateRoot(envelope, derivative, initialGuess) {
985
+ let result = initialGuess;
986
+ for (let i = 1; i < rootIterations; i++) {
987
+ result = result - envelope(result) / derivative(result);
988
+ }
989
+ return result;
990
+ }
991
+ function calcAngularFreq(undampedFreq, dampingRatio) {
992
+ return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
993
+ }
994
+
995
+ // node_modules/motion-dom/dist/es/animation/generators/spring/index.mjs
996
+ var durationKeys = ["duration", "bounce"];
997
+ var physicsKeys = ["stiffness", "damping", "mass"];
998
+ function isSpringType(options, keys2) {
999
+ return keys2.some((key) => options[key] !== void 0);
1000
+ }
1001
+ function getSpringOptions(options) {
1002
+ let springOptions = {
1003
+ velocity: springDefaults.velocity,
1004
+ stiffness: springDefaults.stiffness,
1005
+ damping: springDefaults.damping,
1006
+ mass: springDefaults.mass,
1007
+ isResolvedFromDuration: false,
1008
+ ...options
1009
+ };
1010
+ if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) {
1011
+ if (options.visualDuration) {
1012
+ const visualDuration = options.visualDuration;
1013
+ const root = 2 * Math.PI / (visualDuration * 1.2);
1014
+ const stiffness = root * root;
1015
+ const damping = 2 * clamp(0.05, 1, 1 - (options.bounce || 0)) * Math.sqrt(stiffness);
1016
+ springOptions = {
1017
+ ...springOptions,
1018
+ mass: springDefaults.mass,
1019
+ stiffness,
1020
+ damping
1021
+ };
1022
+ } else {
1023
+ const derived = findSpring(options);
1024
+ springOptions = {
1025
+ ...springOptions,
1026
+ ...derived,
1027
+ mass: springDefaults.mass
1028
+ };
1029
+ springOptions.isResolvedFromDuration = true;
1030
+ }
1031
+ }
1032
+ return springOptions;
1033
+ }
1034
+ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
1035
+ const options = typeof optionsOrVisualDuration !== "object" ? {
1036
+ visualDuration: optionsOrVisualDuration,
1037
+ keyframes: [0, 1],
1038
+ bounce
1039
+ } : optionsOrVisualDuration;
1040
+ let { restSpeed, restDelta } = options;
1041
+ const origin = options.keyframes[0];
1042
+ const target = options.keyframes[options.keyframes.length - 1];
1043
+ const state = { done: false, value: origin };
1044
+ const { stiffness, damping, mass, duration, velocity, isResolvedFromDuration } = getSpringOptions({
1045
+ ...options,
1046
+ velocity: -millisecondsToSeconds(options.velocity || 0)
1047
+ });
1048
+ const initialVelocity = velocity || 0;
1049
+ const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
1050
+ const initialDelta = target - origin;
1051
+ const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));
1052
+ const isGranularScale = Math.abs(initialDelta) < 5;
1053
+ restSpeed || (restSpeed = isGranularScale ? springDefaults.restSpeed.granular : springDefaults.restSpeed.default);
1054
+ restDelta || (restDelta = isGranularScale ? springDefaults.restDelta.granular : springDefaults.restDelta.default);
1055
+ let resolveSpring;
1056
+ if (dampingRatio < 1) {
1057
+ const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
1058
+ resolveSpring = (t) => {
1059
+ const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
1060
+ return target - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq * Math.sin(angularFreq * t) + initialDelta * Math.cos(angularFreq * t));
1061
+ };
1062
+ } else if (dampingRatio === 1) {
1063
+ resolveSpring = (t) => target - Math.exp(-undampedAngularFreq * t) * (initialDelta + (initialVelocity + undampedAngularFreq * initialDelta) * t);
1064
+ } else {
1065
+ const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
1066
+ resolveSpring = (t) => {
1067
+ const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
1068
+ const freqForT = Math.min(dampedAngularFreq * t, 300);
1069
+ return target - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) * Math.sinh(freqForT) + dampedAngularFreq * initialDelta * Math.cosh(freqForT)) / dampedAngularFreq;
1070
+ };
1071
+ }
1072
+ const generator = {
1073
+ calculatedDuration: isResolvedFromDuration ? duration || null : null,
1074
+ next: (t) => {
1075
+ const current = resolveSpring(t);
1076
+ if (!isResolvedFromDuration) {
1077
+ let currentVelocity = t === 0 ? initialVelocity : 0;
1078
+ if (dampingRatio < 1) {
1079
+ currentVelocity = t === 0 ? secondsToMilliseconds(initialVelocity) : calcGeneratorVelocity(resolveSpring, t, current);
1080
+ }
1081
+ const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
1082
+ const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
1083
+ state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;
1084
+ } else {
1085
+ state.done = t >= duration;
1086
+ }
1087
+ state.value = state.done ? target : current;
1088
+ return state;
1089
+ },
1090
+ toString: () => {
1091
+ const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
1092
+ const easing = generateLinearEasing((progress2) => generator.next(calculatedDuration * progress2).value, calculatedDuration, 30);
1093
+ return calculatedDuration + "ms " + easing;
1094
+ },
1095
+ toTransition: () => {
1096
+ }
1097
+ };
1098
+ return generator;
1099
+ }
1100
+ spring.applyToOptions = (options) => {
1101
+ const generatorOptions = createGeneratorEasing(options, 100, spring);
1102
+ options.ease = generatorOptions.ease;
1103
+ options.duration = secondsToMilliseconds(generatorOptions.duration);
1104
+ options.type = "keyframes";
1105
+ return options;
1106
+ };
1107
+
1108
+ // node_modules/motion-dom/dist/es/animation/generators/inertia.mjs
1109
+ function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
1110
+ const origin = keyframes2[0];
1111
+ const state = {
1112
+ done: false,
1113
+ value: origin
1114
+ };
1115
+ const isOutOfBounds = (v) => min !== void 0 && v < min || max !== void 0 && v > max;
1116
+ const nearestBoundary = (v) => {
1117
+ if (min === void 0)
1118
+ return max;
1119
+ if (max === void 0)
1120
+ return min;
1121
+ return Math.abs(min - v) < Math.abs(max - v) ? min : max;
1122
+ };
1123
+ let amplitude = power * velocity;
1124
+ const ideal = origin + amplitude;
1125
+ const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
1126
+ if (target !== ideal)
1127
+ amplitude = target - origin;
1128
+ const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
1129
+ const calcLatest = (t) => target + calcDelta(t);
1130
+ const applyFriction = (t) => {
1131
+ const delta = calcDelta(t);
1132
+ const latest = calcLatest(t);
1133
+ state.done = Math.abs(delta) <= restDelta;
1134
+ state.value = state.done ? target : latest;
1135
+ };
1136
+ let timeReachedBoundary;
1137
+ let spring$1;
1138
+ const checkCatchBoundary = (t) => {
1139
+ if (!isOutOfBounds(state.value))
1140
+ return;
1141
+ timeReachedBoundary = t;
1142
+ spring$1 = spring({
1143
+ keyframes: [state.value, nearestBoundary(state.value)],
1144
+ velocity: calcGeneratorVelocity(calcLatest, t, state.value),
1145
+ // TODO: This should be passing * 1000
1146
+ damping: bounceDamping,
1147
+ stiffness: bounceStiffness,
1148
+ restDelta,
1149
+ restSpeed
1150
+ });
1151
+ };
1152
+ checkCatchBoundary(0);
1153
+ return {
1154
+ calculatedDuration: null,
1155
+ next: (t) => {
1156
+ let hasUpdatedFrame = false;
1157
+ if (!spring$1 && timeReachedBoundary === void 0) {
1158
+ hasUpdatedFrame = true;
1159
+ applyFriction(t);
1160
+ checkCatchBoundary(t);
1161
+ }
1162
+ if (timeReachedBoundary !== void 0 && t >= timeReachedBoundary) {
1163
+ return spring$1.next(t - timeReachedBoundary);
1164
+ } else {
1165
+ !hasUpdatedFrame && applyFriction(t);
1166
+ return state;
1167
+ }
1168
+ }
1169
+ };
1170
+ }
1171
+
1172
+ // node_modules/motion-dom/dist/es/utils/interpolate.mjs
1173
+ function createMixers(output, ease2, customMixer) {
1174
+ const mixers = [];
1175
+ const mixerFactory = customMixer || MotionGlobalConfig.mix || mix;
1176
+ const numMixers = output.length - 1;
1177
+ for (let i = 0; i < numMixers; i++) {
1178
+ let mixer = mixerFactory(output[i], output[i + 1]);
1179
+ if (ease2) {
1180
+ const easingFunction = Array.isArray(ease2) ? ease2[i] || noop : ease2;
1181
+ mixer = pipe(easingFunction, mixer);
1182
+ }
1183
+ mixers.push(mixer);
1184
+ }
1185
+ return mixers;
1186
+ }
1187
+ function interpolate(input, output, { clamp: isClamp = true, ease: ease2, mixer } = {}) {
1188
+ const inputLength = input.length;
1189
+ invariant(inputLength === output.length, "Both input and output ranges must be the same length", "range-length");
1190
+ if (inputLength === 1)
1191
+ return () => output[0];
1192
+ if (inputLength === 2 && output[0] === output[1])
1193
+ return () => output[1];
1194
+ const isZeroDeltaRange = input[0] === input[1];
1195
+ if (input[0] > input[inputLength - 1]) {
1196
+ input = [...input].reverse();
1197
+ output = [...output].reverse();
1198
+ }
1199
+ const mixers = createMixers(output, ease2, mixer);
1200
+ const numMixers = mixers.length;
1201
+ const interpolator = (v) => {
1202
+ if (isZeroDeltaRange && v < input[0])
1203
+ return output[0];
1204
+ let i = 0;
1205
+ if (numMixers > 1) {
1206
+ for (; i < input.length - 2; i++) {
1207
+ if (v < input[i + 1])
1208
+ break;
1209
+ }
1210
+ }
1211
+ const progressInRange = progress(input[i], input[i + 1], v);
1212
+ return mixers[i](progressInRange);
1213
+ };
1214
+ return isClamp ? (v) => interpolator(clamp(input[0], input[inputLength - 1], v)) : interpolator;
1215
+ }
1216
+
1217
+ // node_modules/motion-dom/dist/es/animation/keyframes/offsets/fill.mjs
1218
+ function fillOffset(offset, remaining) {
1219
+ const min = offset[offset.length - 1];
1220
+ for (let i = 1; i <= remaining; i++) {
1221
+ const offsetProgress = progress(0, remaining, i);
1222
+ offset.push(mixNumber(min, 1, offsetProgress));
1223
+ }
1224
+ }
1225
+
1226
+ // node_modules/motion-dom/dist/es/animation/keyframes/offsets/default.mjs
1227
+ function defaultOffset(arr) {
1228
+ const offset = [0];
1229
+ fillOffset(offset, arr.length - 1);
1230
+ return offset;
1231
+ }
1232
+
1233
+ // node_modules/motion-dom/dist/es/animation/keyframes/offsets/time.mjs
1234
+ function convertOffsetToTimes(offset, duration) {
1235
+ return offset.map((o) => o * duration);
1236
+ }
1237
+
1238
+ // node_modules/motion-dom/dist/es/animation/generators/keyframes.mjs
1239
+ function defaultEasing(values, easing) {
1240
+ return values.map(() => easing || easeInOut).splice(0, values.length - 1);
1241
+ }
1242
+ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease: ease2 = "easeInOut" }) {
1243
+ const easingFunctions = isEasingArray(ease2) ? ease2.map(easingDefinitionToFunction) : easingDefinitionToFunction(ease2);
1244
+ const state = {
1245
+ done: false,
1246
+ value: keyframeValues[0]
1247
+ };
1248
+ const absoluteTimes = convertOffsetToTimes(
1249
+ // Only use the provided offsets if they're the correct length
1250
+ // TODO Maybe we should warn here if there's a length mismatch
1251
+ times && times.length === keyframeValues.length ? times : defaultOffset(keyframeValues),
1252
+ duration
1253
+ );
1254
+ const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
1255
+ ease: Array.isArray(easingFunctions) ? easingFunctions : defaultEasing(keyframeValues, easingFunctions)
1256
+ });
1257
+ return {
1258
+ calculatedDuration: duration,
1259
+ next: (t) => {
1260
+ state.value = mapTimeToKeyframe(t);
1261
+ state.done = t >= duration;
1262
+ return state;
1263
+ }
1264
+ };
1265
+ }
1266
+
1267
+ // node_modules/motion-dom/dist/es/animation/keyframes/get-final.mjs
1268
+ var isNotNull = (value) => value !== null;
1269
+ function getFinalKeyframe(keyframes2, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
1270
+ const resolvedKeyframes = keyframes2.filter(isNotNull);
1271
+ const useFirstKeyframe = speed < 0 || repeat && repeatType !== "loop" && repeat % 2 === 1;
1272
+ const index = useFirstKeyframe ? 0 : resolvedKeyframes.length - 1;
1273
+ return !index || finalKeyframe === void 0 ? resolvedKeyframes[index] : finalKeyframe;
1274
+ }
1275
+
1276
+ // node_modules/motion-dom/dist/es/animation/utils/replace-transition-type.mjs
1277
+ var transitionTypeMap = {
1278
+ decay: inertia,
1279
+ inertia,
1280
+ tween: keyframes,
1281
+ keyframes,
1282
+ spring
1283
+ };
1284
+ function replaceTransitionType(transition) {
1285
+ if (typeof transition.type === "string") {
1286
+ transition.type = transitionTypeMap[transition.type];
1287
+ }
1288
+ }
1289
+
1290
+ // node_modules/motion-dom/dist/es/animation/utils/WithPromise.mjs
1291
+ var WithPromise = class {
1292
+ constructor() {
1293
+ this.updateFinished();
1294
+ }
1295
+ get finished() {
1296
+ return this._finished;
1297
+ }
1298
+ updateFinished() {
1299
+ this._finished = new Promise((resolve) => {
1300
+ this.resolve = resolve;
1301
+ });
1302
+ }
1303
+ notifyFinished() {
1304
+ this.resolve();
1305
+ }
1306
+ /**
1307
+ * Allows the animation to be awaited.
1308
+ *
1309
+ * @deprecated Use `finished` instead.
1310
+ */
1311
+ then(onResolve, onReject) {
1312
+ return this.finished.then(onResolve, onReject);
1313
+ }
1314
+ };
1315
+
1316
+ // node_modules/motion-dom/dist/es/animation/JSAnimation.mjs
1317
+ var percentToProgress = (percent2) => percent2 / 100;
1318
+ var JSAnimation = class extends WithPromise {
1319
+ constructor(options) {
1320
+ super();
1321
+ this.state = "idle";
1322
+ this.startTime = null;
1323
+ this.isStopped = false;
1324
+ this.currentTime = 0;
1325
+ this.holdTime = null;
1326
+ this.playbackSpeed = 1;
1327
+ this.stop = () => {
1328
+ const { motionValue: motionValue2 } = this.options;
1329
+ if (motionValue2 && motionValue2.updatedAt !== time.now()) {
1330
+ this.tick(time.now());
1331
+ }
1332
+ this.isStopped = true;
1333
+ if (this.state === "idle")
1334
+ return;
1335
+ this.teardown();
1336
+ this.options.onStop?.();
1337
+ };
1338
+ activeAnimations.mainThread++;
1339
+ this.options = options;
1340
+ this.initAnimation();
1341
+ this.play();
1342
+ if (options.autoplay === false)
1343
+ this.pause();
1344
+ }
1345
+ initAnimation() {
1346
+ const { options } = this;
1347
+ replaceTransitionType(options);
1348
+ const { type = keyframes, repeat = 0, repeatDelay = 0, repeatType, velocity = 0 } = options;
1349
+ let { keyframes: keyframes$1 } = options;
1350
+ const generatorFactory = type || keyframes;
1351
+ if (process.env.NODE_ENV !== "production" && generatorFactory !== keyframes) {
1352
+ invariant(keyframes$1.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`, "spring-two-frames");
1353
+ }
1354
+ if (generatorFactory !== keyframes && typeof keyframes$1[0] !== "number") {
1355
+ this.mixKeyframes = pipe(percentToProgress, mix(keyframes$1[0], keyframes$1[1]));
1356
+ keyframes$1 = [0, 100];
1357
+ }
1358
+ const generator = generatorFactory({ ...options, keyframes: keyframes$1 });
1359
+ if (repeatType === "mirror") {
1360
+ this.mirroredGenerator = generatorFactory({
1361
+ ...options,
1362
+ keyframes: [...keyframes$1].reverse(),
1363
+ velocity: -velocity
1364
+ });
1365
+ }
1366
+ if (generator.calculatedDuration === null) {
1367
+ generator.calculatedDuration = calcGeneratorDuration(generator);
1368
+ }
1369
+ const { calculatedDuration } = generator;
1370
+ this.calculatedDuration = calculatedDuration;
1371
+ this.resolvedDuration = calculatedDuration + repeatDelay;
1372
+ this.totalDuration = this.resolvedDuration * (repeat + 1) - repeatDelay;
1373
+ this.generator = generator;
1374
+ }
1375
+ updateTime(timestamp) {
1376
+ const animationTime = Math.round(timestamp - this.startTime) * this.playbackSpeed;
1377
+ if (this.holdTime !== null) {
1378
+ this.currentTime = this.holdTime;
1379
+ } else {
1380
+ this.currentTime = animationTime;
1381
+ }
1382
+ }
1383
+ tick(timestamp, sample = false) {
1384
+ const { generator, totalDuration, mixKeyframes, mirroredGenerator, resolvedDuration, calculatedDuration } = this;
1385
+ if (this.startTime === null)
1386
+ return generator.next(0);
1387
+ const { delay = 0, keyframes: keyframes2, repeat, repeatType, repeatDelay, type, onUpdate, finalKeyframe } = this.options;
1388
+ if (this.speed > 0) {
1389
+ this.startTime = Math.min(this.startTime, timestamp);
1390
+ } else if (this.speed < 0) {
1391
+ this.startTime = Math.min(timestamp - totalDuration / this.speed, this.startTime);
1392
+ }
1393
+ if (sample) {
1394
+ this.currentTime = timestamp;
1395
+ } else {
1396
+ this.updateTime(timestamp);
1397
+ }
1398
+ const timeWithoutDelay = this.currentTime - delay * (this.playbackSpeed >= 0 ? 1 : -1);
1399
+ const isInDelayPhase = this.playbackSpeed >= 0 ? timeWithoutDelay < 0 : timeWithoutDelay > totalDuration;
1400
+ this.currentTime = Math.max(timeWithoutDelay, 0);
1401
+ if (this.state === "finished" && this.holdTime === null) {
1402
+ this.currentTime = totalDuration;
1403
+ }
1404
+ let elapsed = this.currentTime;
1405
+ let frameGenerator = generator;
1406
+ if (repeat) {
1407
+ const progress2 = Math.min(this.currentTime, totalDuration) / resolvedDuration;
1408
+ let currentIteration = Math.floor(progress2);
1409
+ let iterationProgress = progress2 % 1;
1410
+ if (!iterationProgress && progress2 >= 1) {
1411
+ iterationProgress = 1;
1412
+ }
1413
+ iterationProgress === 1 && currentIteration--;
1414
+ currentIteration = Math.min(currentIteration, repeat + 1);
1415
+ const isOddIteration = Boolean(currentIteration % 2);
1416
+ if (isOddIteration) {
1417
+ if (repeatType === "reverse") {
1418
+ iterationProgress = 1 - iterationProgress;
1419
+ if (repeatDelay) {
1420
+ iterationProgress -= repeatDelay / resolvedDuration;
1421
+ }
1422
+ } else if (repeatType === "mirror") {
1423
+ frameGenerator = mirroredGenerator;
1424
+ }
1425
+ }
1426
+ elapsed = clamp(0, 1, iterationProgress) * resolvedDuration;
1427
+ }
1428
+ const state = isInDelayPhase ? { done: false, value: keyframes2[0] } : frameGenerator.next(elapsed);
1429
+ if (mixKeyframes) {
1430
+ state.value = mixKeyframes(state.value);
1431
+ }
1432
+ let { done } = state;
1433
+ if (!isInDelayPhase && calculatedDuration !== null) {
1434
+ done = this.playbackSpeed >= 0 ? this.currentTime >= totalDuration : this.currentTime <= 0;
1435
+ }
1436
+ const isAnimationFinished = this.holdTime === null && (this.state === "finished" || this.state === "running" && done);
1437
+ if (isAnimationFinished && type !== inertia) {
1438
+ state.value = getFinalKeyframe(keyframes2, this.options, finalKeyframe, this.speed);
1439
+ }
1440
+ if (onUpdate) {
1441
+ onUpdate(state.value);
1442
+ }
1443
+ if (isAnimationFinished) {
1444
+ this.finish();
1445
+ }
1446
+ return state;
1447
+ }
1448
+ /**
1449
+ * Allows the returned animation to be awaited or promise-chained. Currently
1450
+ * resolves when the animation finishes at all but in a future update could/should
1451
+ * reject if its cancels.
1452
+ */
1453
+ then(resolve, reject) {
1454
+ return this.finished.then(resolve, reject);
1455
+ }
1456
+ get duration() {
1457
+ return millisecondsToSeconds(this.calculatedDuration);
1458
+ }
1459
+ get iterationDuration() {
1460
+ const { delay = 0 } = this.options || {};
1461
+ return this.duration + millisecondsToSeconds(delay);
1462
+ }
1463
+ get time() {
1464
+ return millisecondsToSeconds(this.currentTime);
1465
+ }
1466
+ set time(newTime) {
1467
+ newTime = secondsToMilliseconds(newTime);
1468
+ this.currentTime = newTime;
1469
+ if (this.startTime === null || this.holdTime !== null || this.playbackSpeed === 0) {
1470
+ this.holdTime = newTime;
1471
+ } else if (this.driver) {
1472
+ this.startTime = this.driver.now() - newTime / this.playbackSpeed;
1473
+ }
1474
+ this.driver?.start(false);
1475
+ }
1476
+ get speed() {
1477
+ return this.playbackSpeed;
1478
+ }
1479
+ set speed(newSpeed) {
1480
+ this.updateTime(time.now());
1481
+ const hasChanged = this.playbackSpeed !== newSpeed;
1482
+ this.playbackSpeed = newSpeed;
1483
+ if (hasChanged) {
1484
+ this.time = millisecondsToSeconds(this.currentTime);
1485
+ }
1486
+ }
1487
+ play() {
1488
+ if (this.isStopped)
1489
+ return;
1490
+ const { driver = frameloopDriver, startTime } = this.options;
1491
+ if (!this.driver) {
1492
+ this.driver = driver((timestamp) => this.tick(timestamp));
1493
+ }
1494
+ this.options.onPlay?.();
1495
+ const now2 = this.driver.now();
1496
+ if (this.state === "finished") {
1497
+ this.updateFinished();
1498
+ this.startTime = now2;
1499
+ } else if (this.holdTime !== null) {
1500
+ this.startTime = now2 - this.holdTime;
1501
+ } else if (!this.startTime) {
1502
+ this.startTime = startTime ?? now2;
1503
+ }
1504
+ if (this.state === "finished" && this.speed < 0) {
1505
+ this.startTime += this.calculatedDuration;
1506
+ }
1507
+ this.holdTime = null;
1508
+ this.state = "running";
1509
+ this.driver.start();
1510
+ }
1511
+ pause() {
1512
+ this.state = "paused";
1513
+ this.updateTime(time.now());
1514
+ this.holdTime = this.currentTime;
1515
+ }
1516
+ complete() {
1517
+ if (this.state !== "running") {
1518
+ this.play();
1519
+ }
1520
+ this.state = "finished";
1521
+ this.holdTime = null;
1522
+ }
1523
+ finish() {
1524
+ this.notifyFinished();
1525
+ this.teardown();
1526
+ this.state = "finished";
1527
+ this.options.onComplete?.();
1528
+ }
1529
+ cancel() {
1530
+ this.holdTime = null;
1531
+ this.startTime = 0;
1532
+ this.tick(0);
1533
+ this.teardown();
1534
+ this.options.onCancel?.();
1535
+ }
1536
+ teardown() {
1537
+ this.state = "idle";
1538
+ this.stopDriver();
1539
+ this.startTime = this.holdTime = null;
1540
+ activeAnimations.mainThread--;
1541
+ }
1542
+ stopDriver() {
1543
+ if (!this.driver)
1544
+ return;
1545
+ this.driver.stop();
1546
+ this.driver = void 0;
1547
+ }
1548
+ sample(sampleTime) {
1549
+ this.startTime = 0;
1550
+ return this.tick(sampleTime, true);
1551
+ }
1552
+ attachTimeline(timeline) {
1553
+ if (this.options.allowFlatten) {
1554
+ this.options.type = "keyframes";
1555
+ this.options.ease = "linear";
1556
+ this.initAnimation();
1557
+ }
1558
+ this.driver?.stop();
1559
+ return timeline.observe(this);
1560
+ }
1561
+ };
1562
+
1563
+ // node_modules/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs
1564
+ function fillWildcards(keyframes2) {
1565
+ for (let i = 1; i < keyframes2.length; i++) {
1566
+ keyframes2[i] ?? (keyframes2[i] = keyframes2[i - 1]);
1567
+ }
1568
+ }
1569
+
1570
+ // node_modules/motion-dom/dist/es/render/dom/parse-transform.mjs
1571
+ var radToDeg = (rad) => rad * 180 / Math.PI;
1572
+ var rotate = (v) => {
1573
+ const angle = radToDeg(Math.atan2(v[1], v[0]));
1574
+ return rebaseAngle(angle);
1575
+ };
1576
+ var matrix2dParsers = {
1577
+ x: 4,
1578
+ y: 5,
1579
+ translateX: 4,
1580
+ translateY: 5,
1581
+ scaleX: 0,
1582
+ scaleY: 3,
1583
+ scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,
1584
+ rotate,
1585
+ rotateZ: rotate,
1586
+ skewX: (v) => radToDeg(Math.atan(v[1])),
1587
+ skewY: (v) => radToDeg(Math.atan(v[2])),
1588
+ skew: (v) => (Math.abs(v[1]) + Math.abs(v[2])) / 2
1589
+ };
1590
+ var rebaseAngle = (angle) => {
1591
+ angle = angle % 360;
1592
+ if (angle < 0)
1593
+ angle += 360;
1594
+ return angle;
1595
+ };
1596
+ var rotateZ = rotate;
1597
+ var scaleX = (v) => Math.sqrt(v[0] * v[0] + v[1] * v[1]);
1598
+ var scaleY = (v) => Math.sqrt(v[4] * v[4] + v[5] * v[5]);
1599
+ var matrix3dParsers = {
1600
+ x: 12,
1601
+ y: 13,
1602
+ z: 14,
1603
+ translateX: 12,
1604
+ translateY: 13,
1605
+ translateZ: 14,
1606
+ scaleX,
1607
+ scaleY,
1608
+ scale: (v) => (scaleX(v) + scaleY(v)) / 2,
1609
+ rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),
1610
+ rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),
1611
+ rotateZ,
1612
+ rotate: rotateZ,
1613
+ skewX: (v) => radToDeg(Math.atan(v[4])),
1614
+ skewY: (v) => radToDeg(Math.atan(v[1])),
1615
+ skew: (v) => (Math.abs(v[1]) + Math.abs(v[4])) / 2
1616
+ };
1617
+ function defaultTransformValue(name) {
1618
+ return name.includes("scale") ? 1 : 0;
1619
+ }
1620
+ function parseValueFromTransform(transform2, name) {
1621
+ if (!transform2 || transform2 === "none") {
1622
+ return defaultTransformValue(name);
1623
+ }
1624
+ const matrix3dMatch = transform2.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
1625
+ let parsers;
1626
+ let match;
1627
+ if (matrix3dMatch) {
1628
+ parsers = matrix3dParsers;
1629
+ match = matrix3dMatch;
1630
+ } else {
1631
+ const matrix2dMatch = transform2.match(/^matrix\(([-\d.e\s,]+)\)$/u);
1632
+ parsers = matrix2dParsers;
1633
+ match = matrix2dMatch;
1634
+ }
1635
+ if (!match) {
1636
+ return defaultTransformValue(name);
1637
+ }
1638
+ const valueParser = parsers[name];
1639
+ const values = match[1].split(",").map(convertTransformToNumber);
1640
+ return typeof valueParser === "function" ? valueParser(values) : values[valueParser];
1641
+ }
1642
+ function convertTransformToNumber(value) {
1643
+ return parseFloat(value.trim());
1644
+ }
1645
+
1646
+ // node_modules/motion-dom/dist/es/render/utils/keys-transform.mjs
1647
+ var transformPropOrder = [
1648
+ "transformPerspective",
1649
+ "x",
1650
+ "y",
1651
+ "z",
1652
+ "translateX",
1653
+ "translateY",
1654
+ "translateZ",
1655
+ "scale",
1656
+ "scaleX",
1657
+ "scaleY",
1658
+ "rotate",
1659
+ "rotateX",
1660
+ "rotateY",
1661
+ "rotateZ",
1662
+ "skew",
1663
+ "skewX",
1664
+ "skewY"
1665
+ ];
1666
+ var transformProps = /* @__PURE__ */ (() => new Set(transformPropOrder))();
1667
+
1668
+ // node_modules/motion-dom/dist/es/animation/keyframes/utils/unit-conversion.mjs
1669
+ var transformKeys = /* @__PURE__ */ new Set(["x", "y", "z"]);
1670
+ var nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
1671
+ function removeNonTranslationalTransform(visualElement) {
1672
+ const removedTransforms = [];
1673
+ nonTranslationalTransformKeys.forEach((key) => {
1674
+ const value = visualElement.getValue(key);
1675
+ if (value !== void 0) {
1676
+ removedTransforms.push([key, value.get()]);
1677
+ value.set(key.startsWith("scale") ? 1 : 0);
1678
+ }
1679
+ });
1680
+ return removedTransforms;
1681
+ }
1682
+ var positionalValues = {
1683
+ // Dimensions
1684
+ width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
1685
+ height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
1686
+ top: (_bbox, { top }) => parseFloat(top),
1687
+ left: (_bbox, { left }) => parseFloat(left),
1688
+ bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
1689
+ right: ({ x }, { left }) => parseFloat(left) + (x.max - x.min),
1690
+ // Transform
1691
+ x: (_bbox, { transform: transform2 }) => parseValueFromTransform(transform2, "x"),
1692
+ y: (_bbox, { transform: transform2 }) => parseValueFromTransform(transform2, "y")
1693
+ };
1694
+ positionalValues.translateX = positionalValues.x;
1695
+ positionalValues.translateY = positionalValues.y;
1696
+
1697
+ // node_modules/motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs
1698
+ var toResolve = /* @__PURE__ */ new Set();
1699
+ var isScheduled = false;
1700
+ var anyNeedsMeasurement = false;
1701
+ var isForced = false;
1702
+ function measureAllKeyframes() {
1703
+ if (anyNeedsMeasurement) {
1704
+ const resolversToMeasure = Array.from(toResolve).filter((resolver) => resolver.needsMeasurement);
1705
+ const elementsToMeasure = new Set(resolversToMeasure.map((resolver) => resolver.element));
1706
+ const transformsToRestore = /* @__PURE__ */ new Map();
1707
+ elementsToMeasure.forEach((element) => {
1708
+ const removedTransforms = removeNonTranslationalTransform(element);
1709
+ if (!removedTransforms.length)
1710
+ return;
1711
+ transformsToRestore.set(element, removedTransforms);
1712
+ element.render();
1713
+ });
1714
+ resolversToMeasure.forEach((resolver) => resolver.measureInitialState());
1715
+ elementsToMeasure.forEach((element) => {
1716
+ element.render();
1717
+ const restore = transformsToRestore.get(element);
1718
+ if (restore) {
1719
+ restore.forEach(([key, value]) => {
1720
+ element.getValue(key)?.set(value);
1721
+ });
1722
+ }
1723
+ });
1724
+ resolversToMeasure.forEach((resolver) => resolver.measureEndState());
1725
+ resolversToMeasure.forEach((resolver) => {
1726
+ if (resolver.suspendedScrollY !== void 0) {
1727
+ window.scrollTo(0, resolver.suspendedScrollY);
1728
+ }
1729
+ });
1730
+ }
1731
+ anyNeedsMeasurement = false;
1732
+ isScheduled = false;
1733
+ toResolve.forEach((resolver) => resolver.complete(isForced));
1734
+ toResolve.clear();
1735
+ }
1736
+ function readAllKeyframes() {
1737
+ toResolve.forEach((resolver) => {
1738
+ resolver.readKeyframes();
1739
+ if (resolver.needsMeasurement) {
1740
+ anyNeedsMeasurement = true;
1741
+ }
1742
+ });
1743
+ }
1744
+ function flushKeyframeResolvers() {
1745
+ isForced = true;
1746
+ readAllKeyframes();
1747
+ measureAllKeyframes();
1748
+ isForced = false;
1749
+ }
1750
+ var KeyframeResolver = class {
1751
+ constructor(unresolvedKeyframes, onComplete, name, motionValue2, element, isAsync = false) {
1752
+ this.state = "pending";
1753
+ this.isAsync = false;
1754
+ this.needsMeasurement = false;
1755
+ this.unresolvedKeyframes = [...unresolvedKeyframes];
1756
+ this.onComplete = onComplete;
1757
+ this.name = name;
1758
+ this.motionValue = motionValue2;
1759
+ this.element = element;
1760
+ this.isAsync = isAsync;
1761
+ }
1762
+ scheduleResolve() {
1763
+ this.state = "scheduled";
1764
+ if (this.isAsync) {
1765
+ toResolve.add(this);
1766
+ if (!isScheduled) {
1767
+ isScheduled = true;
1768
+ frame.read(readAllKeyframes);
1769
+ frame.resolveKeyframes(measureAllKeyframes);
1770
+ }
1771
+ } else {
1772
+ this.readKeyframes();
1773
+ this.complete();
1774
+ }
1775
+ }
1776
+ readKeyframes() {
1777
+ const { unresolvedKeyframes, name, element, motionValue: motionValue2 } = this;
1778
+ if (unresolvedKeyframes[0] === null) {
1779
+ const currentValue = motionValue2?.get();
1780
+ const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
1781
+ if (currentValue !== void 0) {
1782
+ unresolvedKeyframes[0] = currentValue;
1783
+ } else if (element && name) {
1784
+ const valueAsRead = element.readValue(name, finalKeyframe);
1785
+ if (valueAsRead !== void 0 && valueAsRead !== null) {
1786
+ unresolvedKeyframes[0] = valueAsRead;
1787
+ }
1788
+ }
1789
+ if (unresolvedKeyframes[0] === void 0) {
1790
+ unresolvedKeyframes[0] = finalKeyframe;
1791
+ }
1792
+ if (motionValue2 && currentValue === void 0) {
1793
+ motionValue2.set(unresolvedKeyframes[0]);
1794
+ }
1795
+ }
1796
+ fillWildcards(unresolvedKeyframes);
1797
+ }
1798
+ setFinalKeyframe() {
1799
+ }
1800
+ measureInitialState() {
1801
+ }
1802
+ renderEndStyles() {
1803
+ }
1804
+ measureEndState() {
1805
+ }
1806
+ complete(isForcedComplete = false) {
1807
+ this.state = "complete";
1808
+ this.onComplete(this.unresolvedKeyframes, this.finalKeyframe, isForcedComplete);
1809
+ toResolve.delete(this);
1810
+ }
1811
+ cancel() {
1812
+ if (this.state === "scheduled") {
1813
+ toResolve.delete(this);
1814
+ this.state = "pending";
1815
+ }
1816
+ }
1817
+ resume() {
1818
+ if (this.state === "pending")
1819
+ this.scheduleResolve();
1820
+ }
1821
+ };
1822
+
1823
+ // node_modules/motion-dom/dist/es/render/dom/is-css-var.mjs
1824
+ var isCSSVar = (name) => name.startsWith("--");
1825
+
1826
+ // node_modules/motion-dom/dist/es/render/dom/style-set.mjs
1827
+ function setStyle(element, name, value) {
1828
+ isCSSVar(name) ? element.style.setProperty(name, value) : element.style[name] = value;
1829
+ }
1830
+
1831
+ // node_modules/motion-dom/dist/es/utils/supports/scroll-timeline.mjs
1832
+ var supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== void 0);
1833
+
1834
+ // node_modules/motion-dom/dist/es/utils/supports/flags.mjs
1835
+ var supportsFlags = {};
1836
+
1837
+ // node_modules/motion-dom/dist/es/utils/supports/memo.mjs
1838
+ function memoSupports(callback, supportsFlag) {
1839
+ const memoized = memo(callback);
1840
+ return () => supportsFlags[supportsFlag] ?? memoized();
1841
+ }
1842
+
1843
+ // node_modules/motion-dom/dist/es/utils/supports/linear-easing.mjs
1844
+ var supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
1845
+ try {
1846
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
1847
+ } catch (e) {
1848
+ return false;
1849
+ }
1850
+ return true;
1851
+ }, "linearEasing");
1852
+
1853
+ // node_modules/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs
1854
+ var cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
1855
+
1856
+ // node_modules/motion-dom/dist/es/animation/waapi/easing/supported.mjs
1857
+ var supportedWaapiEasing = {
1858
+ linear: "linear",
1859
+ ease: "ease",
1860
+ easeIn: "ease-in",
1861
+ easeOut: "ease-out",
1862
+ easeInOut: "ease-in-out",
1863
+ circIn: /* @__PURE__ */ cubicBezierAsString([0, 0.65, 0.55, 1]),
1864
+ circOut: /* @__PURE__ */ cubicBezierAsString([0.55, 0, 1, 0.45]),
1865
+ backIn: /* @__PURE__ */ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
1866
+ backOut: /* @__PURE__ */ cubicBezierAsString([0.33, 1.53, 0.69, 0.99])
1867
+ };
1868
+
1869
+ // node_modules/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs
1870
+ function mapEasingToNativeEasing(easing, duration) {
1871
+ if (!easing) {
1872
+ return void 0;
1873
+ } else if (typeof easing === "function") {
1874
+ return supportsLinearEasing() ? generateLinearEasing(easing, duration) : "ease-out";
1875
+ } else if (isBezierDefinition(easing)) {
1876
+ return cubicBezierAsString(easing);
1877
+ } else if (Array.isArray(easing)) {
1878
+ return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) || supportedWaapiEasing.easeOut);
1879
+ } else {
1880
+ return supportedWaapiEasing[easing];
1881
+ }
1882
+ }
1883
+
1884
+ // node_modules/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs
1885
+ function startWaapiAnimation(element, valueName, keyframes2, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease: ease2 = "easeOut", times } = {}, pseudoElement = void 0) {
1886
+ const keyframeOptions = {
1887
+ [valueName]: keyframes2
1888
+ };
1889
+ if (times)
1890
+ keyframeOptions.offset = times;
1891
+ const easing = mapEasingToNativeEasing(ease2, duration);
1892
+ if (Array.isArray(easing))
1893
+ keyframeOptions.easing = easing;
1894
+ if (statsBuffer.value) {
1895
+ activeAnimations.waapi++;
1896
+ }
1897
+ const options = {
1898
+ delay,
1899
+ duration,
1900
+ easing: !Array.isArray(easing) ? easing : "linear",
1901
+ fill: "both",
1902
+ iterations: repeat + 1,
1903
+ direction: repeatType === "reverse" ? "alternate" : "normal"
1904
+ };
1905
+ if (pseudoElement)
1906
+ options.pseudoElement = pseudoElement;
1907
+ const animation = element.animate(keyframeOptions, options);
1908
+ if (statsBuffer.value) {
1909
+ animation.finished.finally(() => {
1910
+ activeAnimations.waapi--;
1911
+ });
1912
+ }
1913
+ return animation;
1914
+ }
1915
+
1916
+ // node_modules/motion-dom/dist/es/animation/generators/utils/is-generator.mjs
1917
+ function isGenerator(type) {
1918
+ return typeof type === "function" && "applyToOptions" in type;
1919
+ }
1920
+
1921
+ // node_modules/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs
1922
+ function applyGeneratorOptions({ type, ...options }) {
1923
+ if (isGenerator(type) && supportsLinearEasing()) {
1924
+ return type.applyToOptions(options);
1925
+ } else {
1926
+ options.duration ?? (options.duration = 300);
1927
+ options.ease ?? (options.ease = "easeOut");
1928
+ }
1929
+ return options;
1930
+ }
1931
+
1932
+ // node_modules/motion-dom/dist/es/animation/NativeAnimation.mjs
1933
+ var NativeAnimation = class extends WithPromise {
1934
+ constructor(options) {
1935
+ super();
1936
+ this.finishedTime = null;
1937
+ this.isStopped = false;
1938
+ this.manualStartTime = null;
1939
+ if (!options)
1940
+ return;
1941
+ const { element, name, keyframes: keyframes2, pseudoElement, allowFlatten = false, finalKeyframe, onComplete } = options;
1942
+ this.isPseudoElement = Boolean(pseudoElement);
1943
+ this.allowFlatten = allowFlatten;
1944
+ this.options = options;
1945
+ invariant(typeof options.type !== "string", `Mini animate() doesn't support "type" as a string.`, "mini-spring");
1946
+ const transition = applyGeneratorOptions(options);
1947
+ this.animation = startWaapiAnimation(element, name, keyframes2, transition, pseudoElement);
1948
+ if (transition.autoplay === false) {
1949
+ this.animation.pause();
1950
+ }
1951
+ this.animation.onfinish = () => {
1952
+ this.finishedTime = this.time;
1953
+ if (!pseudoElement) {
1954
+ const keyframe = getFinalKeyframe(keyframes2, this.options, finalKeyframe, this.speed);
1955
+ if (this.updateMotionValue) {
1956
+ this.updateMotionValue(keyframe);
1957
+ } else {
1958
+ setStyle(element, name, keyframe);
1959
+ }
1960
+ this.animation.cancel();
1961
+ }
1962
+ onComplete?.();
1963
+ this.notifyFinished();
1964
+ };
1965
+ }
1966
+ play() {
1967
+ if (this.isStopped)
1968
+ return;
1969
+ this.manualStartTime = null;
1970
+ this.animation.play();
1971
+ if (this.state === "finished") {
1972
+ this.updateFinished();
1973
+ }
1974
+ }
1975
+ pause() {
1976
+ this.animation.pause();
1977
+ }
1978
+ complete() {
1979
+ this.animation.finish?.();
1980
+ }
1981
+ cancel() {
1982
+ try {
1983
+ this.animation.cancel();
1984
+ } catch (e) {
1985
+ }
1986
+ }
1987
+ stop() {
1988
+ if (this.isStopped)
1989
+ return;
1990
+ this.isStopped = true;
1991
+ const { state } = this;
1992
+ if (state === "idle" || state === "finished") {
1993
+ return;
1994
+ }
1995
+ if (this.updateMotionValue) {
1996
+ this.updateMotionValue();
1997
+ } else {
1998
+ this.commitStyles();
1999
+ }
2000
+ if (!this.isPseudoElement)
2001
+ this.cancel();
2002
+ }
2003
+ /**
2004
+ * WAAPI doesn't natively have any interruption capabilities.
2005
+ *
2006
+ * In this method, we commit styles back to the DOM before cancelling
2007
+ * the animation.
2008
+ *
2009
+ * This is designed to be overridden by NativeAnimationExtended, which
2010
+ * will create a renderless JS animation and sample it twice to calculate
2011
+ * its current value, "previous" value, and therefore allow
2012
+ * Motion to also correctly calculate velocity for any subsequent animation
2013
+ * while deferring the commit until the next animation frame.
2014
+ */
2015
+ commitStyles() {
2016
+ if (!this.isPseudoElement) {
2017
+ this.animation.commitStyles?.();
2018
+ }
2019
+ }
2020
+ get duration() {
2021
+ const duration = this.animation.effect?.getComputedTiming?.().duration || 0;
2022
+ return millisecondsToSeconds(Number(duration));
2023
+ }
2024
+ get iterationDuration() {
2025
+ const { delay = 0 } = this.options || {};
2026
+ return this.duration + millisecondsToSeconds(delay);
2027
+ }
2028
+ get time() {
2029
+ return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2030
+ }
2031
+ set time(newTime) {
2032
+ this.manualStartTime = null;
2033
+ this.finishedTime = null;
2034
+ this.animation.currentTime = secondsToMilliseconds(newTime);
2035
+ }
2036
+ /**
2037
+ * The playback speed of the animation.
2038
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
2039
+ */
2040
+ get speed() {
2041
+ return this.animation.playbackRate;
2042
+ }
2043
+ set speed(newSpeed) {
2044
+ if (newSpeed < 0)
2045
+ this.finishedTime = null;
2046
+ this.animation.playbackRate = newSpeed;
2047
+ }
2048
+ get state() {
2049
+ return this.finishedTime !== null ? "finished" : this.animation.playState;
2050
+ }
2051
+ get startTime() {
2052
+ return this.manualStartTime ?? Number(this.animation.startTime);
2053
+ }
2054
+ set startTime(newStartTime) {
2055
+ this.manualStartTime = this.animation.startTime = newStartTime;
2056
+ }
2057
+ /**
2058
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
2059
+ */
2060
+ attachTimeline({ timeline, observe }) {
2061
+ if (this.allowFlatten) {
2062
+ this.animation.effect?.updateTiming({ easing: "linear" });
2063
+ }
2064
+ this.animation.onfinish = null;
2065
+ if (timeline && supportsScrollTimeline()) {
2066
+ this.animation.timeline = timeline;
2067
+ return noop;
2068
+ } else {
2069
+ return observe(this);
2070
+ }
2071
+ }
2072
+ };
2073
+
2074
+ // node_modules/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.mjs
2075
+ var unsupportedEasingFunctions = {
2076
+ anticipate,
2077
+ backInOut,
2078
+ circInOut
2079
+ };
2080
+ function isUnsupportedEase(key) {
2081
+ return key in unsupportedEasingFunctions;
2082
+ }
2083
+ function replaceStringEasing(transition) {
2084
+ if (typeof transition.ease === "string" && isUnsupportedEase(transition.ease)) {
2085
+ transition.ease = unsupportedEasingFunctions[transition.ease];
2086
+ }
2087
+ }
2088
+
2089
+ // node_modules/motion-dom/dist/es/animation/NativeAnimationExtended.mjs
2090
+ var sampleDelta = 10;
2091
+ var NativeAnimationExtended = class extends NativeAnimation {
2092
+ constructor(options) {
2093
+ replaceStringEasing(options);
2094
+ replaceTransitionType(options);
2095
+ super(options);
2096
+ if (options.startTime !== void 0) {
2097
+ this.startTime = options.startTime;
2098
+ }
2099
+ this.options = options;
2100
+ }
2101
+ /**
2102
+ * WAAPI doesn't natively have any interruption capabilities.
2103
+ *
2104
+ * Rather than read committed styles back out of the DOM, we can
2105
+ * create a renderless JS animation and sample it twice to calculate
2106
+ * its current value, "previous" value, and therefore allow
2107
+ * Motion to calculate velocity for any subsequent animation.
2108
+ */
2109
+ updateMotionValue(value) {
2110
+ const { motionValue: motionValue2, onUpdate, onComplete, element, ...options } = this.options;
2111
+ if (!motionValue2)
2112
+ return;
2113
+ if (value !== void 0) {
2114
+ motionValue2.set(value);
2115
+ return;
2116
+ }
2117
+ const sampleAnimation = new JSAnimation({
2118
+ ...options,
2119
+ autoplay: false
2120
+ });
2121
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2122
+ const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
2123
+ motionValue2.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
2124
+ sampleAnimation.stop();
2125
+ }
2126
+ };
2127
+
2128
+ // node_modules/motion-dom/dist/es/animation/utils/is-animatable.mjs
2129
+ var isAnimatable = (value, name) => {
2130
+ if (name === "zIndex")
2131
+ return false;
2132
+ if (typeof value === "number" || Array.isArray(value))
2133
+ return true;
2134
+ if (typeof value === "string" && // It's animatable if we have a string
2135
+ (complex.test(value) || value === "0") && // And it contains numbers and/or colors
2136
+ !value.startsWith("url(")) {
2137
+ return true;
2138
+ }
2139
+ return false;
2140
+ };
2141
+
2142
+ // node_modules/motion-dom/dist/es/animation/utils/can-animate.mjs
2143
+ function hasKeyframesChanged(keyframes2) {
2144
+ const current = keyframes2[0];
2145
+ if (keyframes2.length === 1)
2146
+ return true;
2147
+ for (let i = 0; i < keyframes2.length; i++) {
2148
+ if (keyframes2[i] !== current)
2149
+ return true;
2150
+ }
2151
+ }
2152
+ function canAnimate(keyframes2, name, type, velocity) {
2153
+ const originKeyframe = keyframes2[0];
2154
+ if (originKeyframe === null) {
2155
+ return false;
2156
+ }
2157
+ if (name === "display" || name === "visibility")
2158
+ return true;
2159
+ const targetKeyframe = keyframes2[keyframes2.length - 1];
2160
+ const isOriginAnimatable = isAnimatable(originKeyframe, name);
2161
+ const isTargetAnimatable = isAnimatable(targetKeyframe, name);
2162
+ warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". "${isOriginAnimatable ? targetKeyframe : originKeyframe}" is not an animatable value.`, "value-not-animatable");
2163
+ if (!isOriginAnimatable || !isTargetAnimatable) {
2164
+ return false;
2165
+ }
2166
+ return hasKeyframesChanged(keyframes2) || (type === "spring" || isGenerator(type)) && velocity;
2167
+ }
2168
+
2169
+ // node_modules/motion-dom/dist/es/animation/utils/make-animation-instant.mjs
2170
+ function makeAnimationInstant(options) {
2171
+ options.duration = 0;
2172
+ options.type = "keyframes";
2173
+ }
2174
+
2175
+ // node_modules/motion-dom/dist/es/animation/waapi/supports/waapi.mjs
2176
+ var acceleratedValues = /* @__PURE__ */ new Set([
2177
+ "opacity",
2178
+ "clipPath",
2179
+ "filter",
2180
+ "transform"
2181
+ // TODO: Could be re-enabled now we have support for linear() easing
2182
+ // "background-color"
2183
+ ]);
2184
+ var supportsWaapi = /* @__PURE__ */ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
2185
+ function supportsBrowserAnimation(options) {
2186
+ const { motionValue: motionValue2, name, repeatDelay, repeatType, damping, type } = options;
2187
+ const subject = motionValue2?.owner?.current;
2188
+ if (!(subject instanceof HTMLElement)) {
2189
+ return false;
2190
+ }
2191
+ const { onUpdate, transformTemplate } = motionValue2.owner.getProps();
2192
+ return supportsWaapi() && name && acceleratedValues.has(name) && (name !== "transform" || !transformTemplate) && /**
2193
+ * If we're outputting values to onUpdate then we can't use WAAPI as there's
2194
+ * no way to read the value from WAAPI every frame.
2195
+ */
2196
+ !onUpdate && !repeatDelay && repeatType !== "mirror" && damping !== 0 && type !== "inertia";
2197
+ }
2198
+
2199
+ // node_modules/motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs
2200
+ var MAX_RESOLVE_DELAY = 40;
2201
+ var AsyncMotionValueAnimation = class extends WithPromise {
2202
+ constructor({ autoplay = true, delay = 0, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", keyframes: keyframes2, name, motionValue: motionValue2, element, ...options }) {
2203
+ super();
2204
+ this.stop = () => {
2205
+ if (this._animation) {
2206
+ this._animation.stop();
2207
+ this.stopTimeline?.();
2208
+ }
2209
+ this.keyframeResolver?.cancel();
2210
+ };
2211
+ this.createdAt = time.now();
2212
+ const optionsWithDefaults = {
2213
+ autoplay,
2214
+ delay,
2215
+ type,
2216
+ repeat,
2217
+ repeatDelay,
2218
+ repeatType,
2219
+ name,
2220
+ motionValue: motionValue2,
2221
+ element,
2222
+ ...options
2223
+ };
2224
+ const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
2225
+ this.keyframeResolver = new KeyframeResolver$1(keyframes2, (resolvedKeyframes, finalKeyframe, forced) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe, optionsWithDefaults, !forced), name, motionValue2, element);
2226
+ this.keyframeResolver?.scheduleResolve();
2227
+ }
2228
+ onKeyframesResolved(keyframes2, finalKeyframe, options, sync) {
2229
+ this.keyframeResolver = void 0;
2230
+ const { name, type, velocity, delay, isHandoff, onUpdate } = options;
2231
+ this.resolvedAt = time.now();
2232
+ if (!canAnimate(keyframes2, name, type, velocity)) {
2233
+ if (MotionGlobalConfig.instantAnimations || !delay) {
2234
+ onUpdate?.(getFinalKeyframe(keyframes2, options, finalKeyframe));
2235
+ }
2236
+ keyframes2[0] = keyframes2[keyframes2.length - 1];
2237
+ makeAnimationInstant(options);
2238
+ options.repeat = 0;
2239
+ }
2240
+ const startTime = sync ? !this.resolvedAt ? this.createdAt : this.resolvedAt - this.createdAt > MAX_RESOLVE_DELAY ? this.resolvedAt : this.createdAt : void 0;
2241
+ const resolvedOptions = {
2242
+ startTime,
2243
+ finalKeyframe,
2244
+ ...options,
2245
+ keyframes: keyframes2
2246
+ };
2247
+ const useWaapi = !isHandoff && supportsBrowserAnimation(resolvedOptions);
2248
+ const element = resolvedOptions.motionValue?.owner?.current;
2249
+ const animation = useWaapi ? new NativeAnimationExtended({
2250
+ ...resolvedOptions,
2251
+ element
2252
+ }) : new JSAnimation(resolvedOptions);
2253
+ animation.finished.then(() => {
2254
+ this.notifyFinished();
2255
+ }).catch(noop);
2256
+ if (this.pendingTimeline) {
2257
+ this.stopTimeline = animation.attachTimeline(this.pendingTimeline);
2258
+ this.pendingTimeline = void 0;
2259
+ }
2260
+ this._animation = animation;
2261
+ }
2262
+ get finished() {
2263
+ if (!this._animation) {
2264
+ return this._finished;
2265
+ } else {
2266
+ return this.animation.finished;
2267
+ }
2268
+ }
2269
+ then(onResolve, _onReject) {
2270
+ return this.finished.finally(onResolve).then(() => {
2271
+ });
2272
+ }
2273
+ get animation() {
2274
+ if (!this._animation) {
2275
+ this.keyframeResolver?.resume();
2276
+ flushKeyframeResolvers();
2277
+ }
2278
+ return this._animation;
2279
+ }
2280
+ get duration() {
2281
+ return this.animation.duration;
2282
+ }
2283
+ get iterationDuration() {
2284
+ return this.animation.iterationDuration;
2285
+ }
2286
+ get time() {
2287
+ return this.animation.time;
2288
+ }
2289
+ set time(newTime) {
2290
+ this.animation.time = newTime;
2291
+ }
2292
+ get speed() {
2293
+ return this.animation.speed;
2294
+ }
2295
+ get state() {
2296
+ return this.animation.state;
2297
+ }
2298
+ set speed(newSpeed) {
2299
+ this.animation.speed = newSpeed;
2300
+ }
2301
+ get startTime() {
2302
+ return this.animation.startTime;
2303
+ }
2304
+ attachTimeline(timeline) {
2305
+ if (this._animation) {
2306
+ this.stopTimeline = this.animation.attachTimeline(timeline);
2307
+ } else {
2308
+ this.pendingTimeline = timeline;
2309
+ }
2310
+ return () => this.stop();
2311
+ }
2312
+ play() {
2313
+ this.animation.play();
2314
+ }
2315
+ pause() {
2316
+ this.animation.pause();
2317
+ }
2318
+ complete() {
2319
+ this.animation.complete();
2320
+ }
2321
+ cancel() {
2322
+ if (this._animation) {
2323
+ this.animation.cancel();
2324
+ }
2325
+ this.keyframeResolver?.cancel();
2326
+ }
2327
+ };
2328
+
2329
+ // node_modules/motion-dom/dist/es/animation/utils/calc-child-stagger.mjs
2330
+ function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
2331
+ const index = Array.from(children).sort((a, b) => a.sortNodePosition(b)).indexOf(child);
2332
+ const numChildren = children.size;
2333
+ const maxStaggerDuration = (numChildren - 1) * staggerChildren;
2334
+ const delayIsFunction = typeof delayChildren === "function";
2335
+ return delayIsFunction ? delayChildren(index, numChildren) : staggerDirection === 1 ? index * staggerChildren : maxStaggerDuration - index * staggerChildren;
2336
+ }
2337
+
2338
+ // node_modules/motion-dom/dist/es/animation/utils/default-transitions.mjs
2339
+ var underDampedSpring = {
2340
+ type: "spring",
2341
+ stiffness: 500,
2342
+ damping: 25,
2343
+ restSpeed: 10
2344
+ };
2345
+ var criticallyDampedSpring = (target) => ({
2346
+ type: "spring",
2347
+ stiffness: 550,
2348
+ damping: target === 0 ? 2 * Math.sqrt(550) : 30,
2349
+ restSpeed: 10
2350
+ });
2351
+ var keyframesTransition = {
2352
+ type: "keyframes",
2353
+ duration: 0.8
2354
+ };
2355
+ var ease = {
2356
+ type: "keyframes",
2357
+ ease: [0.25, 0.1, 0.35, 1],
2358
+ duration: 0.3
2359
+ };
2360
+ var getDefaultTransition = (valueKey, { keyframes: keyframes2 }) => {
2361
+ if (keyframes2.length > 2) {
2362
+ return keyframesTransition;
2363
+ } else if (transformProps.has(valueKey)) {
2364
+ return valueKey.startsWith("scale") ? criticallyDampedSpring(keyframes2[1]) : underDampedSpring;
2365
+ }
2366
+ return ease;
2367
+ };
2368
+
2369
+ // node_modules/motion-dom/dist/es/animation/utils/get-final-keyframe.mjs
2370
+ var isNotNull2 = (value) => value !== null;
2371
+ function getFinalKeyframe2(keyframes2, { repeat, repeatType = "loop" }, finalKeyframe) {
2372
+ const resolvedKeyframes = keyframes2.filter(isNotNull2);
2373
+ const index = repeat && repeatType !== "loop" && repeat % 2 === 1 ? 0 : resolvedKeyframes.length - 1;
2374
+ return !index || finalKeyframe === void 0 ? resolvedKeyframes[index] : finalKeyframe;
2375
+ }
2376
+
2377
+ // node_modules/motion-dom/dist/es/animation/utils/get-value-transition.mjs
2378
+ function getValueTransition(transition, key) {
2379
+ return transition?.[key] ?? transition?.["default"] ?? transition;
2380
+ }
2381
+
2382
+ // node_modules/motion-dom/dist/es/animation/utils/is-transition-defined.mjs
2383
+ function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
2384
+ return !!Object.keys(transition).length;
2385
+ }
2386
+
2387
+ // node_modules/motion-dom/dist/es/animation/interfaces/motion-value.mjs
2388
+ var animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
2389
+ const valueTransition = getValueTransition(transition, name) || {};
2390
+ const delay = valueTransition.delay || transition.delay || 0;
2391
+ let { elapsed = 0 } = transition;
2392
+ elapsed = elapsed - secondsToMilliseconds(delay);
2393
+ const options = {
2394
+ keyframes: Array.isArray(target) ? target : [null, target],
2395
+ ease: "easeOut",
2396
+ velocity: value.getVelocity(),
2397
+ ...valueTransition,
2398
+ delay: -elapsed,
2399
+ onUpdate: (v) => {
2400
+ value.set(v);
2401
+ valueTransition.onUpdate && valueTransition.onUpdate(v);
2402
+ },
2403
+ onComplete: () => {
2404
+ onComplete();
2405
+ valueTransition.onComplete && valueTransition.onComplete();
2406
+ },
2407
+ name,
2408
+ motionValue: value,
2409
+ element: isHandoff ? void 0 : element
2410
+ };
2411
+ if (!isTransitionDefined(valueTransition)) {
2412
+ Object.assign(options, getDefaultTransition(name, options));
2413
+ }
2414
+ options.duration && (options.duration = secondsToMilliseconds(options.duration));
2415
+ options.repeatDelay && (options.repeatDelay = secondsToMilliseconds(options.repeatDelay));
2416
+ if (options.from !== void 0) {
2417
+ options.keyframes[0] = options.from;
2418
+ }
2419
+ let shouldSkip = false;
2420
+ if (options.type === false || options.duration === 0 && !options.repeatDelay) {
2421
+ makeAnimationInstant(options);
2422
+ if (options.delay === 0) {
2423
+ shouldSkip = true;
2424
+ }
2425
+ }
2426
+ if (MotionGlobalConfig.instantAnimations || MotionGlobalConfig.skipAnimations) {
2427
+ shouldSkip = true;
2428
+ makeAnimationInstant(options);
2429
+ options.delay = 0;
2430
+ }
2431
+ options.allowFlatten = !valueTransition.type && !valueTransition.ease;
2432
+ if (shouldSkip && !isHandoff && value.get() !== void 0) {
2433
+ const finalKeyframe = getFinalKeyframe2(options.keyframes, valueTransition);
2434
+ if (finalKeyframe !== void 0) {
2435
+ frame.update(() => {
2436
+ options.onUpdate(finalKeyframe);
2437
+ options.onComplete();
2438
+ });
2439
+ return;
2440
+ }
2441
+ }
2442
+ return valueTransition.isSync ? new JSAnimation(options) : new AsyncMotionValueAnimation(options);
2443
+ };
2444
+
2445
+ // node_modules/motion-dom/dist/es/render/utils/resolve-variants.mjs
2446
+ function getValueState(visualElement) {
2447
+ const state = [{}, {}];
2448
+ visualElement?.values.forEach((value, key) => {
2449
+ state[0][key] = value.get();
2450
+ state[1][key] = value.getVelocity();
2451
+ });
2452
+ return state;
2453
+ }
2454
+ function resolveVariantFromProps(props, definition, custom, visualElement) {
2455
+ if (typeof definition === "function") {
2456
+ const [current, velocity] = getValueState(visualElement);
2457
+ definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
2458
+ }
2459
+ if (typeof definition === "string") {
2460
+ definition = props.variants && props.variants[definition];
2461
+ }
2462
+ if (typeof definition === "function") {
2463
+ const [current, velocity] = getValueState(visualElement);
2464
+ definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
2465
+ }
2466
+ return definition;
2467
+ }
2468
+
2469
+ // node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.mjs
2470
+ function resolveVariant(visualElement, definition, custom) {
2471
+ const props = visualElement.getProps();
2472
+ return resolveVariantFromProps(props, definition, custom !== void 0 ? custom : props.custom, visualElement);
2473
+ }
2474
+
2475
+ // node_modules/motion-dom/dist/es/render/utils/keys-position.mjs
2476
+ var positionalKeys = /* @__PURE__ */ new Set([
2477
+ "width",
2478
+ "height",
2479
+ "top",
2480
+ "left",
2481
+ "right",
2482
+ "bottom",
2483
+ ...transformPropOrder
2484
+ ]);
2485
+
2486
+ // node_modules/motion-dom/dist/es/value/index.mjs
2487
+ var MAX_VELOCITY_DELTA = 30;
2488
+ var isFloat = (value) => {
2489
+ return !isNaN(parseFloat(value));
2490
+ };
2491
+ var collectMotionValues = {
2492
+ current: void 0
2493
+ };
2494
+ var MotionValue = class {
2495
+ /**
2496
+ * @param init - The initiating value
2497
+ * @param config - Optional configuration options
2498
+ *
2499
+ * - `transformer`: A function to transform incoming values with.
2500
+ */
2501
+ constructor(init, options = {}) {
2502
+ this.canTrackVelocity = null;
2503
+ this.events = {};
2504
+ this.updateAndNotify = (v) => {
2505
+ const currentTime = time.now();
2506
+ if (this.updatedAt !== currentTime) {
2507
+ this.setPrevFrameValue();
2508
+ }
2509
+ this.prev = this.current;
2510
+ this.setCurrent(v);
2511
+ if (this.current !== this.prev) {
2512
+ this.events.change?.notify(this.current);
2513
+ if (this.dependents) {
2514
+ for (const dependent of this.dependents) {
2515
+ dependent.dirty();
2516
+ }
2517
+ }
2518
+ }
2519
+ };
2520
+ this.hasAnimated = false;
2521
+ this.setCurrent(init);
2522
+ this.owner = options.owner;
2523
+ }
2524
+ setCurrent(current) {
2525
+ this.current = current;
2526
+ this.updatedAt = time.now();
2527
+ if (this.canTrackVelocity === null && current !== void 0) {
2528
+ this.canTrackVelocity = isFloat(this.current);
2529
+ }
2530
+ }
2531
+ setPrevFrameValue(prevFrameValue = this.current) {
2532
+ this.prevFrameValue = prevFrameValue;
2533
+ this.prevUpdatedAt = this.updatedAt;
2534
+ }
2535
+ /**
2536
+ * Adds a function that will be notified when the `MotionValue` is updated.
2537
+ *
2538
+ * It returns a function that, when called, will cancel the subscription.
2539
+ *
2540
+ * When calling `onChange` inside a React component, it should be wrapped with the
2541
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
2542
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
2543
+ *
2544
+ * ```jsx
2545
+ * export const MyComponent = () => {
2546
+ * const x = useMotionValue(0)
2547
+ * const y = useMotionValue(0)
2548
+ * const opacity = useMotionValue(1)
2549
+ *
2550
+ * useEffect(() => {
2551
+ * function updateOpacity() {
2552
+ * const maxXY = Math.max(x.get(), y.get())
2553
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
2554
+ * opacity.set(newOpacity)
2555
+ * }
2556
+ *
2557
+ * const unsubscribeX = x.on("change", updateOpacity)
2558
+ * const unsubscribeY = y.on("change", updateOpacity)
2559
+ *
2560
+ * return () => {
2561
+ * unsubscribeX()
2562
+ * unsubscribeY()
2563
+ * }
2564
+ * }, [])
2565
+ *
2566
+ * return <motion.div style={{ x }} />
2567
+ * }
2568
+ * ```
2569
+ *
2570
+ * @param subscriber - A function that receives the latest value.
2571
+ * @returns A function that, when called, will cancel this subscription.
2572
+ *
2573
+ * @deprecated
2574
+ */
2575
+ onChange(subscription) {
2576
+ if (process.env.NODE_ENV !== "production") {
2577
+ warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on("change", callback).`);
2578
+ }
2579
+ return this.on("change", subscription);
2580
+ }
2581
+ on(eventName, callback) {
2582
+ if (!this.events[eventName]) {
2583
+ this.events[eventName] = new SubscriptionManager();
2584
+ }
2585
+ const unsubscribe = this.events[eventName].add(callback);
2586
+ if (eventName === "change") {
2587
+ return () => {
2588
+ unsubscribe();
2589
+ frame.read(() => {
2590
+ if (!this.events.change.getSize()) {
2591
+ this.stop();
2592
+ }
2593
+ });
2594
+ };
2595
+ }
2596
+ return unsubscribe;
2597
+ }
2598
+ clearListeners() {
2599
+ for (const eventManagers in this.events) {
2600
+ this.events[eventManagers].clear();
2601
+ }
2602
+ }
2603
+ /**
2604
+ * Attaches a passive effect to the `MotionValue`.
2605
+ */
2606
+ attach(passiveEffect, stopPassiveEffect) {
2607
+ this.passiveEffect = passiveEffect;
2608
+ this.stopPassiveEffect = stopPassiveEffect;
2609
+ }
2610
+ /**
2611
+ * Sets the state of the `MotionValue`.
2612
+ *
2613
+ * @remarks
2614
+ *
2615
+ * ```jsx
2616
+ * const x = useMotionValue(0)
2617
+ * x.set(10)
2618
+ * ```
2619
+ *
2620
+ * @param latest - Latest value to set.
2621
+ * @param render - Whether to notify render subscribers. Defaults to `true`
2622
+ *
2623
+ * @public
2624
+ */
2625
+ set(v) {
2626
+ if (!this.passiveEffect) {
2627
+ this.updateAndNotify(v);
2628
+ } else {
2629
+ this.passiveEffect(v, this.updateAndNotify);
2630
+ }
2631
+ }
2632
+ setWithVelocity(prev, current, delta) {
2633
+ this.set(current);
2634
+ this.prev = void 0;
2635
+ this.prevFrameValue = prev;
2636
+ this.prevUpdatedAt = this.updatedAt - delta;
2637
+ }
2638
+ /**
2639
+ * Set the state of the `MotionValue`, stopping any active animations,
2640
+ * effects, and resets velocity to `0`.
2641
+ */
2642
+ jump(v, endAnimation = true) {
2643
+ this.updateAndNotify(v);
2644
+ this.prev = v;
2645
+ this.prevUpdatedAt = this.prevFrameValue = void 0;
2646
+ endAnimation && this.stop();
2647
+ if (this.stopPassiveEffect)
2648
+ this.stopPassiveEffect();
2649
+ }
2650
+ dirty() {
2651
+ this.events.change?.notify(this.current);
2652
+ }
2653
+ addDependent(dependent) {
2654
+ if (!this.dependents) {
2655
+ this.dependents = /* @__PURE__ */ new Set();
2656
+ }
2657
+ this.dependents.add(dependent);
2658
+ }
2659
+ removeDependent(dependent) {
2660
+ if (this.dependents) {
2661
+ this.dependents.delete(dependent);
2662
+ }
2663
+ }
2664
+ /**
2665
+ * Returns the latest state of `MotionValue`
2666
+ *
2667
+ * @returns - The latest state of `MotionValue`
2668
+ *
2669
+ * @public
2670
+ */
2671
+ get() {
2672
+ if (collectMotionValues.current) {
2673
+ collectMotionValues.current.push(this);
2674
+ }
2675
+ return this.current;
2676
+ }
2677
+ /**
2678
+ * @public
2679
+ */
2680
+ getPrevious() {
2681
+ return this.prev;
2682
+ }
2683
+ /**
2684
+ * Returns the latest velocity of `MotionValue`
2685
+ *
2686
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
2687
+ *
2688
+ * @public
2689
+ */
2690
+ getVelocity() {
2691
+ const currentTime = time.now();
2692
+ if (!this.canTrackVelocity || this.prevFrameValue === void 0 || currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {
2693
+ return 0;
2694
+ }
2695
+ const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);
2696
+ return velocityPerSecond(parseFloat(this.current) - parseFloat(this.prevFrameValue), delta);
2697
+ }
2698
+ /**
2699
+ * Registers a new animation to control this `MotionValue`. Only one
2700
+ * animation can drive a `MotionValue` at one time.
2701
+ *
2702
+ * ```jsx
2703
+ * value.start()
2704
+ * ```
2705
+ *
2706
+ * @param animation - A function that starts the provided animation
2707
+ */
2708
+ start(startAnimation) {
2709
+ this.stop();
2710
+ return new Promise((resolve) => {
2711
+ this.hasAnimated = true;
2712
+ this.animation = startAnimation(resolve);
2713
+ if (this.events.animationStart) {
2714
+ this.events.animationStart.notify();
2715
+ }
2716
+ }).then(() => {
2717
+ if (this.events.animationComplete) {
2718
+ this.events.animationComplete.notify();
2719
+ }
2720
+ this.clearAnimation();
2721
+ });
2722
+ }
2723
+ /**
2724
+ * Stop the currently active animation.
2725
+ *
2726
+ * @public
2727
+ */
2728
+ stop() {
2729
+ if (this.animation) {
2730
+ this.animation.stop();
2731
+ if (this.events.animationCancel) {
2732
+ this.events.animationCancel.notify();
2733
+ }
2734
+ }
2735
+ this.clearAnimation();
2736
+ }
2737
+ /**
2738
+ * Returns `true` if this value is currently animating.
2739
+ *
2740
+ * @public
2741
+ */
2742
+ isAnimating() {
2743
+ return !!this.animation;
2744
+ }
2745
+ clearAnimation() {
2746
+ delete this.animation;
2747
+ }
2748
+ /**
2749
+ * Destroy and clean up subscribers to this `MotionValue`.
2750
+ *
2751
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
2752
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
2753
+ * created a `MotionValue` via the `motionValue` function.
2754
+ *
2755
+ * @public
2756
+ */
2757
+ destroy() {
2758
+ this.dependents?.clear();
2759
+ this.events.destroy?.notify();
2760
+ this.clearListeners();
2761
+ this.stop();
2762
+ if (this.stopPassiveEffect) {
2763
+ this.stopPassiveEffect();
2764
+ }
2765
+ }
2766
+ };
2767
+ function motionValue(init, options) {
2768
+ return new MotionValue(init, options);
2769
+ }
2770
+
2771
+ // node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.mjs
2772
+ var isKeyframesTarget = (v) => {
2773
+ return Array.isArray(v);
2774
+ };
2775
+
2776
+ // node_modules/motion-dom/dist/es/render/utils/setters.mjs
2777
+ function setMotionValue(visualElement, key, value) {
2778
+ if (visualElement.hasValue(key)) {
2779
+ visualElement.getValue(key).set(value);
2780
+ } else {
2781
+ visualElement.addValue(key, motionValue(value));
2782
+ }
2783
+ }
2784
+ function resolveFinalValueInKeyframes(v) {
2785
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
2786
+ }
2787
+ function setTarget(visualElement, definition) {
2788
+ const resolved = resolveVariant(visualElement, definition);
2789
+ let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
2790
+ target = { ...target, ...transitionEnd };
2791
+ for (const key in target) {
2792
+ const value = resolveFinalValueInKeyframes(target[key]);
2793
+ setMotionValue(visualElement, key, value);
2794
+ }
2795
+ }
2796
+
2797
+ // node_modules/motion-dom/dist/es/value/utils/is-motion-value.mjs
2798
+ var isMotionValue = (value) => Boolean(value && value.getVelocity);
2799
+
2800
+ // node_modules/motion-dom/dist/es/value/will-change/is.mjs
2801
+ function isWillChangeMotionValue(value) {
2802
+ return Boolean(isMotionValue(value) && value.add);
2803
+ }
2804
+
2805
+ // node_modules/motion-dom/dist/es/value/will-change/add-will-change.mjs
2806
+ function addValueToWillChange(visualElement, key) {
2807
+ const willChange = visualElement.getValue("willChange");
2808
+ if (isWillChangeMotionValue(willChange)) {
2809
+ return willChange.add(key);
2810
+ } else if (!willChange && MotionGlobalConfig.WillChange) {
2811
+ const newWillChange = new MotionGlobalConfig.WillChange("auto");
2812
+ visualElement.addValue("willChange", newWillChange);
2813
+ newWillChange.add(key);
2814
+ }
2815
+ }
2816
+
2817
+ // node_modules/motion-dom/dist/es/render/dom/utils/camel-to-dash.mjs
2818
+ function camelToDash(str) {
2819
+ return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
2820
+ }
2821
+
2822
+ // node_modules/motion-dom/dist/es/animation/optimized-appear/data-id.mjs
2823
+ var optimizedAppearDataId = "framerAppearId";
2824
+ var optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
2825
+
2826
+ // node_modules/motion-dom/dist/es/animation/optimized-appear/get-appear-id.mjs
2827
+ function getOptimisedAppearId(visualElement) {
2828
+ return visualElement.props[optimizedAppearDataAttribute];
2829
+ }
2830
+
2831
+ // node_modules/motion-dom/dist/es/animation/interfaces/visual-element-target.mjs
2832
+ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
2833
+ const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
2834
+ needsAnimating[key] = false;
2835
+ return shouldBlock;
2836
+ }
2837
+ function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
2838
+ let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
2839
+ const reduceMotion = transition?.reduceMotion;
2840
+ if (transitionOverride)
2841
+ transition = transitionOverride;
2842
+ const animations = [];
2843
+ const animationTypeState = type && visualElement.animationState && visualElement.animationState.getState()[type];
2844
+ for (const key in target) {
2845
+ const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
2846
+ const valueTarget = target[key];
2847
+ if (valueTarget === void 0 || animationTypeState && shouldBlockAnimation(animationTypeState, key)) {
2848
+ continue;
2849
+ }
2850
+ const valueTransition = {
2851
+ delay,
2852
+ ...getValueTransition(transition || {}, key)
2853
+ };
2854
+ const currentValue = value.get();
2855
+ if (currentValue !== void 0 && !value.isAnimating && !Array.isArray(valueTarget) && valueTarget === currentValue && !valueTransition.velocity) {
2856
+ continue;
2857
+ }
2858
+ let isHandoff = false;
2859
+ if (window.MotionHandoffAnimation) {
2860
+ const appearId = getOptimisedAppearId(visualElement);
2861
+ if (appearId) {
2862
+ const startTime = window.MotionHandoffAnimation(appearId, key, frame);
2863
+ if (startTime !== null) {
2864
+ valueTransition.startTime = startTime;
2865
+ isHandoff = true;
2866
+ }
2867
+ }
2868
+ }
2869
+ addValueToWillChange(visualElement, key);
2870
+ const shouldReduceMotion = reduceMotion ?? visualElement.shouldReduceMotion;
2871
+ value.start(animateMotionValue(key, value, valueTarget, shouldReduceMotion && positionalKeys.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
2872
+ const animation = value.animation;
2873
+ if (animation) {
2874
+ animations.push(animation);
2875
+ }
2876
+ }
2877
+ if (transitionEnd) {
2878
+ Promise.all(animations).then(() => {
2879
+ frame.update(() => {
2880
+ transitionEnd && setTarget(visualElement, transitionEnd);
2881
+ });
2882
+ });
2883
+ }
2884
+ return animations;
2885
+ }
2886
+
2887
+ // node_modules/motion-dom/dist/es/animation/interfaces/visual-element-variant.mjs
2888
+ function animateVariant(visualElement, variant, options = {}) {
2889
+ const resolved = resolveVariant(visualElement, variant, options.type === "exit" ? visualElement.presenceContext?.custom : void 0);
2890
+ let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
2891
+ if (options.transitionOverride) {
2892
+ transition = options.transitionOverride;
2893
+ }
2894
+ const getAnimation = resolved ? () => Promise.all(animateTarget(visualElement, resolved, options)) : () => Promise.resolve();
2895
+ const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size ? (forwardDelay = 0) => {
2896
+ const { delayChildren = 0, staggerChildren, staggerDirection } = transition;
2897
+ return animateChildren(visualElement, variant, forwardDelay, delayChildren, staggerChildren, staggerDirection, options);
2898
+ } : () => Promise.resolve();
2899
+ const { when } = transition;
2900
+ if (when) {
2901
+ const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
2902
+ return first().then(() => last());
2903
+ } else {
2904
+ return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
2905
+ }
2906
+ }
2907
+ function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
2908
+ const animations = [];
2909
+ for (const child of visualElement.variantChildren) {
2910
+ child.notify("AnimationStart", variant);
2911
+ animations.push(animateVariant(child, variant, {
2912
+ ...options,
2913
+ delay: delay + (typeof delayChildren === "function" ? 0 : delayChildren) + calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection)
2914
+ }).then(() => child.notify("AnimationComplete", variant)));
2915
+ }
2916
+ return Promise.all(animations);
2917
+ }
2918
+
2919
+ // node_modules/motion-dom/dist/es/animation/interfaces/visual-element.mjs
2920
+ function animateVisualElement(visualElement, definition, options = {}) {
2921
+ visualElement.notify("AnimationStart", definition);
2922
+ let animation;
2923
+ if (Array.isArray(definition)) {
2924
+ const animations = definition.map((variant) => animateVariant(visualElement, variant, options));
2925
+ animation = Promise.all(animations);
2926
+ } else if (typeof definition === "string") {
2927
+ animation = animateVariant(visualElement, definition, options);
2928
+ } else {
2929
+ const resolvedDefinition = typeof definition === "function" ? resolveVariant(visualElement, definition, options.custom) : definition;
2930
+ animation = Promise.all(animateTarget(visualElement, resolvedDefinition, options));
2931
+ }
2932
+ return animation.then(() => {
2933
+ visualElement.notify("AnimationComplete", definition);
2934
+ });
2935
+ }
2936
+
2937
+ // node_modules/motion-dom/dist/es/utils/resolve-elements.mjs
2938
+ function resolveElements(elementOrSelector, scope, selectorCache) {
2939
+ if (elementOrSelector == null) {
2940
+ return [];
2941
+ }
2942
+ if (elementOrSelector instanceof EventTarget) {
2943
+ return [elementOrSelector];
2944
+ } else if (typeof elementOrSelector === "string") {
2945
+ let root = document;
2946
+ if (scope) {
2947
+ root = scope.current;
2948
+ }
2949
+ const elements = selectorCache?.[elementOrSelector] ?? root.querySelectorAll(elementOrSelector);
2950
+ return elements ? Array.from(elements) : [];
2951
+ }
2952
+ return Array.from(elementOrSelector).filter((element) => element != null);
2953
+ }
2954
+
2955
+ // node_modules/motion-dom/dist/es/utils/is-html-element.mjs
2956
+ function isHTMLElement(element) {
2957
+ return isObject(element) && "offsetHeight" in element;
2958
+ }
2959
+
2960
+ // node_modules/motion-dom/dist/es/utils/is-svg-element.mjs
2961
+ function isSVGElement(element) {
2962
+ return isObject(element) && "ownerSVGElement" in element;
2963
+ }
2964
+
2965
+ // node_modules/motion-dom/dist/es/resize/handle-element.mjs
2966
+ var resizeHandlers = /* @__PURE__ */ new WeakMap();
2967
+ var observer;
2968
+ var getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
2969
+ if (borderBoxSize && borderBoxSize[0]) {
2970
+ return borderBoxSize[0][borderBoxAxis + "Size"];
2971
+ } else if (isSVGElement(target) && "getBBox" in target) {
2972
+ return target.getBBox()[svgAxis];
2973
+ } else {
2974
+ return target[htmlAxis];
2975
+ }
2976
+ };
2977
+ var getWidth = /* @__PURE__ */ getSize("inline", "width", "offsetWidth");
2978
+ var getHeight = /* @__PURE__ */ getSize("block", "height", "offsetHeight");
2979
+ function notifyTarget({ target, borderBoxSize }) {
2980
+ resizeHandlers.get(target)?.forEach((handler) => {
2981
+ handler(target, {
2982
+ get width() {
2983
+ return getWidth(target, borderBoxSize);
2984
+ },
2985
+ get height() {
2986
+ return getHeight(target, borderBoxSize);
2987
+ }
2988
+ });
2989
+ });
2990
+ }
2991
+ function notifyAll(entries) {
2992
+ entries.forEach(notifyTarget);
2993
+ }
2994
+ function createResizeObserver() {
2995
+ if (typeof ResizeObserver === "undefined")
2996
+ return;
2997
+ observer = new ResizeObserver(notifyAll);
2998
+ }
2999
+ function resizeElement(target, handler) {
3000
+ if (!observer)
3001
+ createResizeObserver();
3002
+ const elements = resolveElements(target);
3003
+ elements.forEach((element) => {
3004
+ let elementHandlers = resizeHandlers.get(element);
3005
+ if (!elementHandlers) {
3006
+ elementHandlers = /* @__PURE__ */ new Set();
3007
+ resizeHandlers.set(element, elementHandlers);
3008
+ }
3009
+ elementHandlers.add(handler);
3010
+ observer?.observe(element);
3011
+ });
3012
+ return () => {
3013
+ elements.forEach((element) => {
3014
+ const elementHandlers = resizeHandlers.get(element);
3015
+ elementHandlers?.delete(handler);
3016
+ if (!elementHandlers?.size) {
3017
+ observer?.unobserve(element);
3018
+ }
3019
+ });
3020
+ };
3021
+ }
3022
+
3023
+ // node_modules/motion-dom/dist/es/resize/handle-window.mjs
3024
+ var windowCallbacks = /* @__PURE__ */ new Set();
3025
+ var windowResizeHandler;
3026
+ function createWindowResizeHandler() {
3027
+ windowResizeHandler = () => {
3028
+ const info = {
3029
+ get width() {
3030
+ return window.innerWidth;
3031
+ },
3032
+ get height() {
3033
+ return window.innerHeight;
3034
+ }
3035
+ };
3036
+ windowCallbacks.forEach((callback) => callback(info));
3037
+ };
3038
+ window.addEventListener("resize", windowResizeHandler);
3039
+ }
3040
+ function resizeWindow(callback) {
3041
+ windowCallbacks.add(callback);
3042
+ if (!windowResizeHandler)
3043
+ createWindowResizeHandler();
3044
+ return () => {
3045
+ windowCallbacks.delete(callback);
3046
+ if (!windowCallbacks.size && typeof windowResizeHandler === "function") {
3047
+ window.removeEventListener("resize", windowResizeHandler);
3048
+ windowResizeHandler = void 0;
3049
+ }
3050
+ };
3051
+ }
3052
+
3053
+ // node_modules/motion-dom/dist/es/resize/index.mjs
3054
+ function resize(a, b) {
3055
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
3056
+ }
3057
+
3058
+ // node_modules/motion-dom/dist/es/scroll/observe.mjs
3059
+ function observeTimeline(update, timeline) {
3060
+ let prevProgress;
3061
+ const onFrame = () => {
3062
+ const { currentTime } = timeline;
3063
+ const percentage = currentTime === null ? 0 : currentTime.value;
3064
+ const progress2 = percentage / 100;
3065
+ if (prevProgress !== progress2) {
3066
+ update(progress2);
3067
+ }
3068
+ prevProgress = progress2;
3069
+ };
3070
+ frame.preUpdate(onFrame, true);
3071
+ return () => cancelFrame(onFrame);
3072
+ }
3073
+
3074
+ // node_modules/motion-dom/dist/es/utils/transform.mjs
3075
+ function transform(...args) {
3076
+ const useImmediate = !Array.isArray(args[0]);
3077
+ const argOffset = useImmediate ? 0 : -1;
3078
+ const inputValue = args[0 + argOffset];
3079
+ const inputRange = args[1 + argOffset];
3080
+ const outputRange = args[2 + argOffset];
3081
+ const options = args[3 + argOffset];
3082
+ const interpolator = interpolate(inputRange, outputRange, options);
3083
+ return useImmediate ? interpolator(inputValue) : interpolator;
3084
+ }
3085
+
3086
+ // node_modules/motion-dom/dist/es/value/follow-value.mjs
3087
+ function attachFollow(value, source, options = {}) {
3088
+ const initialValue = value.get();
3089
+ let activeAnimation = null;
3090
+ let latestValue = initialValue;
3091
+ let latestSetter;
3092
+ const unit = typeof initialValue === "string" ? initialValue.replace(/[\d.-]/g, "") : void 0;
3093
+ const stopAnimation2 = () => {
3094
+ if (activeAnimation) {
3095
+ activeAnimation.stop();
3096
+ activeAnimation = null;
3097
+ }
3098
+ };
3099
+ const startAnimation = () => {
3100
+ stopAnimation2();
3101
+ const currentValue = asNumber(value.get());
3102
+ const targetValue = asNumber(latestValue);
3103
+ if (currentValue === targetValue) {
3104
+ return;
3105
+ }
3106
+ activeAnimation = new JSAnimation({
3107
+ keyframes: [currentValue, targetValue],
3108
+ velocity: value.getVelocity(),
3109
+ // Default to spring if no type specified (matches useSpring behavior)
3110
+ type: "spring",
3111
+ restDelta: 1e-3,
3112
+ restSpeed: 0.01,
3113
+ ...options,
3114
+ onUpdate: latestSetter
3115
+ });
3116
+ };
3117
+ value.attach((v, set) => {
3118
+ latestValue = v;
3119
+ latestSetter = (latest) => set(parseValue(latest, unit));
3120
+ frame.postRender(() => {
3121
+ startAnimation();
3122
+ value["events"].animationStart?.notify();
3123
+ activeAnimation?.then(() => {
3124
+ value["events"].animationComplete?.notify();
3125
+ });
3126
+ });
3127
+ }, stopAnimation2);
3128
+ if (isMotionValue(source)) {
3129
+ const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
3130
+ const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
3131
+ return () => {
3132
+ removeSourceOnChange();
3133
+ removeValueOnDestroy();
3134
+ };
3135
+ }
3136
+ return stopAnimation2;
3137
+ }
3138
+ function parseValue(v, unit) {
3139
+ return unit ? v + unit : v;
3140
+ }
3141
+ function asNumber(v) {
3142
+ return typeof v === "number" ? v : parseFloat(v);
3143
+ }
3144
+
3145
+ // node_modules/framer-motion/dist/es/context/MotionConfigContext.mjs
3146
+ var import_react3 = require("react");
3147
+ var MotionConfigContext = (0, import_react3.createContext)({
3148
+ transformPagePoint: (p) => p,
3149
+ isStatic: false,
3150
+ reducedMotion: "never"
3151
+ });
3152
+
3153
+ // node_modules/framer-motion/dist/es/value/use-scroll.mjs
3154
+ var import_react4 = require("react");
3155
+
3156
+ // node_modules/framer-motion/dist/es/render/dom/scroll/info.mjs
3157
+ var maxElapsed2 = 50;
3158
+ var createAxisInfo = () => ({
3159
+ current: 0,
3160
+ offset: [],
3161
+ progress: 0,
3162
+ scrollLength: 0,
3163
+ targetOffset: 0,
3164
+ targetLength: 0,
3165
+ containerLength: 0,
3166
+ velocity: 0
3167
+ });
3168
+ var createScrollInfo = () => ({
3169
+ time: 0,
3170
+ x: createAxisInfo(),
3171
+ y: createAxisInfo()
3172
+ });
3173
+ var keys = {
3174
+ x: {
3175
+ length: "Width",
3176
+ position: "Left"
3177
+ },
3178
+ y: {
3179
+ length: "Height",
3180
+ position: "Top"
3181
+ }
3182
+ };
3183
+ function updateAxisInfo(element, axisName, info, time2) {
3184
+ const axis = info[axisName];
3185
+ const { length, position } = keys[axisName];
3186
+ const prev = axis.current;
3187
+ const prevTime = info.time;
3188
+ axis.current = element[`scroll${position}`];
3189
+ axis.scrollLength = element[`scroll${length}`] - element[`client${length}`];
3190
+ axis.offset.length = 0;
3191
+ axis.offset[0] = 0;
3192
+ axis.offset[1] = axis.scrollLength;
3193
+ axis.progress = progress(0, axis.scrollLength, axis.current);
3194
+ const elapsed = time2 - prevTime;
3195
+ axis.velocity = elapsed > maxElapsed2 ? 0 : velocityPerSecond(axis.current - prev, elapsed);
3196
+ }
3197
+ function updateScrollInfo(element, info, time2) {
3198
+ updateAxisInfo(element, "x", info, time2);
3199
+ updateAxisInfo(element, "y", info, time2);
3200
+ info.time = time2;
3201
+ }
3202
+
3203
+ // node_modules/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs
3204
+ function calcInset(element, container) {
3205
+ const inset = { x: 0, y: 0 };
3206
+ let current = element;
3207
+ while (current && current !== container) {
3208
+ if (isHTMLElement(current)) {
3209
+ inset.x += current.offsetLeft;
3210
+ inset.y += current.offsetTop;
3211
+ current = current.offsetParent;
3212
+ } else if (current.tagName === "svg") {
3213
+ const svgBoundingBox = current.getBoundingClientRect();
3214
+ current = current.parentElement;
3215
+ const parentBoundingBox = current.getBoundingClientRect();
3216
+ inset.x += svgBoundingBox.left - parentBoundingBox.left;
3217
+ inset.y += svgBoundingBox.top - parentBoundingBox.top;
3218
+ } else if (current instanceof SVGGraphicsElement) {
3219
+ const { x, y } = current.getBBox();
3220
+ inset.x += x;
3221
+ inset.y += y;
3222
+ let svg = null;
3223
+ let parent = current.parentNode;
3224
+ while (!svg) {
3225
+ if (parent.tagName === "svg") {
3226
+ svg = parent;
3227
+ }
3228
+ parent = current.parentNode;
3229
+ }
3230
+ current = svg;
3231
+ } else {
3232
+ break;
3233
+ }
3234
+ }
3235
+ return inset;
3236
+ }
3237
+
3238
+ // node_modules/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs
3239
+ var namedEdges = {
3240
+ start: 0,
3241
+ center: 0.5,
3242
+ end: 1
3243
+ };
3244
+ function resolveEdge(edge, length, inset = 0) {
3245
+ let delta = 0;
3246
+ if (edge in namedEdges) {
3247
+ edge = namedEdges[edge];
3248
+ }
3249
+ if (typeof edge === "string") {
3250
+ const asNumber2 = parseFloat(edge);
3251
+ if (edge.endsWith("px")) {
3252
+ delta = asNumber2;
3253
+ } else if (edge.endsWith("%")) {
3254
+ edge = asNumber2 / 100;
3255
+ } else if (edge.endsWith("vw")) {
3256
+ delta = asNumber2 / 100 * document.documentElement.clientWidth;
3257
+ } else if (edge.endsWith("vh")) {
3258
+ delta = asNumber2 / 100 * document.documentElement.clientHeight;
3259
+ } else {
3260
+ edge = asNumber2;
3261
+ }
3262
+ }
3263
+ if (typeof edge === "number") {
3264
+ delta = length * edge;
3265
+ }
3266
+ return inset + delta;
3267
+ }
3268
+
3269
+ // node_modules/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs
3270
+ var defaultOffset2 = [0, 0];
3271
+ function resolveOffset(offset, containerLength, targetLength, targetInset) {
3272
+ let offsetDefinition = Array.isArray(offset) ? offset : defaultOffset2;
3273
+ let targetPoint = 0;
3274
+ let containerPoint = 0;
3275
+ if (typeof offset === "number") {
3276
+ offsetDefinition = [offset, offset];
3277
+ } else if (typeof offset === "string") {
3278
+ offset = offset.trim();
3279
+ if (offset.includes(" ")) {
3280
+ offsetDefinition = offset.split(" ");
3281
+ } else {
3282
+ offsetDefinition = [offset, namedEdges[offset] ? offset : `0`];
3283
+ }
3284
+ }
3285
+ targetPoint = resolveEdge(offsetDefinition[0], targetLength, targetInset);
3286
+ containerPoint = resolveEdge(offsetDefinition[1], containerLength);
3287
+ return targetPoint - containerPoint;
3288
+ }
3289
+
3290
+ // node_modules/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs
3291
+ var ScrollOffset = {
3292
+ Enter: [
3293
+ [0, 1],
3294
+ [1, 1]
3295
+ ],
3296
+ Exit: [
3297
+ [0, 0],
3298
+ [1, 0]
3299
+ ],
3300
+ Any: [
3301
+ [1, 0],
3302
+ [0, 1]
3303
+ ],
3304
+ All: [
3305
+ [0, 0],
3306
+ [1, 1]
3307
+ ]
3308
+ };
3309
+
3310
+ // node_modules/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs
3311
+ var point = { x: 0, y: 0 };
3312
+ function getTargetSize(target) {
3313
+ return "getBBox" in target && target.tagName !== "svg" ? target.getBBox() : { width: target.clientWidth, height: target.clientHeight };
3314
+ }
3315
+ function resolveOffsets(container, info, options) {
3316
+ const { offset: offsetDefinition = ScrollOffset.All } = options;
3317
+ const { target = container, axis = "y" } = options;
3318
+ const lengthLabel = axis === "y" ? "height" : "width";
3319
+ const inset = target !== container ? calcInset(target, container) : point;
3320
+ const targetSize = target === container ? { width: container.scrollWidth, height: container.scrollHeight } : getTargetSize(target);
3321
+ const containerSize = {
3322
+ width: container.clientWidth,
3323
+ height: container.clientHeight
3324
+ };
3325
+ info[axis].offset.length = 0;
3326
+ let hasChanged = !info[axis].interpolate;
3327
+ const numOffsets = offsetDefinition.length;
3328
+ for (let i = 0; i < numOffsets; i++) {
3329
+ const offset = resolveOffset(offsetDefinition[i], containerSize[lengthLabel], targetSize[lengthLabel], inset[axis]);
3330
+ if (!hasChanged && offset !== info[axis].interpolatorOffsets[i]) {
3331
+ hasChanged = true;
3332
+ }
3333
+ info[axis].offset[i] = offset;
3334
+ }
3335
+ if (hasChanged) {
3336
+ info[axis].interpolate = interpolate(info[axis].offset, defaultOffset(offsetDefinition), { clamp: false });
3337
+ info[axis].interpolatorOffsets = [...info[axis].offset];
3338
+ }
3339
+ info[axis].progress = clamp(0, 1, info[axis].interpolate(info[axis].current));
3340
+ }
3341
+
3342
+ // node_modules/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs
3343
+ function measure(container, target = container, info) {
3344
+ info.x.targetOffset = 0;
3345
+ info.y.targetOffset = 0;
3346
+ if (target !== container) {
3347
+ let node = target;
3348
+ while (node && node !== container) {
3349
+ info.x.targetOffset += node.offsetLeft;
3350
+ info.y.targetOffset += node.offsetTop;
3351
+ node = node.offsetParent;
3352
+ }
3353
+ }
3354
+ info.x.targetLength = target === container ? target.scrollWidth : target.clientWidth;
3355
+ info.y.targetLength = target === container ? target.scrollHeight : target.clientHeight;
3356
+ info.x.containerLength = container.clientWidth;
3357
+ info.y.containerLength = container.clientHeight;
3358
+ if (process.env.NODE_ENV !== "production") {
3359
+ if (container && target && target !== container) {
3360
+ warnOnce(getComputedStyle(container).position !== "static", "Please ensure that the container has a non-static position, like 'relative', 'fixed', or 'absolute' to ensure scroll offset is calculated correctly.");
3361
+ }
3362
+ }
3363
+ }
3364
+ function createOnScrollHandler(element, onScroll, info, options = {}) {
3365
+ return {
3366
+ measure: (time2) => {
3367
+ measure(element, options.target, info);
3368
+ updateScrollInfo(element, info, time2);
3369
+ if (options.offset || options.target) {
3370
+ resolveOffsets(element, info, options);
3371
+ }
3372
+ },
3373
+ notify: () => onScroll(info)
3374
+ };
3375
+ }
3376
+
3377
+ // node_modules/framer-motion/dist/es/render/dom/scroll/track.mjs
3378
+ var scrollListeners = /* @__PURE__ */ new WeakMap();
3379
+ var resizeListeners = /* @__PURE__ */ new WeakMap();
3380
+ var onScrollHandlers = /* @__PURE__ */ new WeakMap();
3381
+ var scrollSize = /* @__PURE__ */ new WeakMap();
3382
+ var dimensionCheckProcesses = /* @__PURE__ */ new WeakMap();
3383
+ var getEventTarget = (element) => element === document.scrollingElement ? window : element;
3384
+ function scrollInfo(onScroll, { container = document.scrollingElement, trackContentSize = false, ...options } = {}) {
3385
+ if (!container)
3386
+ return noop;
3387
+ let containerHandlers = onScrollHandlers.get(container);
3388
+ if (!containerHandlers) {
3389
+ containerHandlers = /* @__PURE__ */ new Set();
3390
+ onScrollHandlers.set(container, containerHandlers);
3391
+ }
3392
+ const info = createScrollInfo();
3393
+ const containerHandler = createOnScrollHandler(container, onScroll, info, options);
3394
+ containerHandlers.add(containerHandler);
3395
+ if (!scrollListeners.has(container)) {
3396
+ const measureAll = () => {
3397
+ for (const handler of containerHandlers) {
3398
+ handler.measure(frameData.timestamp);
3399
+ }
3400
+ frame.preUpdate(notifyAll2);
3401
+ };
3402
+ const notifyAll2 = () => {
3403
+ for (const handler of containerHandlers) {
3404
+ handler.notify();
3405
+ }
3406
+ };
3407
+ const listener2 = () => frame.read(measureAll);
3408
+ scrollListeners.set(container, listener2);
3409
+ const target = getEventTarget(container);
3410
+ window.addEventListener("resize", listener2, { passive: true });
3411
+ if (container !== document.documentElement) {
3412
+ resizeListeners.set(container, resize(container, listener2));
3413
+ }
3414
+ target.addEventListener("scroll", listener2, { passive: true });
3415
+ listener2();
3416
+ }
3417
+ if (trackContentSize && !dimensionCheckProcesses.has(container)) {
3418
+ const listener2 = scrollListeners.get(container);
3419
+ const size = {
3420
+ width: container.scrollWidth,
3421
+ height: container.scrollHeight
3422
+ };
3423
+ scrollSize.set(container, size);
3424
+ const checkScrollDimensions = () => {
3425
+ const newWidth = container.scrollWidth;
3426
+ const newHeight = container.scrollHeight;
3427
+ if (size.width !== newWidth || size.height !== newHeight) {
3428
+ listener2();
3429
+ size.width = newWidth;
3430
+ size.height = newHeight;
3431
+ }
3432
+ };
3433
+ const dimensionCheckProcess = frame.read(checkScrollDimensions, true);
3434
+ dimensionCheckProcesses.set(container, dimensionCheckProcess);
3435
+ }
3436
+ const listener = scrollListeners.get(container);
3437
+ frame.read(listener, false, true);
3438
+ return () => {
3439
+ cancelFrame(listener);
3440
+ const currentHandlers = onScrollHandlers.get(container);
3441
+ if (!currentHandlers)
3442
+ return;
3443
+ currentHandlers.delete(containerHandler);
3444
+ if (currentHandlers.size)
3445
+ return;
3446
+ const scrollListener = scrollListeners.get(container);
3447
+ scrollListeners.delete(container);
3448
+ if (scrollListener) {
3449
+ getEventTarget(container).removeEventListener("scroll", scrollListener);
3450
+ resizeListeners.get(container)?.();
3451
+ window.removeEventListener("resize", scrollListener);
3452
+ }
3453
+ const dimensionCheckProcess = dimensionCheckProcesses.get(container);
3454
+ if (dimensionCheckProcess) {
3455
+ cancelFrame(dimensionCheckProcess);
3456
+ dimensionCheckProcesses.delete(container);
3457
+ }
3458
+ scrollSize.delete(container);
3459
+ };
3460
+ }
3461
+
3462
+ // node_modules/framer-motion/dist/es/render/dom/scroll/utils/get-timeline.mjs
3463
+ var timelineCache = /* @__PURE__ */ new Map();
3464
+ function scrollTimelineFallback(options) {
3465
+ const currentTime = { value: 0 };
3466
+ const cancel = scrollInfo((info) => {
3467
+ currentTime.value = info[options.axis].progress * 100;
3468
+ }, options);
3469
+ return { currentTime, cancel };
3470
+ }
3471
+ function getTimeline({ source, container, ...options }) {
3472
+ const { axis } = options;
3473
+ if (source)
3474
+ container = source;
3475
+ const containerCache = timelineCache.get(container) ?? /* @__PURE__ */ new Map();
3476
+ timelineCache.set(container, containerCache);
3477
+ const targetKey = options.target ?? "self";
3478
+ const targetCache = containerCache.get(targetKey) ?? {};
3479
+ const axisKey = axis + (options.offset ?? []).join(",");
3480
+ if (!targetCache[axisKey]) {
3481
+ targetCache[axisKey] = !options.target && supportsScrollTimeline() ? new ScrollTimeline({ source: container, axis }) : scrollTimelineFallback({ container, ...options });
3482
+ }
3483
+ return targetCache[axisKey];
3484
+ }
3485
+
3486
+ // node_modules/framer-motion/dist/es/render/dom/scroll/attach-animation.mjs
3487
+ function attachToAnimation(animation, options) {
3488
+ const timeline = getTimeline(options);
3489
+ return animation.attachTimeline({
3490
+ timeline: options.target ? void 0 : timeline,
3491
+ observe: (valueAnimation) => {
3492
+ valueAnimation.pause();
3493
+ return observeTimeline((progress2) => {
3494
+ valueAnimation.time = valueAnimation.iterationDuration * progress2;
3495
+ }, timeline);
3496
+ }
3497
+ });
3498
+ }
3499
+
3500
+ // node_modules/framer-motion/dist/es/render/dom/scroll/attach-function.mjs
3501
+ function isOnScrollWithInfo(onScroll) {
3502
+ return onScroll.length === 2;
3503
+ }
3504
+ function attachToFunction(onScroll, options) {
3505
+ if (isOnScrollWithInfo(onScroll)) {
3506
+ return scrollInfo((info) => {
3507
+ onScroll(info[options.axis].progress, info);
3508
+ }, options);
3509
+ } else {
3510
+ return observeTimeline(onScroll, getTimeline(options));
3511
+ }
3512
+ }
3513
+
3514
+ // node_modules/framer-motion/dist/es/render/dom/scroll/index.mjs
3515
+ function scroll(onScroll, { axis = "y", container = document.scrollingElement, ...options } = {}) {
3516
+ if (!container)
3517
+ return noop;
3518
+ const optionsWithDefaults = { axis, container, ...options };
3519
+ return typeof onScroll === "function" ? attachToFunction(onScroll, optionsWithDefaults) : attachToAnimation(onScroll, optionsWithDefaults);
3520
+ }
3521
+
3522
+ // node_modules/framer-motion/dist/es/value/use-scroll.mjs
3523
+ var createScrollMotionValues = () => ({
3524
+ scrollX: motionValue(0),
3525
+ scrollY: motionValue(0),
3526
+ scrollXProgress: motionValue(0),
3527
+ scrollYProgress: motionValue(0)
3528
+ });
3529
+ var isRefPending = (ref) => {
3530
+ if (!ref)
3531
+ return false;
3532
+ return !ref.current;
3533
+ };
3534
+ function useScroll({ container, target, ...options } = {}) {
3535
+ const values = useConstant(createScrollMotionValues);
3536
+ const scrollAnimation = (0, import_react4.useRef)(null);
3537
+ const needsStart = (0, import_react4.useRef)(false);
3538
+ const start = (0, import_react4.useCallback)(() => {
3539
+ scrollAnimation.current = scroll((_progress, { x, y }) => {
3540
+ values.scrollX.set(x.current);
3541
+ values.scrollXProgress.set(x.progress);
3542
+ values.scrollY.set(y.current);
3543
+ values.scrollYProgress.set(y.progress);
3544
+ }, {
3545
+ ...options,
3546
+ container: container?.current || void 0,
3547
+ target: target?.current || void 0
3548
+ });
3549
+ return () => {
3550
+ scrollAnimation.current?.();
3551
+ };
3552
+ }, [container, target, JSON.stringify(options.offset)]);
3553
+ useIsomorphicLayoutEffect(() => {
3554
+ needsStart.current = false;
3555
+ if (isRefPending(container) || isRefPending(target)) {
3556
+ needsStart.current = true;
3557
+ return;
3558
+ } else {
3559
+ return start();
3560
+ }
3561
+ }, [start]);
3562
+ (0, import_react4.useEffect)(() => {
3563
+ if (needsStart.current) {
3564
+ invariant(!isRefPending(container), "Container ref is defined but not hydrated", "use-scroll-ref");
3565
+ invariant(!isRefPending(target), "Target ref is defined but not hydrated", "use-scroll-ref");
3566
+ return start();
3567
+ } else {
3568
+ return;
3569
+ }
3570
+ }, [start]);
3571
+ return values;
3572
+ }
3573
+
3574
+ // node_modules/framer-motion/dist/es/value/use-motion-value.mjs
3575
+ var import_react5 = require("react");
3576
+ function useMotionValue(initial) {
3577
+ const value = useConstant(() => motionValue(initial));
3578
+ const { isStatic } = (0, import_react5.useContext)(MotionConfigContext);
3579
+ if (isStatic) {
3580
+ const [, setLatest] = (0, import_react5.useState)(initial);
3581
+ (0, import_react5.useEffect)(() => value.on("change", setLatest), []);
3582
+ }
3583
+ return value;
3584
+ }
3585
+
3586
+ // node_modules/framer-motion/dist/es/value/use-combine-values.mjs
3587
+ function useCombineMotionValues(values, combineValues) {
3588
+ const value = useMotionValue(combineValues());
3589
+ const updateValue = () => value.set(combineValues());
3590
+ updateValue();
3591
+ useIsomorphicLayoutEffect(() => {
3592
+ const scheduleUpdate = () => frame.preRender(updateValue, false, true);
3593
+ const subscriptions = values.map((v) => v.on("change", scheduleUpdate));
3594
+ return () => {
3595
+ subscriptions.forEach((unsubscribe) => unsubscribe());
3596
+ cancelFrame(updateValue);
3597
+ };
3598
+ });
3599
+ return value;
3600
+ }
3601
+
3602
+ // node_modules/framer-motion/dist/es/value/use-follow-value.mjs
3603
+ var import_react6 = require("react");
3604
+
3605
+ // node_modules/framer-motion/dist/es/value/use-computed.mjs
3606
+ function useComputed(compute) {
3607
+ collectMotionValues.current = [];
3608
+ compute();
3609
+ const value = useCombineMotionValues(collectMotionValues.current, compute);
3610
+ collectMotionValues.current = void 0;
3611
+ return value;
3612
+ }
3613
+
3614
+ // node_modules/framer-motion/dist/es/value/use-transform.mjs
3615
+ function useTransform(input, inputRangeOrTransformer, outputRangeOrMap, options) {
3616
+ if (typeof input === "function") {
3617
+ return useComputed(input);
3618
+ }
3619
+ const isOutputMap = outputRangeOrMap !== void 0 && !Array.isArray(outputRangeOrMap) && typeof inputRangeOrTransformer !== "function";
3620
+ if (isOutputMap) {
3621
+ return useMapTransform(input, inputRangeOrTransformer, outputRangeOrMap, options);
3622
+ }
3623
+ const outputRange = outputRangeOrMap;
3624
+ const transformer = typeof inputRangeOrTransformer === "function" ? inputRangeOrTransformer : transform(inputRangeOrTransformer, outputRange, options);
3625
+ return Array.isArray(input) ? useListTransform(input, transformer) : useListTransform([input], ([latest]) => transformer(latest));
3626
+ }
3627
+ function useListTransform(values, transformer) {
3628
+ const latest = useConstant(() => []);
3629
+ return useCombineMotionValues(values, () => {
3630
+ latest.length = 0;
3631
+ const numValues = values.length;
3632
+ for (let i = 0; i < numValues; i++) {
3633
+ latest[i] = values[i].get();
3634
+ }
3635
+ return transformer(latest);
3636
+ });
3637
+ }
3638
+ function useMapTransform(inputValue, inputRange, outputMap, options) {
3639
+ const keys2 = useConstant(() => Object.keys(outputMap));
3640
+ const output = useConstant(() => ({}));
3641
+ for (const key of keys2) {
3642
+ output[key] = useTransform(inputValue, inputRange, outputMap[key], options);
3643
+ }
3644
+ return output;
3645
+ }
3646
+
3647
+ // node_modules/framer-motion/dist/es/value/use-follow-value.mjs
3648
+ function useFollowValue(source, options = {}) {
3649
+ const { isStatic } = (0, import_react6.useContext)(MotionConfigContext);
3650
+ const getFromSource = () => isMotionValue(source) ? source.get() : source;
3651
+ if (isStatic) {
3652
+ return useTransform(getFromSource);
3653
+ }
3654
+ const value = useMotionValue(getFromSource());
3655
+ (0, import_react6.useInsertionEffect)(() => {
3656
+ return attachFollow(value, source, options);
3657
+ }, [value, JSON.stringify(options)]);
3658
+ return value;
3659
+ }
3660
+
3661
+ // node_modules/framer-motion/dist/es/value/use-spring.mjs
3662
+ function useSpring(source, options = {}) {
3663
+ return useFollowValue(source, { type: "spring", ...options });
3664
+ }
3665
+
3666
+ // node_modules/framer-motion/dist/es/animation/hooks/animation-controls.mjs
3667
+ function stopAnimation(visualElement) {
3668
+ visualElement.values.forEach((value) => value.stop());
3669
+ }
3670
+ function setVariants(visualElement, variantLabels) {
3671
+ const reversedLabels = [...variantLabels].reverse();
3672
+ reversedLabels.forEach((key) => {
3673
+ const variant = visualElement.getVariant(key);
3674
+ variant && setTarget(visualElement, variant);
3675
+ if (visualElement.variantChildren) {
3676
+ visualElement.variantChildren.forEach((child) => {
3677
+ setVariants(child, variantLabels);
3678
+ });
3679
+ }
3680
+ });
3681
+ }
3682
+ function setValues(visualElement, definition) {
3683
+ if (Array.isArray(definition)) {
3684
+ return setVariants(visualElement, definition);
3685
+ } else if (typeof definition === "string") {
3686
+ return setVariants(visualElement, [definition]);
3687
+ } else {
3688
+ setTarget(visualElement, definition);
3689
+ }
3690
+ }
3691
+ function animationControls() {
3692
+ let hasMounted = false;
3693
+ const subscribers = /* @__PURE__ */ new Set();
3694
+ const controls = {
3695
+ subscribe(visualElement) {
3696
+ subscribers.add(visualElement);
3697
+ return () => void subscribers.delete(visualElement);
3698
+ },
3699
+ start(definition, transitionOverride) {
3700
+ invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
3701
+ const animations = [];
3702
+ subscribers.forEach((visualElement) => {
3703
+ animations.push(animateVisualElement(visualElement, definition, {
3704
+ transitionOverride
3705
+ }));
3706
+ });
3707
+ return Promise.all(animations);
3708
+ },
3709
+ set(definition) {
3710
+ invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
3711
+ return subscribers.forEach((visualElement) => {
3712
+ setValues(visualElement, definition);
3713
+ });
3714
+ },
3715
+ stop() {
3716
+ subscribers.forEach((visualElement) => {
3717
+ stopAnimation(visualElement);
3718
+ });
3719
+ },
3720
+ mount() {
3721
+ hasMounted = true;
3722
+ return () => {
3723
+ hasMounted = false;
3724
+ controls.stop();
3725
+ };
3726
+ }
3727
+ };
3728
+ return controls;
3729
+ }
3730
+
3731
+ // node_modules/framer-motion/dist/es/animation/hooks/use-animation.mjs
3732
+ function useAnimationControls() {
3733
+ const controls = useConstant(animationControls);
3734
+ useIsomorphicLayoutEffect(controls.mount, []);
3735
+ return controls;
3736
+ }
3737
+ var useAnimation = useAnimationControls;
3738
+
3739
+ // src/bridges/motion/index.ts
3740
+ function useScrollProgress() {
3741
+ const { scrollYProgress } = useScroll();
3742
+ return scrollYProgress;
3743
+ }
3744
+ // Annotate the CommonJS export names for ESM import in node:
3745
+ 0 && (module.exports = {
3746
+ useAnimation,
3747
+ useMotionValue,
3748
+ useScrollProgress,
3749
+ useSpring,
3750
+ useTransform
3751
+ });
3752
+ //# sourceMappingURL=motion.js.map