@tamagui/animations-reanimated 2.7.7 → 3.0.0-beta.1097.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/createAnimations.cjs +928 -900
  2. package/dist/cjs/createAnimations.native.cjs +1176 -0
  3. package/dist/cjs/createAnimations.native.js +1121 -1118
  4. package/dist/cjs/createAnimations.native.js.map +1 -1
  5. package/dist/cjs/createAnimationsCompiler.cjs +64 -0
  6. package/dist/cjs/createAnimationsCompiler.native.cjs +68 -0
  7. package/dist/cjs/createAnimationsCompiler.native.js +70 -0
  8. package/dist/cjs/createAnimationsCompiler.native.js.map +1 -0
  9. package/dist/cjs/index.cjs +9 -11
  10. package/dist/cjs/index.compiler.cjs +24 -0
  11. package/dist/cjs/index.compiler.native.cjs +26 -0
  12. package/dist/cjs/index.compiler.native.js +28 -0
  13. package/dist/cjs/index.compiler.native.js.map +1 -0
  14. package/dist/cjs/index.native.cjs +20 -0
  15. package/dist/cjs/index.native.js +9 -10
  16. package/dist/cjs/index.native.js.map +1 -1
  17. package/dist/esm/createAnimations.mjs +917 -878
  18. package/dist/esm/createAnimations.mjs.map +1 -1
  19. package/dist/esm/createAnimations.native.js +1110 -1097
  20. package/dist/esm/createAnimations.native.js.map +1 -1
  21. package/dist/esm/createAnimationsCompiler.mjs +44 -0
  22. package/dist/esm/createAnimationsCompiler.mjs.map +1 -0
  23. package/dist/esm/createAnimationsCompiler.native.js +46 -0
  24. package/dist/esm/createAnimationsCompiler.native.js.map +1 -0
  25. package/dist/esm/index.compiler.mjs +3 -0
  26. package/dist/esm/index.compiler.native.js +3 -0
  27. package/dist/esm/index.js +1 -2
  28. package/dist/esm/index.mjs +1 -2
  29. package/dist/esm/index.native.js +1 -2
  30. package/package.json +11 -9
  31. package/src/createAnimations.tsx +369 -178
  32. package/src/createAnimationsCompiler.ts +89 -0
  33. package/src/index.compiler.ts +2 -0
  34. package/types/createAnimations.d.ts +5 -5
  35. package/types/createAnimations.d.ts.map +2 -2
  36. package/types/createAnimationsCompiler.d.ts +5 -0
  37. package/types/createAnimationsCompiler.d.ts.map +11 -0
  38. package/types/index.compiler.d.ts +3 -0
  39. package/types/index.compiler.d.ts.map +11 -0
  40. package/dist/esm/index.js.map +0 -1
  41. package/dist/esm/index.mjs.map +0 -1
  42. package/dist/esm/index.native.js.map +0 -1
