{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","dispatchCommand","dispatchCommandFabric","animatedRef","commandName","args","arguments","length","undefined","_WORKLET","shadowNodeWrapper","_dispatchCommandFabric","dispatchCommandPaper","viewTag","_dispatchCommandPaper","dispatchCommandJest","console","warn","dispatchCommandChromeDebugger","dispatchCommandDefault"],"sources":["dispatchCommand.ts"],"sourcesContent":["'use strict';\nimport type { ShadowNodeWrapper } from '../commonTypes';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport type {\n AnimatedRef,\n AnimatedRefOnJS,\n AnimatedRefOnUI,\n} from '../hook/commonTypes';\nimport type { Component } from 'react';\n\ntype DispatchCommand = (\n animatedRef: AnimatedRef,\n commandName: string,\n args?: unknown[]\n) => void;\n\n/**\n * Lets you synchronously call a command of a native component.\n *\n * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef#returns) connected to the component you'd want to call the command on.\n * @param commandName - The name of the command to dispatch (e.g. `\"focus\"` or `\"scrollToEnd\"`).\n * @param args - An optional array of arguments for the command.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/dispatchCommand\n */\nexport let dispatchCommand: DispatchCommand;\n\nfunction dispatchCommandFabric(\n animatedRef: AnimatedRefOnJS | AnimatedRefOnUI,\n commandName: string,\n args: Array = []\n) {\n 'worklet';\n if (!_WORKLET) {\n return;\n }\n\n const shadowNodeWrapper = animatedRef() as ShadowNodeWrapper;\n _dispatchCommandFabric!(shadowNodeWrapper, commandName, args);\n}\n\nfunction dispatchCommandPaper(\n animatedRef: AnimatedRefOnJS | AnimatedRefOnUI,\n commandName: string,\n args: Array = []\n) {\n 'worklet';\n if (!_WORKLET) {\n return;\n }\n\n const viewTag = animatedRef() as number;\n _dispatchCommandPaper!(viewTag, commandName, args);\n}\n\nfunction dispatchCommandJest() {\n console.warn('[Reanimated] dispatchCommand() is not supported with Jest.');\n}\n\nfunction dispatchCommandChromeDebugger() {\n console.warn(\n '[Reanimated] dispatchCommand() is not supported with Chrome Debugger.'\n );\n}\n\nfunction dispatchCommandDefault() {\n console.warn(\n '[Reanimated] dispatchCommand() is not supported on this configuration.'\n );\n}\n\nif (!shouldBeUseWeb()) {\n // Those assertions are actually correct since on Native platforms `AnimatedRef` is\n // mapped as a different function in `shareableMappingCache` and\n // TypeScript is not able to infer that.\n if (isFabric()) {\n dispatchCommand = dispatchCommandFabric as unknown as DispatchCommand;\n } else {\n dispatchCommand = dispatchCommandPaper as unknown as DispatchCommand;\n }\n} else if (isJest()) {\n dispatchCommand = dispatchCommandJest;\n} else if (isChromeDebugger()) {\n dispatchCommand = dispatchCommandChromeDebugger;\n} else {\n dispatchCommand = dispatchCommandDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAc3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIC,eAAgC;AAE3C,SAASC,qBAAqBA,CAC5BC,WAA8C,EAC9CC,WAAmB,EAEnB;EACA,SAAS;;EAAC,IAFVC,IAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAGzB,IAAI,CAACG,QAAQ,EAAE;IACb;EACF;EAEA,MAAMC,iBAAiB,GAAGP,WAAW,EAAuB;EAC5DQ,sBAAsB,CAAED,iBAAiB,EAAEN,WAAW,EAAEC,IAAI,CAAC;AAC/D;AAEA,SAASO,oBAAoBA,CAC3BT,WAA8C,EAC9CC,WAAmB,EAEnB;EACA,SAAS;;EAAC,IAFVC,IAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAGzB,IAAI,CAACG,QAAQ,EAAE;IACb;EACF;EAEA,MAAMI,OAAO,GAAGV,WAAW,EAAY;EACvCW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