// Metro module 384 (f385). import _classCallCheck from "./_classCallCheck"; import _createClass from "./_createClass"; import AnimatedValue from "./AnimatedValue"; import AnimatedValueXY from "./AnimatedValueXY"; import Module38 from "./Module38"; import { findNodeHandle } from "./Module114"; import Module357 from "./Module357"; function $mk66464($env) { return (a0, a1) => { const r4 = $env; const r5 = $env.$parent; const r6 = r5[1]; const r14 = r5[2]; if (a0 instanceof r6(r14[2])) { a0.__makeNative(r4[1]); r4[2].push({ nativeEventPath: a1, animatedValueTag: a0.__getNativeTag() }); } else if (a0 instanceof r6(r14[3])) { const r24 = r4[3]; r24(a0.x, a1.concat("x")); r24(a0.y, a1.concat("y")); } else if (typeof a0 === "object") { for (const key in a0) { (0, r4[3])(a0[key], a1.concat(key)); } } }; } function $mk66465($env) { return (a0) => { const r1 = $env; const r2 = $env.$parent; (0, r2[1])(r2[2][6]).API.addAnimatedEventToView(r1[4], r1[0], a0); }; } function $mk66466($env) { return () => { const r1 = $env; if (r1[4] != null) { r1[2].forEach($mk101222(r1)); } }; } function $mk101222($env) { return (a0) => { const r1 = $env; const r2 = $env.$parent; (0, r2[1])(r2[2][6]).API.removeAnimatedEventFromView(r1[4], r1[0], a0.animatedValueTag); }; } let env412 = {}; const AnimatedEvent = function AnimatedEvent(a0, a1) { const _this = this; let r2 = a1; _classCallCheck(this, AnimatedEvent); this._listeners = []; this._callListeners = function(...c28648_0) { _this._listeners.forEach((_listener) => _listener.apply(void 0, [...c28648_0])); }; this._argMapping = a0; if (a1 == null) { console.warn("Animated.event now requires a second argument for options"); r2 = { useNativeDriver: false }; } if (r2.listener) { this.__addListener(r2.listener); } this._attachedEvent = null; this.__isNative = Module357.shouldUseNativeDriver(r2); this.__platformConfig = r2.platformConfig; }; const r29 = _createClass(AnimatedEvent, [{ key: "__addListener", value: function __addListener(a0) { this._listeners.push(a0); } }, { key: "__removeListener", value: function __removeListener(c23759_0) { this._listeners = this._listeners.filter((_listener) => _listener !== c23759_0); } }, { key: "__attach", value: function __attach(a0, a1) { let env23760; Module38(this.__isNative, "Only native driven events need to be attached."); const _argMapping = this._argMapping; const __platformConfig = this.__platformConfig; const r16 = env23760 = { $parent: env412 }; env23760[0] = a1; env23760[1] = __platformConfig; env23760[4] = void 0; const r18 = []; env23760[2] = r18; const r10 = $mk66464(r16); env23760[3] = r10; Module38(_argMapping[0] && _argMapping[0].nativeEvent, "Native driven events only support animated values contained inside `nativeEvent`."); r10(_argMapping[0].nativeEvent, []); const r31 = findNodeHandle(a0); env23760[4] = r31; if (r31 != null) { r18.forEach($mk66465(r16)); } this._attachedEvent = { detach: $mk66466(r16) }; } }, { key: "__detach", value: function __detach(a0, a1) { Module38(this.__isNative, "Only native driven events need to be detached."); if (this._attachedEvent) { this._attachedEvent.detach(); } } }, { key: "__getHandler", value: function __getHandler() { const _this2 = this; if (this.__isNative) { return this._callListeners; } return function(...args) { let c28649_0 = args; const traverse2 = (a0, a1) => { if (a0 instanceof AnimatedValue) { if (typeof a1 === "number") { a0.setValue(a1); } } else if (a0 instanceof AnimatedValueXY) { if (typeof a1 === "object") { traverse2(a0.x, a1.x); traverse2(a0.y, a1.y); } } else if (typeof a0 === "object") { for (const key in a0) { traverse2(a0[key], a1[key]); } } }; _this2._argMapping.forEach((item, index) => { const r24 = c28649_0[index]; if (item instanceof AnimatedValue) { if (typeof r24 === "number") { item.setValue(r24); } } else if (item instanceof AnimatedValueXY) { if (typeof r24 === "object") { const r51 = item.x; const r52 = r24.x; if (r51 instanceof AnimatedValue) { if (typeof r52 === "number") { r51.setValue(r52); } } else if (r51 instanceof AnimatedValueXY) { if (typeof r52 === "object") { traverse2(r51.x, r52.x); traverse2(r51.y, r52.y); } } else if (typeof r51 === "object") { for (const key3 in r51) { traverse2(r51[key3], r52[key3]); } } const r80 = item.y; const r81 = r24.y; if (r80 instanceof AnimatedValue) { if (typeof r81 === "number") { r80.setValue(r81); } } else if (r80 instanceof AnimatedValueXY) { if (typeof r81 === "object") { traverse2(r80.x, r81.x); traverse2(r80.y, r81.y); } } else if (typeof r80 === "object") { for (const key4 in r80) { const r96 = key4; traverse2(r80[r96], r81[r96]); } } } } else if (typeof item === "object") { for (const key in item) { const r18 = item[key]; const r17 = r24[key]; if (r18 instanceof AnimatedValue) { if (typeof r17 === "number") { r18.setValue(r17); } } else if (r18 instanceof AnimatedValueXY) { if (typeof r17 === "object") { traverse2(r18.x, r17.x); traverse2(r18.y, r17.y); } } else if (typeof r18 === "object") { for (const key2 in r18) { traverse2(r18[key2], r17[key2]); } } } } }); _this2._callListeners.apply(_this2, [...args]); }; } }]); export function attachNativeEventImpl(a0, a1, a2, a3) { let env12296; const r3 = env12296 = { $parent: env412 }; env12296[0] = a1; env12296[1] = a3; const r5 = []; env12296[2] = r5; const r9 = $mk66464(r3); env12296[3] = r9; Module38(a2[0] && a2[0].nativeEvent, "Native driven events only support animated values contained inside `nativeEvent`."); r9(a2[0].nativeEvent, []); const r25 = findNodeHandle(a0); env12296[4] = r25; if (r25 != null) { r5.forEach($mk66465(r3)); } return { detach: $mk66466(r3) }; } export { r29 as AnimatedEvent };