@@ -0,0 +1,1176 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var createAnimations_exports = {};
30
+ __export(createAnimations_exports, { createAnimations: () => createAnimations });
31
+ module.exports = __toCommonJS(createAnimations_exports);
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var import_animation_helpers = require("@tamagui/animation-helpers");
34
+ var import_core = require("@tamagui/core");
35
+ var import_internal_runtime = require("@tamagui/web/internal-runtime");
36
+ var import_use_presence = require("@tamagui/use-presence");
37
+ var import_normalize_colors = __toESM(require("@react-native/normalize-colors"), 1);
38
+ var import_react = __toESM(require("react"), 1);
39
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
40
+ var getDefaultExport = function(module2) {
41
+ var mod = module2;
42
+ if (mod.__esModule || mod[Symbol.toStringTag] === "Module") {
43
+ return mod.default || mod;
44
+ }
45
+ return mod;
46
+ };
47
+ var Animated = getDefaultExport(import_react_native_reanimated.default);
48
+ var silenceAnimatedComponentDevCheck = function(style) {
49
+ if (process.env.NODE_ENV !== "development" || import_core.isWeb || !style || typeof style !== "object") {
50
+ return;
51
+ }
52
+ Object.defineProperty(style, "_requiresAnimatedComponent", {
53
+ configurable: true,
54
+ enumerable: false,
55
+ value: true
56
+ });
57
+ };
58
+ var resolveDynamicValue = function(value, isDark) {
59
+ if (value !== null && typeof value === "object" && "dynamic" in value && typeof value.dynamic === "object") {
60
+ var dynamic = value.dynamic;
61
+ return isDark ? dynamic.dark : dynamic.light;
62
+ }
63
+ return value;
64
+ };
65
+ var updateMapperState = import_core.isWeb ? function(state, emitted) {
66
+ state.value.emitted = emitted;
67
+ } : function(state, emitted) {
68
+ "worklet";
69
+ if (!globalThis._WORKLET) return;
70
+ state.modify(function(current) {
71
+ current.emitted = emitted;
72
+ return current;
73
+ }, false);
74
+ };
75
+ var cloneAnimationValue = function(value) {
76
+ if (Array.isArray(value)) {
77
+ return value.map(cloneAnimationValue);
78
+ }
79
+ if (value && typeof value === "object") {
80
+ var next = {};
81
+ for (var key in value) {
82
+ next[key] = cloneAnimationValue(value[key]);
83
+ }
84
+ return next;
85
+ }
86
+ return value;
87
+ };
88
+ var cloneStyleRecord = function(style) {
89
+ var next = {};
90
+ for (var key in style) {
91
+ next[key] = cloneAnimationValue(style[key]);
92
+ }
93
+ return next;
94
+ };
95
+ var cloneTransitionConfig = function(config) {
96
+ return cloneAnimationValue(config);
97
+ };
98
+ var getAnimatedTransforms = function(value) {
99
+ if (!Array.isArray(value)) return [];
100
+ return value.filter(function(item) {
101
+ return item !== null && typeof item === "object" && !Array.isArray(item);
102
+ });
103
+ };
104
+ var getRemovedAnimatedKeys = function(current, previous) {
105
+ var removedKeys = {};
106
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
107
+ try {
108
+ for (var _iterator = previous[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
109
+ var key = _step.value;
110
+ if (!current.has(key)) removedKeys[key] = true;
111
+ }
112
+ } catch (err) {
113
+ _didIteratorError = true;
114
+ _iteratorError = err;
115
+ } finally {
116
+ try {
117
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
118
+ _iterator.return();
119
+ }
120
+ } finally {
121
+ if (_didIteratorError) {
122
+ throw _iteratorError;
123
+ }
124
+ }
125
+ }
126
+ return removedKeys;
127
+ };
128
+ var getImplicitDefault = function(key, targetValue) {
129
+ "worklet";
130
+ var value = key === "opacity" || key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
131
+ if (typeof targetValue !== "string") return value;
132
+ var suffixIndex = 0;
133
+ while (suffixIndex < targetValue.length) {
134
+ var character = targetValue[suffixIndex];
135
+ var code = character.charCodeAt(0);
136
+ if (code >= 48 && code <= 57 || character === "." || character === "-" || character === "+") {
137
+ suffixIndex++;
138
+ } else {
139
+ break;
140
+ }
141
+ }
142
+ return suffixIndex > 0 ? `${value}${targetValue.slice(suffixIndex)}` : value;
143
+ };
144
+ var COLOR_STYLE_KEYS = {
145
+ backgroundColor: true,
146
+ borderColor: true,
147
+ borderLeftColor: true,
148
+ borderRightColor: true,
149
+ borderTopColor: true,
150
+ borderBottomColor: true,
151
+ color: true
152
+ };
153
+ var toReanimatedColor = function(value) {
154
+ "worklet";
155
+ if (typeof value === "number") {
156
+ var color = value >>> 0;
157
+ var alpha = (color >>> 24 & 255) / 255;
158
+ var red = color >>> 16 & 255;
159
+ var green = color >>> 8 & 255;
160
+ var blue = color & 255;
161
+ return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
162
+ }
163
+ if (typeof value !== "string") return value;
164
+ var trimmed = value.trim();
165
+ if (trimmed === "transparent") return "rgba(0, 0, 0, 0)";
166
+ return trimmed;
167
+ };
168
+ var isReanimatedColorHistory = function(value) {
169
+ "worklet";
170
+ var normalized = toReanimatedColor(value);
171
+ return typeof normalized === "string" && normalized.startsWith("rgba(");
172
+ };
173
+ var normalizeAnimationColor = function(value) {
174
+ if (typeof value === "number") {
175
+ return toReanimatedColor(value);
176
+ }
177
+ if (typeof value !== "string") return;
178
+ var color = (0, import_normalize_colors.default)(value);
179
+ if (color == null) return;
180
+ var red = Math.round((color & 4278190080) >>> 24);
181
+ var green = Math.round((color & 16711680) >>> 16);
182
+ var blue = Math.round((color & 65280) >>> 8);
183
+ var alpha = (color & 255) / 255;
184
+ return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
185
+ };
186
+ var buildSnapshot = function(animated, statics, transforms, previousKeys, lastPainted) {
187
+ var snapshotAnimated = {};
188
+ var snapshotStatics = cloneStyleRecord(statics);
189
+ for (var key in snapshotStatics) {
190
+ if (!COLOR_STYLE_KEYS[key]) continue;
191
+ var normalized = normalizeAnimationColor(snapshotStatics[key]);
192
+ if (normalized !== void 0) snapshotStatics[key] = normalized;
193
+ }
194
+ for (var key1 in animated) {
195
+ if (key1 === "transform") continue;
196
+ var value = animated[key1];
197
+ if (COLOR_STYLE_KEYS[key1]) {
198
+ var normalized1 = normalizeAnimationColor(value);
199
+ if (normalized1 === void 0) {
200
+ snapshotStatics[key1] = cloneAnimationValue(value);
201
+ continue;
202
+ }
203
+ snapshotAnimated[key1] = normalized1;
204
+ } else {
205
+ snapshotAnimated[key1] = cloneAnimationValue(value);
206
+ }
207
+ }
208
+ var snapshotTransforms = transforms.map(cloneStyleRecord);
209
+ var keys = new Set(Object.keys(snapshotAnimated));
210
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
211
+ try {
212
+ for (var _iterator = snapshotTransforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
213
+ var transform = _step.value;
214
+ var key2 = Object.keys(transform)[0];
215
+ var value1 = key2 ? transform[key2] : void 0;
216
+ if (key2 && (typeof value1 === "number" || typeof value1 === "string")) {
217
+ keys.add(`transform:${key2}`);
218
+ }
219
+ }
220
+ } catch (err) {
221
+ _didIteratorError = true;
222
+ _iteratorError = err;
223
+ } finally {
224
+ try {
225
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
226
+ _iterator.return();
227
+ }
228
+ } finally {
229
+ if (_didIteratorError) {
230
+ throw _iteratorError;
231
+ }
232
+ }
233
+ }
234
+ var seeds = {};
235
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
236
+ try {
237
+ for (var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
238
+ var key3 = _step1.value;
239
+ var value2 = lastPainted[key3];
240
+ if (typeof value2 !== "number" && typeof value2 !== "string") continue;
241
+ if (value2 === "auto" || typeof value2 === "string" && value2.startsWith("calc")) {
242
+ continue;
243
+ }
244
+ if (COLOR_STYLE_KEYS[key3]) value2 = normalizeAnimationColor(value2);
245
+ if (value2 !== void 0) seeds[key3] = value2;
246
+ }
247
+ } catch (err) {
248
+ _didIteratorError1 = true;
249
+ _iteratorError1 = err;
250
+ } finally {
251
+ try {
252
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
253
+ _iterator1.return();
254
+ }
255
+ } finally {
256
+ if (_didIteratorError1) {
257
+ throw _iteratorError1;
258
+ }
259
+ }
260
+ }
261
+ var gatedKeys = {};
262
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
263
+ try {
264
+ for (var _iterator2 = keys[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
265
+ var key4 = _step2.value;
266
+ gatedKeys[key4] = true;
267
+ }
268
+ } catch (err) {
269
+ _didIteratorError2 = true;
270
+ _iteratorError2 = err;
271
+ } finally {
272
+ try {
273
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
274
+ _iterator2.return();
275
+ }
276
+ } finally {
277
+ if (_didIteratorError2) {
278
+ throw _iteratorError2;
279
+ }
280
+ }
281
+ }
282
+ var removedKeys = getRemovedAnimatedKeys(keys, previousKeys);
283
+ var painted = {
284
+ ...snapshotStatics,
285
+ ...snapshotAnimated
286
+ };
287
+ var staticTransforms = getAnimatedTransforms(snapshotStatics.transform);
288
+ delete painted.transform;
289
+ var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
290
+ try {
291
+ for (var _iterator3 = staticTransforms[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
292
+ var transform1 = _step3.value;
293
+ var key5 = Object.keys(transform1)[0];
294
+ if (key5) painted[`transform:${key5}`] = transform1[key5];
295
+ }
296
+ } catch (err) {
297
+ _didIteratorError3 = true;
298
+ _iteratorError3 = err;
299
+ } finally {
300
+ try {
301
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
302
+ _iterator3.return();
303
+ }
304
+ } finally {
305
+ if (_didIteratorError3) {
306
+ throw _iteratorError3;
307
+ }
308
+ }
309
+ }
310
+ var _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
311
+ try {
312
+ for (var _iterator4 = snapshotTransforms[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
313
+ var transform2 = _step4.value;
314
+ var key6 = Object.keys(transform2)[0];
315
+ if (key6) painted[`transform:${key6}`] = transform2[key6];
316
+ }
317
+ } catch (err) {
318
+ _didIteratorError4 = true;
319
+ _iteratorError4 = err;
320
+ } finally {
321
+ try {
322
+ if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
323
+ _iterator4.return();
324
+ }
325
+ } finally {
326
+ if (_didIteratorError4) {
327
+ throw _iteratorError4;
328
+ }
329
+ }
330
+ }
331
+ return {
332
+ value: {
333
+ animated: snapshotAnimated,
334
+ statics: snapshotStatics,
335
+ transforms: snapshotTransforms,
336
+ gatedKeys,
337
+ seeds,
338
+ removedKeys,
339
+ removeTransform: Object.keys(removedKeys).some(function(key7) {
340
+ return key7.startsWith("transform:");
341
+ }),
342
+ clearValue: import_core.isWeb ? "" : null
343
+ },
344
+ painted,
345
+ keys
346
+ };
347
+ };
348
+ var getGatedKeys = function(snapshot) {
349
+ return Object.keys(snapshot.gatedKeys);
350
+ };
351
+ var createReanimatedConfig = function(config) {
352
+ "worklet";
353
+ var next = {};
354
+ var source = config;
355
+ for (var key in source) {
356
+ if (key === "type" || key === "delay") continue;
357
+ var value = source[key];
358
+ if (value !== void 0) {
359
+ next[key] = value;
360
+ }
361
+ }
362
+ return next;
363
+ };
364
+ var applyAnimation = function(targetValue, config, callback, seedValue) {
365
+ "worklet";
366
+ var validateStartAsColor = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
367
+ var delay = config.delay;
368
+ var reanimatedConfig = createReanimatedConfig(config);
369
+ var animatedValue;
370
+ if (config.type === "timing") {
371
+ animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, reanimatedConfig, callback);
372
+ } else {
373
+ animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, reanimatedConfig, callback);
374
+ var innerOnFrame = animatedValue.onFrame;
375
+ animatedValue.onFrame = function(animation, now) {
376
+ "worklet";
377
+ return innerOnFrame(animation, now < animation.lastTimestamp ? animation.lastTimestamp : now);
378
+ };
379
+ }
380
+ var isAnimationDescriptor = animatedValue !== null && typeof animatedValue !== "number" && typeof animatedValue !== "string" && typeof animatedValue !== "boolean" && typeof animatedValue !== "undefined";
381
+ if (isAnimationDescriptor && (seedValue !== void 0 || validateStartAsColor)) {
382
+ var innerOnStart = animatedValue.onStart;
383
+ animatedValue.onStart = function(animation, value, timestamp, previousAnimation) {
384
+ "worklet";
385
+ var startValue = validateStartAsColor ? isReanimatedColorHistory(value) ? toReanimatedColor(value) : seedValue !== null && seedValue !== void 0 ? seedValue : targetValue : seedValue;
386
+ innerOnStart(animation, startValue, timestamp, previousAnimation);
387
+ };
388
+ }
389
+ if (isAnimationDescriptor && delay && delay > 0) {
390
+ animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue);
391
+ }
392
+ return animatedValue;
393
+ };
394
+ var animateSnapshotValue = function(key, implicitKey, targetValue, config, previouslyEmitted, seedValue, gated, currentlyExiting, exitCycleId, currentlyCompletingEnter, enterCycleId, currentlyCompletingUpdate, updateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone) {
395
+ "worklet";
396
+ var validateStartAsColor = arguments.length > 16 && arguments[16] !== void 0 ? arguments[16] : false;
397
+ var cycleGated = gated && (currentlyExiting || currentlyCompletingEnter || currentlyCompletingUpdate);
398
+ if (!previouslyEmitted && seedValue === void 0 && !cycleGated) {
399
+ return targetValue;
400
+ }
401
+ var callback;
402
+ if (gated && currentlyExiting) {
403
+ callback = function(finished) {
404
+ "worklet";
405
+ (0, import_react_native_reanimated.runOnJS)(markExitKeyDone)(key, exitCycleId, finished !== null && finished !== void 0 ? finished : false);
406
+ };
407
+ } else if (gated && currentlyCompletingEnter) {
408
+ callback = function() {
409
+ "worklet";
410
+ (0, import_react_native_reanimated.runOnJS)(markEnterKeyDone)(key, enterCycleId);
411
+ };
412
+ } else if (gated && currentlyCompletingUpdate) {
413
+ callback = function(finished) {
414
+ "worklet";
415
+ (0, import_react_native_reanimated.runOnJS)(markUpdateKeyDone)(key, updateCycleId, finished !== null && finished !== void 0 ? finished : false);
416
+ };
417
+ }
418
+ return applyAnimation(targetValue, config, callback, previouslyEmitted ? void 0 : seedValue !== null && seedValue !== void 0 ? seedValue : getImplicitDefault(implicitKey, targetValue), validateStartAsColor);
419
+ };
420
+ var ANIMATABLE_PROPERTIES = {
421
+ transform: true,
422
+ opacity: true,
423
+ height: true,
424
+ width: true,
425
+ minWidth: true,
426
+ minHeight: true,
427
+ maxWidth: true,
428
+ maxHeight: true,
429
+ backgroundColor: true,
430
+ borderColor: true,
431
+ borderLeftColor: true,
432
+ borderRightColor: true,
433
+ borderTopColor: true,
434
+ borderBottomColor: true,
435
+ borderRadius: true,
436
+ borderTopLeftRadius: true,
437
+ borderTopRightRadius: true,
438
+ borderBottomLeftRadius: true,
439
+ borderBottomRightRadius: true,
440
+ borderWidth: true,
441
+ borderLeftWidth: true,
442
+ borderRightWidth: true,
443
+ borderTopWidth: true,
444
+ borderBottomWidth: true,
445
+ color: true,
446
+ fontSize: true,
447
+ fontWeight: true,
448
+ lineHeight: true,
449
+ letterSpacing: true,
450
+ left: true,
451
+ right: true,
452
+ top: true,
453
+ bottom: true,
454
+ margin: true,
455
+ marginTop: true,
456
+ marginBottom: true,
457
+ marginLeft: true,
458
+ marginRight: true,
459
+ marginHorizontal: true,
460
+ marginVertical: true,
461
+ padding: true,
462
+ paddingTop: true,
463
+ paddingBottom: true,
464
+ paddingLeft: true,
465
+ paddingRight: true,
466
+ paddingHorizontal: true,
467
+ paddingVertical: true,
468
+ gap: true,
469
+ rowGap: true,
470
+ columnGap: true,
471
+ flex: true,
472
+ flexGrow: true,
473
+ flexShrink: true
474
+ };
475
+ var canAnimateProperty = function(key, value) {
476
+ if (!ANIMATABLE_PROPERTIES[key]) return false;
477
+ if (value === "auto") return false;
478
+ if (typeof value === "string" && value.startsWith("calc")) return false;
479
+ return true;
480
+ };
481
+ var splitAnimationStyles = function(style, isDark, disableAnimation) {
482
+ var animated = {};
483
+ var statics = {};
484
+ for (var key in style) {
485
+ var value = resolveDynamicValue(style[key], isDark);
486
+ if (value === void 0) continue;
487
+ if (!disableAnimation && canAnimateProperty(key, value)) {
488
+ animated[key] = cloneAnimationValue(value);
489
+ } else {
490
+ statics[key] = cloneAnimationValue(value);
491
+ }
492
+ }
493
+ return {
494
+ animated,
495
+ statics
496
+ };
497
+ };
498
+ function createWebAnimatedComponent(defaultTag) {
499
+ var isText = defaultTag === "span";
500
+ var Component = Animated.createAnimatedComponent((0, import_core.createRefComponent)(function(propsIn, ref) {
501
+ var _hooks_usePropsTransform;
502
+ var { forwardedRef, render = defaultTag, ...rest } = propsIn;
503
+ var hostRef = (0, import_react.useRef)(null);
504
+ var composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef);
505
+ var stateRef = (0, import_react.useRef)({ get host() {
506
+ return hostRef.current;
507
+ } });
508
+ var [, themeState] = (0, import_internal_runtime.useThemeWithState)({});
509
+ var _themeState_theme, _themeState_name;
510
+ var result = (0, import_core.getSplitStyles)(rest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, (_themeState_theme = themeState === null || themeState === void 0 ? void 0 : themeState.theme) !== null && _themeState_theme !== void 0 ? _themeState_theme : {}, (_themeState_name = themeState === null || themeState === void 0 ? void 0 : themeState.name) !== null && _themeState_name !== void 0 ? _themeState_name : "", { unmounted: false }, {
511
+ isAnimated: false,
512
+ noClass: true
513
+ });
514
+ var _result_viewProps;
515
+ var viewProps = (_result_viewProps = result === null || result === void 0 ? void 0 : result.viewProps) !== null && _result_viewProps !== void 0 ? _result_viewProps : {};
516
+ var Element = render;
517
+ var transformedProps = (_hooks_usePropsTransform = import_core.hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(import_core.hooks, render, viewProps, stateRef, false);
518
+ var { nativeID, ...webProps } = transformedProps !== null && transformedProps !== void 0 ? transformedProps : viewProps;
519
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Element, {
520
+ ...webProps,
521
+ ref: composedRefs
522
+ });
523
+ }));
524
+ Component.acceptRenderProp = true;
525
+ return Component;
526
+ }
527
+ var AnimatedView = createWebAnimatedComponent("div");
528
+ var AnimatedText = createWebAnimatedComponent("span");
529
+ var defaultConfig = { type: "spring" };
530
+ function entryToReanimated(entry) {
531
+ if (entry.timing.kind === "spring") {
532
+ return {
533
+ type: "spring",
534
+ stiffness: entry.timing.stiffness,
535
+ damping: entry.timing.damping,
536
+ mass: entry.timing.mass,
537
+ delay: entry.delayMs || void 0
538
+ };
539
+ }
540
+ var bezier = (0, import_animation_helpers.easingToBezier)(entry.timing.easing);
541
+ return {
542
+ type: "timing",
543
+ duration: entry.timing.durationMs,
544
+ easing: bezier ? import_react_native_reanimated.Easing.bezier(bezier[0], bezier[1], bezier[2], bezier[3]) : void 0,
545
+ delay: entry.delayMs || void 0
546
+ };
547
+ }
548
+ function buildTransitionConfig(transition, animations, animationState, styleKeys) {
549
+ var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(transition, { animations }), animationState);
550
+ var base = resolved.all ? entryToReanimated(resolved.all) : { ...defaultConfig };
551
+ var propertyConfigs = {};
552
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
553
+ try {
554
+ for (var _iterator = styleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
555
+ var key = _step.value;
556
+ var entry = (0, import_animation_helpers.getTransitionForKey)(resolved, key);
557
+ propertyConfigs[key] = entry ? entryToReanimated(entry) : instantConfig();
558
+ }
559
+ } catch (err) {
560
+ _didIteratorError = true;
561
+ _iteratorError = err;
562
+ } finally {
563
+ try {
564
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
565
+ _iterator.return();
566
+ }
567
+ } finally {
568
+ if (_didIteratorError) {
569
+ throw _iteratorError;
570
+ }
571
+ }
572
+ }
573
+ return {
574
+ baseConfig: base,
575
+ propertyConfigs,
576
+ resolved
577
+ };
578
+ }
579
+ var instantConfig = function() {
580
+ return {
581
+ type: "timing",
582
+ duration: 0
583
+ };
584
+ };
585
+ function getStyleKeys(style) {
586
+ var keys = new Set(Object.keys(style));
587
+ if (style.transform && Array.isArray(style.transform)) {
588
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
589
+ try {
590
+ for (var _iterator = style.transform[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
591
+ var t = _step.value;
592
+ if (t && typeof t === "object") {
593
+ keys.add(Object.keys(t)[0]);
594
+ }
595
+ }
596
+ } catch (err) {
597
+ _didIteratorError = true;
598
+ _iteratorError = err;
599
+ } finally {
600
+ try {
601
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
602
+ _iterator.return();
603
+ }
604
+ } finally {
605
+ if (_didIteratorError) {
606
+ throw _iteratorError;
607
+ }
608
+ }
609
+ }
610
+ }
611
+ return keys;
612
+ }
613
+ function createAnimations(animations) {
614
+ return {
615
+ needsCustomComponent: true,
616
+ View: import_core.isWeb ? AnimatedView : Animated.View,
617
+ Text: import_core.isWeb ? AnimatedText : Animated.Text,
618
+ inputStyle: "value",
619
+ outputStyle: "inline",
620
+ avoidReRenders: true,
621
+ animations,
622
+ usePresence: import_use_presence.usePresence,
623
+ ResetPresence: import_use_presence.ResetPresence,
624
+ useAnimatedNumber(initial) {
625
+ var sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
626
+ return (0, import_react.useMemo)(function() {
627
+ return {
628
+ getInstance() {
629
+ "worklet";
630
+ return sharedValue;
631
+ },
632
+ getValue() {
633
+ "worklet";
634
+ return sharedValue.value;
635
+ },
636
+ setValue(next) {
637
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { type: "spring" }, onFinish = arguments.length > 2 ? arguments[2] : void 0;
638
+ if (config.type === "direct") {
639
+ sharedValue.value = next;
640
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
641
+ } else {
642
+ var cb = onFinish ? function(finished) {
643
+ "worklet";
644
+ if (finished !== false) {
645
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
646
+ }
647
+ } : void 0;
648
+ var animationConfig = cloneTransitionConfig(config);
649
+ if (import_core.isWeb) {
650
+ sharedValue.value = applyAnimation(next, animationConfig, cb);
651
+ } else {
652
+ (0, import_react_native_reanimated.runOnUI)(function(targetValue, animationConfig2) {
653
+ "worklet";
654
+ sharedValue.value = applyAnimation(targetValue, animationConfig2, cb);
655
+ })(next, animationConfig);
656
+ }
657
+ }
658
+ },
659
+ stop() {
660
+ (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
661
+ }
662
+ };
663
+ }, [sharedValue]);
664
+ },
665
+ useAnimatedNumberReaction(param, onValue) {
666
+ var { value } = param;
667
+ var instance = value.getInstance();
668
+ return (0, import_react_native_reanimated.useAnimatedReaction)(function() {
669
+ return instance.value;
670
+ }, function(next, prev) {
671
+ if (prev !== next) {
672
+ (0, import_react_native_reanimated.runOnJS)(onValue)(next);
673
+ }
674
+ }, [onValue, instance]);
675
+ },
676
+ useAnimatedNumberStyle(val, getStyle) {
677
+ var instance = val.getInstance();
678
+ if (import_core.isWeb) {
679
+ return (0, import_react_native_reanimated.useAnimatedStyle)(function() {
680
+ "worklet";
681
+ return getStyle(instance.value);
682
+ }, [instance, getStyle]);
683
+ }
684
+ var styleVal = (0, import_react_native_reanimated.useDerivedValue)(function() {
685
+ "worklet";
686
+ return getStyle(instance.value);
687
+ });
688
+ var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function() {
689
+ "worklet";
690
+ return styleVal.value;
691
+ });
692
+ silenceAnimatedComponentDevCheck(animatedStyle);
693
+ return animatedStyle;
694
+ },
695
+ useAnimatedNumbersStyle(vals, getStyle) {
696
+ var instances = vals.map(function(v) {
697
+ return v.getInstance();
698
+ });
699
+ var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function() {
700
+ "worklet";
701
+ var currentValues = instances.map(function(inst) {
702
+ return inst.value;
703
+ });
704
+ return getStyle(...currentValues);
705
+ }, import_core.isWeb ? [getStyle, ...instances] : void 0);
706
+ silenceAnimatedComponentDevCheck(animatedStyle);
707
+ return animatedStyle;
708
+ },
709
+ useAnimations(animationProps) {
710
+ var { props, presence, style, componentState, useStyleEmitter, themeName, stateRef, styleState, onTransition } = animationProps;
711
+ var isHydrating = componentState.unmounted === true;
712
+ var isMounting = componentState.unmounted === "should-enter";
713
+ var isEntering = !!componentState.unmounted;
714
+ var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
715
+ var wasEnteringRef = (0, import_react.useRef)(isEntering);
716
+ var justFinishedEntering = wasEnteringRef.current && !isEntering;
717
+ import_react.default.useEffect(function() {
718
+ wasEnteringRef.current = isEntering;
719
+ });
720
+ var _styleState_effectiveTransition;
721
+ var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
722
+ var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
723
+ var resolvedTransition = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, { animations }), animationState);
724
+ var disableAnimation = isHydrating || !(0, import_animation_helpers.hasTransition)(resolvedTransition);
725
+ var isDark = (themeName === null || themeName === void 0 ? void 0 : themeName.startsWith("dark")) || false;
726
+ var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
727
+ var onTransitionRef = (0, import_react.useRef)(onTransition);
728
+ onTransitionRef.current = onTransition;
729
+ var emit = function(phase, cause, finished) {
730
+ var _onTransitionRef_current;
731
+ (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === "end" ? {
732
+ phase,
733
+ cause,
734
+ finished
735
+ } : {
736
+ phase,
737
+ cause
738
+ });
739
+ };
740
+ var enterStartedRef = (0, import_react.useRef)(false);
741
+ var exitStartedRef = (0, import_react.useRef)(false);
742
+ var updateStartedRef = (0, import_react.useRef)(false);
743
+ var isExitingJSRef = (0, import_react.useRef)(false);
744
+ isExitingJSRef.current = isExiting;
745
+ var updateCycleIdRef = (0, import_react.useRef)(0);
746
+ var pendingUpdateKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
747
+ var updateCompletedRef = (0, import_react.useRef)(false);
748
+ var isCompletingUpdateRef = (0, import_react_native_reanimated.useSharedValue)(false);
749
+ var updateCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(0);
750
+ var updateInterruptedRef = (0, import_react.useRef)(false);
751
+ var markUpdateKeyDone = (0, import_core.useEvent)(function(key, cycleId, finished) {
752
+ if (cycleId !== updateCycleIdRef.current) return;
753
+ if (updateCompletedRef.current) return;
754
+ if (!finished) updateInterruptedRef.current = true;
755
+ pendingUpdateKeysRef.current.delete(key);
756
+ if (pendingUpdateKeysRef.current.size === 0) {
757
+ updateCompletedRef.current = true;
758
+ isCompletingUpdateRef.value = false;
759
+ if (updateStartedRef.current) {
760
+ updateStartedRef.current = false;
761
+ emit("end", "update", !updateInterruptedRef.current);
762
+ }
763
+ }
764
+ });
765
+ var exitCycleIdRef = (0, import_react.useRef)(0);
766
+ var pendingExitKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
767
+ var exitCompletedRef = (0, import_react.useRef)(false);
768
+ var wasExitingRef = (0, import_react.useRef)(false);
769
+ var justStartedExiting = isExiting && !wasExitingRef.current;
770
+ var justStoppedExiting = !isExiting && wasExitingRef.current;
771
+ var markExitKeyDone = (0, import_core.useEvent)(function(key, cycleId, finished) {
772
+ if (cycleId !== exitCycleIdRef.current) return;
773
+ if (exitCompletedRef.current) return;
774
+ pendingExitKeysRef.current.delete(key);
775
+ if (pendingExitKeysRef.current.size === 0) {
776
+ exitCompletedRef.current = true;
777
+ if (exitStartedRef.current) {
778
+ exitStartedRef.current = false;
779
+ emit("end", "exit", true);
780
+ }
781
+ sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
782
+ }
783
+ });
784
+ var enterCycleIdRef = (0, import_react.useRef)(0);
785
+ var pendingEnterKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
786
+ var enterCompletedRef = (0, import_react.useRef)(false);
787
+ var markEnterKeyDone = (0, import_core.useEvent)(function(key, cycleId) {
788
+ if (cycleId !== enterCycleIdRef.current) return;
789
+ if (enterCompletedRef.current) return;
790
+ if (isExitingJSRef.current) return;
791
+ pendingEnterKeysRef.current.delete(key);
792
+ if (pendingEnterKeysRef.current.size === 0) {
793
+ enterCompletedRef.current = true;
794
+ if (enterStartedRef.current) {
795
+ enterStartedRef.current = false;
796
+ emit("end", "enter", true);
797
+ }
798
+ }
799
+ });
800
+ var isExitingRef = (0, import_react_native_reanimated.useSharedValue)(isExiting);
801
+ var exitCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(exitCycleIdRef.current);
802
+ var isCompletingEnterRef = (0, import_react_native_reanimated.useSharedValue)(false);
803
+ var enterCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(enterCycleIdRef.current);
804
+ if (justStartedExiting) {
805
+ exitCycleIdRef.current++;
806
+ exitCompletedRef.current = false;
807
+ pendingExitKeysRef.current.clear();
808
+ enterCycleIdRef.current++;
809
+ pendingEnterKeysRef.current.clear();
810
+ updateCycleIdRef.current++;
811
+ pendingUpdateKeysRef.current.clear();
812
+ updateCompletedRef.current = true;
813
+ }
814
+ if (justStoppedExiting) {
815
+ exitCycleIdRef.current++;
816
+ pendingExitKeysRef.current.clear();
817
+ }
818
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
819
+ isExitingRef.value = isExiting;
820
+ exitCycleIdShared.value = exitCycleIdRef.current;
821
+ isCompletingEnterRef.value = !isExiting && justFinishedEntering && Boolean(onTransitionRef.current);
822
+ enterCycleIdShared.value = enterCycleIdRef.current;
823
+ if (justStartedExiting) {
824
+ isCompletingUpdateRef.value = false;
825
+ updateCycleIdShared.value = updateCycleIdRef.current;
826
+ }
827
+ }, [
828
+ isExiting,
829
+ justFinishedEntering,
830
+ exitCycleIdRef.current,
831
+ enterCycleIdRef.current,
832
+ justStartedExiting
833
+ ]);
834
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
835
+ if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
836
+ exitStartedRef.current = false;
837
+ emit("end", "exit", false);
838
+ }
839
+ }, [justStoppedExiting]);
840
+ import_react.default.useEffect(function() {
841
+ wasExitingRef.current = isExiting;
842
+ });
843
+ var committedRenderKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
844
+ var lastPaintedRef = (0, import_react.useRef)({});
845
+ var carryRef = (0, import_react.useRef)({});
846
+ var { animatedStyles, staticStyles, nextCarry } = (0, import_react.useMemo)(function() {
847
+ var { animated, statics } = splitAnimationStyles(style, isDark, disableAnimation);
848
+ var nextCarry2 = cloneStyleRecord(carryRef.current);
849
+ for (var key in nextCarry2) {
850
+ if (!(key in animated)) delete nextCarry2[key];
851
+ }
852
+ for (var key1 in animated) {
853
+ if (!(key1 in nextCarry2)) {
854
+ nextCarry2[key1] = cloneAnimationValue(animated[key1]);
855
+ }
856
+ statics[key1] = nextCarry2[key1];
857
+ }
858
+ return {
859
+ animatedStyles: animated,
860
+ staticStyles: statics,
861
+ nextCarry: nextCarry2
862
+ };
863
+ }, [
864
+ disableAnimation,
865
+ style,
866
+ isDark
867
+ ]);
868
+ var renderSnapshot = (0, import_react.useMemo)(function() {
869
+ return buildSnapshot(animatedStyles, staticStyles, getAnimatedTransforms(animatedStyles.transform), committedRenderKeysRef.current, lastPaintedRef.current);
870
+ }, [animatedStyles, staticStyles]);
871
+ var renderSnapshotRef = (0, import_react_native_reanimated.useSharedValue)({
872
+ animated: {},
873
+ statics: {},
874
+ transforms: [],
875
+ gatedKeys: {},
876
+ seeds: {},
877
+ removedKeys: {},
878
+ removeTransform: false,
879
+ clearValue: import_core.isWeb ? "" : null
880
+ });
881
+ var emitterSnapshotRef = (0, import_react_native_reanimated.useSharedValue)(null);
882
+ var emitterKeysRef = (0, import_react.useRef)(null);
883
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
884
+ carryRef.current = nextCarry;
885
+ committedRenderKeysRef.current = renderSnapshot.keys;
886
+ lastPaintedRef.current = renderSnapshot.painted;
887
+ }, [nextCarry, renderSnapshot]);
888
+ var pseudoActiveRef = (0, import_react.useRef)(false);
889
+ var publishedSnapshotRef = (0, import_react.useRef)(null);
890
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
891
+ var renderChanged = publishedSnapshotRef.current !== renderSnapshot.value;
892
+ var droppingLatch = (isExiting || !pseudoActiveRef.current && publishedSnapshotRef.current !== null && renderChanged) && emitterSnapshotRef.value !== null;
893
+ var emitterKeys = droppingLatch ? emitterKeysRef.current : null;
894
+ if (droppingLatch || renderChanged) {
895
+ var removedKeys = emitterKeys ? {
896
+ ...renderSnapshot.value.removedKeys,
897
+ ...getRemovedAnimatedKeys(renderSnapshot.keys, emitterKeys)
898
+ } : renderSnapshot.value.removedKeys;
899
+ renderSnapshotRef.value = {
900
+ ...renderSnapshot.value,
901
+ removedKeys,
902
+ removeTransform: Object.keys(removedKeys).some(function(key) {
903
+ return key.startsWith("transform:");
904
+ })
905
+ };
906
+ publishedSnapshotRef.current = renderSnapshot.value;
907
+ }
908
+ if (droppingLatch) {
909
+ emitterSnapshotRef.value = null;
910
+ emitterKeysRef.current = null;
911
+ }
912
+ });
913
+ var { baseConfig, propertyConfigs } = (0, import_react.useMemo)(function() {
914
+ if (isHydrating) {
915
+ return {
916
+ baseConfig: {
917
+ type: "timing",
918
+ duration: 0
919
+ },
920
+ propertyConfigs: {}
921
+ };
922
+ }
923
+ return buildTransitionConfig(effectiveTransition, animations, animationState, getStyleKeys(animatedStyles));
924
+ }, [
925
+ isHydrating,
926
+ effectiveTransition,
927
+ animatedStyles,
928
+ animationState
929
+ ]);
930
+ var configRef = (0, import_react_native_reanimated.useSharedValue)({
931
+ baseConfig,
932
+ propertyConfigs,
933
+ disableAnimation,
934
+ isHydrating
935
+ });
936
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
937
+ configRef.value = {
938
+ baseConfig,
939
+ propertyConfigs,
940
+ disableAnimation,
941
+ isHydrating
942
+ };
943
+ }, [
944
+ baseConfig,
945
+ propertyConfigs,
946
+ disableAnimation,
947
+ isHydrating
948
+ ]);
949
+ useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function(nextStyle, effectiveTransition2, pseudoActive) {
950
+ if (isExitingJSRef.current) return;
951
+ pseudoActiveRef.current = pseudoActive === true;
952
+ var transitionToUse = effectiveTransition2 !== null && effectiveTransition2 !== void 0 ? effectiveTransition2 : props.transition;
953
+ var { baseConfig: newBase, propertyConfigs: newPropertyConfigs } = buildTransitionConfig(transitionToUse, animations, animationState, getStyleKeys(nextStyle));
954
+ configRef.value = {
955
+ baseConfig: newBase,
956
+ propertyConfigs: newPropertyConfigs,
957
+ disableAnimation: configRef.value.disableAnimation,
958
+ isHydrating: configRef.value.isHydrating
959
+ };
960
+ var _emitterKeysRef_current;
961
+ var previousKeys = (_emitterKeysRef_current = emitterKeysRef.current) !== null && _emitterKeysRef_current !== void 0 ? _emitterKeysRef_current : committedRenderKeysRef.current;
962
+ var { animated, statics } = splitAnimationStyles(nextStyle, isDark, configRef.value.disableAnimation);
963
+ var snapshot = buildSnapshot(animated, statics, getAnimatedTransforms(animated.transform), previousKeys, lastPaintedRef.current);
964
+ emitterSnapshotRef.value = snapshot.value;
965
+ emitterKeysRef.current = snapshot.keys;
966
+ lastPaintedRef.current = snapshot.painted;
967
+ if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
968
+ console.info("[animations-reanimated] useStyleEmitter update", {
969
+ animated,
970
+ statics,
971
+ transforms: snapshot.value.transforms
972
+ });
973
+ }
974
+ });
975
+ var exitKeysRegistered = (0, import_react.useRef)(false);
976
+ var enterKeysRegistered = (0, import_react.useRef)(false);
977
+ if (!isExiting && justFinishedEntering && onTransition) {
978
+ var enterKeys = getGatedKeys(renderSnapshot.value);
979
+ enterCycleIdRef.current++;
980
+ enterCompletedRef.current = false;
981
+ pendingEnterKeysRef.current = new Set(enterKeys);
982
+ enterKeysRegistered.current = enterKeys.length > 0;
983
+ }
984
+ if (justStartedExiting && sendExitComplete) {
985
+ var exitKeys = getGatedKeys(renderSnapshot.value);
986
+ pendingExitKeysRef.current = new Set(exitKeys);
987
+ exitKeysRegistered.current = exitKeys.length > 0;
988
+ }
989
+ var previousUpdateStyleRef = (0, import_react.useRef)(null);
990
+ var updateStyle = onTransition ? JSON.stringify(style) : null;
991
+ var previousUpdateStyle = previousUpdateStyleRef.current;
992
+ var shouldRegisterUpdate = updateStyle !== null && previousUpdateStyle !== null && previousUpdateStyle !== updateStyle && !isExiting && !isEntering && !justFinishedEntering;
993
+ var updateKeys = shouldRegisterUpdate ? getGatedKeys(renderSnapshot.value) : [];
994
+ (0, import_core.useIsomorphicLayoutEffect)(function() {
995
+ if (updateStyle === null) {
996
+ previousUpdateStyleRef.current = null;
997
+ isCompletingUpdateRef.value = false;
998
+ return;
999
+ }
1000
+ var previousStyleStillCurrent = previousUpdateStyleRef.current === previousUpdateStyle;
1001
+ previousUpdateStyleRef.current = updateStyle;
1002
+ if (!shouldRegisterUpdate || !previousStyleStillCurrent) return;
1003
+ var cycleId = ++updateCycleIdRef.current;
1004
+ pendingUpdateKeysRef.current = new Set(updateKeys);
1005
+ updateInterruptedRef.current = false;
1006
+ updateCompletedRef.current = updateKeys.length === 0;
1007
+ isCompletingUpdateRef.value = updateKeys.length > 0;
1008
+ updateCycleIdShared.value = cycleId;
1009
+ if (updateStartedRef.current) {
1010
+ emit("end", "update", false);
1011
+ }
1012
+ updateStartedRef.current = true;
1013
+ emit("start", "update");
1014
+ if (updateKeys.length === 0) {
1015
+ updateStartedRef.current = false;
1016
+ emit("end", "update", true);
1017
+ }
1018
+ }, [updateStyle, shouldRegisterUpdate]);
1019
+ import_react.default.useEffect(function() {
1020
+ if (!justStartedExiting || !sendExitComplete) return;
1021
+ if (enterStartedRef.current) {
1022
+ enterStartedRef.current = false;
1023
+ emit("end", "enter", false);
1024
+ }
1025
+ if (updateStartedRef.current) {
1026
+ updateStartedRef.current = false;
1027
+ emit("end", "update", false);
1028
+ }
1029
+ if (onTransitionRef.current && !exitStartedRef.current) {
1030
+ exitStartedRef.current = true;
1031
+ emit("start", "exit");
1032
+ }
1033
+ if (!exitKeysRegistered.current && pendingExitKeysRef.current.size === 0) {
1034
+ if (!exitCompletedRef.current) {
1035
+ exitCompletedRef.current = true;
1036
+ if (exitStartedRef.current) {
1037
+ exitStartedRef.current = false;
1038
+ emit("end", "exit", true);
1039
+ }
1040
+ sendExitComplete();
1041
+ }
1042
+ }
1043
+ }, [justStartedExiting, sendExitComplete]);
1044
+ import_react.default.useEffect(function() {
1045
+ if (isExiting || !justFinishedEntering || !onTransition) return;
1046
+ if (!enterStartedRef.current) {
1047
+ enterStartedRef.current = true;
1048
+ emit("start", "enter");
1049
+ }
1050
+ if (!enterKeysRegistered.current && pendingEnterKeysRef.current.size === 0) {
1051
+ if (!enterCompletedRef.current) {
1052
+ enterCompletedRef.current = true;
1053
+ if (enterStartedRef.current) {
1054
+ enterStartedRef.current = false;
1055
+ emit("end", "enter", true);
1056
+ }
1057
+ }
1058
+ }
1059
+ }, [
1060
+ isExiting,
1061
+ justFinishedEntering,
1062
+ onTransition
1063
+ ]);
1064
+ var mapperStateRef = (0, import_react_native_reanimated.useSharedValue)({ emitted: {} });
1065
+ var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function() {
1066
+ "worklet";
1067
+ var mapperState = mapperStateRef.value;
1068
+ var config = configRef.value;
1069
+ if (config.disableAnimation || config.isHydrating) {
1070
+ updateMapperState(mapperStateRef, {});
1071
+ return {};
1072
+ }
1073
+ var previouslyEmitted = mapperState.emitted;
1074
+ var emitted = {};
1075
+ var result = {};
1076
+ var emitterSnapshot = emitterSnapshotRef.value;
1077
+ var snapshot = emitterSnapshot !== null && emitterSnapshot !== void 0 ? emitterSnapshot : renderSnapshotRef.value;
1078
+ var animatedValues = snapshot.animated;
1079
+ var staticValues = snapshot.statics;
1080
+ var currentlyExiting = isExitingRef.value;
1081
+ var currentCycleId = exitCycleIdShared.value;
1082
+ var currentlyCompletingEnter = isCompletingEnterRef.value;
1083
+ var currentEnterCycleId = enterCycleIdShared.value;
1084
+ var currentlyCompletingUpdate = isCompletingUpdateRef.value;
1085
+ var currentUpdateCycleId = updateCycleIdShared.value;
1086
+ for (var key in staticValues) {
1087
+ result[key] = staticValues[key];
1088
+ }
1089
+ for (var key1 in snapshot.removedKeys) {
1090
+ if (!key1.startsWith("transform:") && !(key1 in staticValues)) {
1091
+ result[key1] = snapshot.clearValue;
1092
+ }
1093
+ }
1094
+ for (var key2 in animatedValues) {
1095
+ if (key2 === "transform") continue;
1096
+ var targetValue = animatedValues[key2];
1097
+ emitted[key2] = true;
1098
+ if (typeof targetValue !== "number" && typeof targetValue !== "string") {
1099
+ result[key2] = targetValue;
1100
+ continue;
1101
+ }
1102
+ var _config_propertyConfigs_key;
1103
+ result[key2] = animateSnapshotValue(key2, key2, targetValue, (_config_propertyConfigs_key = config.propertyConfigs[key2]) !== null && _config_propertyConfigs_key !== void 0 ? _config_propertyConfigs_key : config.baseConfig, !!previouslyEmitted[key2], snapshot.seeds[key2], !!snapshot.gatedKeys[key2], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone, !!COLOR_STYLE_KEYS[key2]);
1104
+ }
1105
+ var transforms = snapshot.transforms;
1106
+ if (transforms.length > 0 || snapshot.removeTransform) {
1107
+ var validTransforms = [];
1108
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
1109
+ try {
1110
+ for (var _iterator = transforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1111
+ var t = _step.value;
1112
+ if (!t) continue;
1113
+ var keys = Object.keys(t);
1114
+ if (keys.length === 0) continue;
1115
+ var transformKey = keys[0];
1116
+ var value = t[transformKey];
1117
+ if (typeof value === "number" || typeof value === "string") {
1118
+ var _config_propertyConfigs_transformKey;
1119
+ var propConfig = (_config_propertyConfigs_transformKey = config.propertyConfigs[transformKey]) !== null && _config_propertyConfigs_transformKey !== void 0 ? _config_propertyConfigs_transformKey : config.baseConfig;
1120
+ var subKey = `transform:${transformKey}`;
1121
+ emitted[subKey] = true;
1122
+ validTransforms.push({ [transformKey]: animateSnapshotValue(subKey, transformKey, value, propConfig, !!previouslyEmitted[subKey], snapshot.seeds[subKey], !!snapshot.gatedKeys[subKey], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone) });
1123
+ } else {
1124
+ validTransforms.push(t);
1125
+ }
1126
+ }
1127
+ } catch (err) {
1128
+ _didIteratorError = true;
1129
+ _iteratorError = err;
1130
+ } finally {
1131
+ try {
1132
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1133
+ _iterator.return();
1134
+ }
1135
+ } finally {
1136
+ if (_didIteratorError) {
1137
+ throw _iteratorError;
1138
+ }
1139
+ }
1140
+ }
1141
+ if (validTransforms.length > 0 || !("transform" in staticValues)) {
1142
+ result.transform = validTransforms;
1143
+ }
1144
+ }
1145
+ updateMapperState(mapperStateRef, emitted);
1146
+ return result;
1147
+ }, import_core.isWeb ? [
1148
+ renderSnapshotRef,
1149
+ emitterSnapshotRef,
1150
+ configRef,
1151
+ isExitingRef,
1152
+ exitCycleIdShared,
1153
+ markExitKeyDone,
1154
+ isCompletingEnterRef,
1155
+ enterCycleIdShared,
1156
+ markEnterKeyDone,
1157
+ isCompletingUpdateRef,
1158
+ updateCycleIdShared,
1159
+ markUpdateKeyDone
1160
+ ] : void 0);
1161
+ silenceAnimatedComponentDevCheck(animatedStyle);
1162
+ if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
1163
+ console.info("[animations-reanimated] useAnimations", {
1164
+ resolvedTransition,
1165
+ componentState,
1166
+ isExiting,
1167
+ animatedStyles,
1168
+ staticStyles,
1169
+ baseConfig,
1170
+ propertyConfigs
1171
+ });
1172
+ }
1173
+ return { style: [staticStyles, animatedStyle] };
1174
+ }
1175
+ };
1176
+ }