{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","processColorsInProps","setNativeProps","setNativePropsFabric","animatedRef","updates","_WORKLET","console","warn","shadowNodeWrapper","_updatePropsFabric","setNativePropsPaper","tag","name","viewName","value","_updatePropsPaper","setNativePropsJest","setNativePropsChromeDebugger","setNativePropsDefault"],"sources":["setNativeProps.ts"],"sourcesContent":["'use strict';\nimport type { ShadowNodeWrapper, StyleProps } 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';\nimport { processColorsInProps } from '../Colors';\n\ntype SetNativeProps = (\n animatedRef: AnimatedRef,\n updates: StyleProps\n) => void;\n/**\n * Lets you imperatively update component properties. You should always reach for [useAnimatedStyle](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle) and [useAnimatedProps](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedProps) first when animating styles or properties.\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 update.\n * @param updates - An object with properties you want to update.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/setNativeProps\n */\nexport let setNativeProps: SetNativeProps;\n\nfunction setNativePropsFabric(\n animatedRef: AnimatedRefOnJS | AnimatedRefOnUI,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const shadowNodeWrapper = animatedRef() as ShadowNodeWrapper;\n processColorsInProps(updates);\n _updatePropsFabric!([{ shadowNodeWrapper, updates }]);\n}\n\nfunction setNativePropsPaper(\n animatedRef: AnimatedRefOnJS | AnimatedRefOnUI,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const tag = animatedRef() as number;\n const name = (animatedRef as AnimatedRefOnUI).viewName.value;\n processColorsInProps(updates);\n _updatePropsPaper!([{ tag, name, updates }]);\n}\n\nfunction setNativePropsJest() {\n console.warn('[Reanimated] setNativeProps() is not supported with Jest.');\n}\n\nfunction setNativePropsChromeDebugger() {\n console.warn(\n '[Reanimated] setNativeProps() is not supported with Chrome Debugger.'\n );\n}\n\nfunction setNativePropsDefault() {\n console.warn(\n '[Reanimated] setNativeProps() 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 setNativeProps = setNativePropsFabric as unknown as SetNativeProps;\n } else {\n setNativeProps = setNativePropsPaper as unknown as SetNativeProps;\n }\n} else if (isJest()) {\n setNativeProps = setNativePropsJest;\n} else if (isChromeDebugger()) {\n setNativeProps = setNativePropsChromeDebugger;\n} else {\n setNativeProps = setNativePropsDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAO3B,SAASC,oBAAoB,QAAQ,WAAW;AAMhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIC,cAA8B;AAEzC,SAASC,oBAAoBA,CAC3BC,WAA8C,EAC9CC,OAAmB,EACnB;EACA,SAAS;;EACT,IAAI,CAACC,QAAQ,EAAE;IACbC,OAAO,CAACC,IAAI,CACV,mEAAmE,CACpE;IACD;EACF;EACA,MAAMC,iBAAiB,GAAGL,WAAW,EAAuB;EAC5DH,oBAAoB,CAACI,OAAO,CAAC;EAC7BK,kBAAkB,CAAE,CAAC;IAAED,iBAAiB;IAAEJ;EAAQ,CAAC,CAAC,CAAC;AACvD;AAEA,SAASM,mBAAmBA,CAC1BP,WAA8C,EAC9CC,OAAmB,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