\n): React.ComponentType {\n function Wrapper(props: P) {\n return (\n \n \n \n );\n }\n\n Wrapper.displayName = `gestureHandlerRootHOC(${\n Component.displayName || Component.name\n })`;\n\n hoistNonReactStatics(Wrapper, Component);\n\n return Wrapper;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n","import Hammer from '@egjs/hammerjs';\nimport { HammerInputExt } from './GestureHandler';\n\nimport IndiscreteGestureHandler from './IndiscreteGestureHandler';\n\nclass PinchGestureHandler extends IndiscreteGestureHandler {\n get name() {\n return 'pinch';\n }\n\n get NativeGestureClass() {\n return Hammer.Pinch;\n }\n\n transformNativeEvent({ scale, velocity, center }: HammerInputExt) {\n return {\n focalX: center.x,\n focalY: center.y,\n velocity,\n scale,\n };\n }\n}\n\nexport default PinchGestureHandler;\n","import Hammer from '@egjs/hammerjs';\n\nimport { DEG_RAD } from './constants';\nimport { HammerInputExt } from './GestureHandler';\nimport IndiscreteGestureHandler from './IndiscreteGestureHandler';\n\nclass RotationGestureHandler extends IndiscreteGestureHandler {\n get name() {\n return 'rotate';\n }\n\n get NativeGestureClass() {\n return Hammer.Rotate;\n }\n\n transformNativeEvent({ rotation, velocity, center }: HammerInputExt) {\n return {\n rotation: (rotation - (this.initialRotation ?? 0)) * DEG_RAD,\n anchorX: center.x,\n anchorY: center.y,\n velocity,\n };\n }\n}\nexport default RotationGestureHandler;\n","import DiscreteGestureHandler from './DiscreteGestureHandler';\nimport { HammerInputExt } from './GestureHandler';\nimport * as NodeManager from './NodeManager';\nimport PressGestureHandler from './PressGestureHandler';\nimport { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';\n\nclass NativeViewGestureHandler extends PressGestureHandler {\n onRawEvent(ev: HammerInputExt) {\n super.onRawEvent(ev);\n if (!ev.isFinal) {\n // if (this.ref instanceof ScrollView) {\n if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {\n // @ts-ignore FIXME(TS) config type\n if (this.config.disallowInterruption) {\n const gestures = Object.values(NodeManager.getNodes()).filter(\n (gesture) => {\n const { handlerTag, view, isGestureRunning } = gesture;\n return (\n // Check if this gesture isn't self\n handlerTag !== this.handlerTag &&\n // Ensure the gesture needs to be cancelled\n isGestureRunning &&\n // ScrollView can cancel discrete gestures like taps and presses\n gesture instanceof DiscreteGestureHandler &&\n // Ensure a view exists and is a child of the current view\n view &&\n // @ts-ignore FIXME(TS) view type\n this.view.contains(view)\n );\n }\n );\n // Cancel all of the gestures that passed the filter\n for (const gesture of gestures) {\n // TODO: Bacon: Send some cached event.\n gesture.forceInvalidate(ev);\n }\n }\n }\n }\n }\n}\n\nexport default NativeViewGestureHandler;\n","import * as React from 'react';\nimport { useImperativeHandle, useRef } from 'react';\n\nimport {\n NativeViewGestureHandler,\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from './NativeViewGestureHandler';\n\n/*\n * This array should consist of:\n * - All keys in propTypes from NativeGestureHandler\n * (and all keys in GestureHandlerPropTypes)\n * - 'onGestureHandlerEvent'\n * - 'onGestureHandlerStateChange'\n */\nconst NATIVE_WRAPPER_PROPS_FILTER = [\n ...nativeViewProps,\n 'onGestureHandlerEvent',\n 'onGestureHandlerStateChange',\n] as const;\n\nexport default function createNativeWrapper
(\n Component: React.ComponentType
,\n config: Readonly = {}\n) {\n const ComponentWrapper = React.forwardRef<\n React.ComponentType,\n P & NativeViewGestureHandlerProps\n >((props, ref) => {\n // filter out props that should be passed to gesture handler wrapper\n const gestureHandlerProps = Object.keys(props).reduce(\n (res, key) => {\n // TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info\n const allowedKeys: readonly string[] = NATIVE_WRAPPER_PROPS_FILTER;\n if (allowedKeys.includes(key)) {\n // @ts-ignore FIXME(TS)\n res[key] = props[key];\n }\n return res;\n },\n { ...config } // watch out not to modify config\n );\n const _ref = useRef>();\n const _gestureHandlerRef = useRef>();\n useImperativeHandle(\n ref,\n // @ts-ignore TODO(TS) decide how nulls work in this context\n () => {\n const node = _gestureHandlerRef.current;\n // add handlerTag for relations config\n if (_ref.current && node) {\n // @ts-ignore FIXME(TS) think about createHandler return type\n _ref.current.handlerTag = node.handlerTag;\n return _ref.current;\n }\n return null;\n },\n [_ref, _gestureHandlerRef]\n );\n return (\n \n \n \n );\n });\n\n ComponentWrapper.displayName = Component.displayName || 'ComponentWrapper';\n\n return ComponentWrapper;\n}\n","import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n FlingGestureConfig,\n FlingGestureHandlerEventPayload,\n} from '../FlingGestureHandler';\n\nexport class FlingGesture extends BaseGesture {\n public config: BaseGestureConfig & FlingGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'FlingGestureHandler';\n }\n\n numberOfPointers(pointers: number) {\n this.config.numberOfPointers = pointers;\n return this;\n }\n\n direction(direction: number) {\n this.config.direction = direction;\n return this;\n }\n}\n\nexport type FlingGestureType = InstanceType;\n","import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport {\n ForceTouchGestureConfig,\n ForceTouchGestureHandlerEventPayload,\n} from '../ForceTouchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype ForceTouchGestureChangeEventPayload = {\n forceChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent,\n previous?: GestureUpdateEvent\n) {\n 'worklet';\n let changePayload: ForceTouchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n forceChange: current.force,\n };\n } else {\n changePayload = {\n forceChange: current.force - previous.force,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class ForceTouchGesture extends ContinousBaseGesture<\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & ForceTouchGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'ForceTouchGestureHandler';\n }\n\n minForce(force: number) {\n this.config.minForce = force;\n return this;\n }\n\n maxForce(force: number) {\n this.config.maxForce = force;\n return this;\n }\n\n feedbackOnActivation(value: boolean) {\n this.config.feedbackOnActivation = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n GestureUpdateEvent<\n ForceTouchGestureHandlerEventPayload &\n ForceTouchGestureChangeEventPayload\n >\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ForceTouchGestureType = InstanceType;\n","import { BaseGesture, Gesture, GestureRef, GestureType } from './gesture';\n\nfunction extendRelation(\n currentRelation: GestureRef[] | undefined,\n extendWith: GestureType[]\n) {\n if (currentRelation === undefined) {\n return [...extendWith];\n } else {\n return [...currentRelation, ...extendWith];\n }\n}\n\nexport class ComposedGesture extends Gesture {\n protected gestures: Gesture[] = [];\n protected simultaneousGestures: GestureType[] = [];\n protected requireGesturesToFail: GestureType[] = [];\n\n constructor(...gestures: Gesture[]) {\n super();\n this.gestures = gestures;\n }\n\n protected prepareSingleGesture(\n gesture: Gesture,\n simultaneousGestures: GestureType[],\n requireGesturesToFail: GestureType[]\n ) {\n if (gesture instanceof BaseGesture) {\n const newConfig = { ...gesture.config };\n\n newConfig.simultaneousWith = extendRelation(\n newConfig.simultaneousWith,\n simultaneousGestures\n );\n newConfig.requireToFail = extendRelation(\n newConfig.requireToFail,\n requireGesturesToFail\n );\n\n gesture.config = newConfig;\n } else if (gesture instanceof ComposedGesture) {\n gesture.simultaneousGestures = simultaneousGestures;\n gesture.requireGesturesToFail = requireGesturesToFail;\n gesture.prepare();\n }\n }\n\n prepare() {\n for (const gesture of this.gestures) {\n this.prepareSingleGesture(\n gesture,\n this.simultaneousGestures,\n this.requireGesturesToFail\n );\n }\n }\n\n initialize() {\n for (const gesture of this.gestures) {\n gesture.initialize();\n }\n }\n\n toGestureArray(): GestureType[] {\n return this.gestures.flatMap((gesture) => gesture.toGestureArray());\n }\n}\n\nexport class SimultaneousGesture extends ComposedGesture {\n prepare() {\n const simultaneousArray = this.gestures\n .flatMap((gesture) => gesture.toGestureArray())\n .concat(this.simultaneousGestures);\n\n for (const gesture of this.gestures) {\n this.prepareSingleGesture(\n gesture,\n simultaneousArray,\n this.requireGesturesToFail\n );\n }\n }\n}\n\nexport class ExclusiveGesture extends ComposedGesture {\n prepare() {\n const gestureArrays = this.gestures.map((gesture) =>\n gesture.toGestureArray()\n );\n\n let requireToFail: GestureType[] = [];\n\n for (let i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(\n this.gestures[i],\n this.simultaneousGestures,\n this.requireGesturesToFail.concat(requireToFail)\n );\n\n requireToFail = requireToFail.concat(gestureArrays[i]);\n }\n }\n}\n\nexport type ComposedGestureType = InstanceType;\nexport type RaceGestureType = ComposedGestureType;\nexport type SimultaneousGestureType = InstanceType;\nexport type ExclusiveGestureType = InstanceType;\n","import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n }\n\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType;\n","import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport {\n PanGestureConfig,\n PanGestureHandlerEventPayload,\n} from '../PanGestureHandler';\n\ntype PanGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent,\n previous?: GestureUpdateEvent\n) {\n 'worklet';\n let changePayload: PanGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.translationX,\n changeY: current.translationY,\n };\n } else {\n changePayload = {\n changeX: current.translationX - previous.translationX,\n changeY: current.translationY - previous.translationY,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PanGesture extends ContinousBaseGesture<\n PanGestureHandlerEventPayload,\n PanGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & PanGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'PanGestureHandler';\n }\n\n activeOffsetY(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.activeOffsetYStart = offset[0];\n this.config.activeOffsetYEnd = offset[1];\n } else if (offset < 0) {\n this.config.activeOffsetYStart = offset;\n } else {\n this.config.activeOffsetYEnd = offset;\n }\n return this;\n }\n\n activeOffsetX(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.activeOffsetXStart = offset[0];\n this.config.activeOffsetXEnd = offset[1];\n } else if (offset < 0) {\n this.config.activeOffsetXStart = offset;\n } else {\n this.config.activeOffsetXEnd = offset;\n }\n return this;\n }\n\n failOffsetY(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.failOffsetYStart = offset[0];\n this.config.failOffsetYEnd = offset[1];\n } else if (offset < 0) {\n this.config.failOffsetYStart = offset;\n } else {\n this.config.failOffsetYEnd = offset;\n }\n return this;\n }\n\n failOffsetX(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.failOffsetXStart = offset[0];\n this.config.failOffsetXEnd = offset[1];\n } else if (offset < 0) {\n this.config.failOffsetXStart = offset;\n } else {\n this.config.failOffsetXEnd = offset;\n }\n return this;\n }\n\n minPointers(minPointers: number) {\n this.config.minPointers = minPointers;\n return this;\n }\n\n maxPointers(maxPointers: number) {\n this.config.maxPointers = maxPointers;\n return this;\n }\n\n minDistance(distance: number) {\n this.config.minDist = distance;\n return this;\n }\n\n minVelocity(velocity: number) {\n this.config.minVelocity = velocity;\n return this;\n }\n\n minVelocityX(velocity: number) {\n this.config.minVelocityX = velocity;\n return this;\n }\n\n minVelocityY(velocity: number) {\n this.config.minVelocityY = velocity;\n return this;\n }\n\n averageTouches(value: boolean) {\n this.config.avgTouches = value;\n return this;\n }\n\n enableTrackpadTwoFingerGesture(value: boolean) {\n this.config.enableTrackpadTwoFingerGesture = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PanGestureHandlerEventPayload & PanGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PanGestureType = InstanceType;\n","import { ContinousBaseGesture } from './gesture';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype PinchGestureChangeEventPayload = {\n scaleChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent,\n previous?: GestureUpdateEvent\n) {\n 'worklet';\n let changePayload: PinchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n scaleChange: current.scale,\n };\n } else {\n changePayload = {\n scaleChange: current.scale / previous.scale,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PinchGesture extends ContinousBaseGesture<\n PinchGestureHandlerEventPayload,\n PinchGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'PinchGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PinchGestureType = InstanceType;\n","import { ContinousBaseGesture } from './gesture';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype RotationGestureChangeEventPayload = {\n rotationChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent,\n previous?: GestureUpdateEvent\n) {\n 'worklet';\n let changePayload: RotationGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n rotationChange: current.rotation,\n };\n } else {\n changePayload = {\n rotationChange: current.rotation - previous.rotation,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class RotationGesture extends ContinousBaseGesture<\n RotationGestureHandlerEventPayload,\n RotationGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'RotationGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type RotationGestureType = InstanceType;\n","import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n TapGestureConfig,\n TapGestureHandlerEventPayload,\n} from '../TapGestureHandler';\n\nexport class TapGesture extends BaseGesture {\n public config: BaseGestureConfig & TapGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'TapGestureHandler';\n }\n\n minPointers(minPointers: number) {\n this.config.minPointers = minPointers;\n return this;\n }\n\n numberOfTaps(count: number) {\n this.config.numberOfTaps = count;\n return this;\n }\n\n maxDistance(maxDist: number) {\n this.config.maxDist = maxDist;\n return this;\n }\n\n maxDuration(duration: number) {\n this.config.maxDurationMs = duration;\n return this;\n }\n\n maxDelay(delay: number) {\n this.config.maxDelayMs = delay;\n return this;\n }\n\n maxDeltaX(delta: number) {\n this.config.maxDeltaX = delta;\n return this;\n }\n\n maxDeltaY(delta: number) {\n this.config.maxDeltaY = delta;\n return this;\n }\n}\n\nexport type TapGestureType = InstanceType;\n","import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n NativeViewGestureConfig,\n NativeViewGestureHandlerPayload,\n} from '../NativeViewGestureHandler';\n\nexport class NativeGesture extends BaseGesture {\n public config: BaseGestureConfig & NativeViewGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'NativeViewGestureHandler';\n }\n\n shouldActivateOnStart(value: boolean) {\n this.config.shouldActivateOnStart = value;\n return this;\n }\n\n disallowInterruption(value: boolean) {\n this.config.disallowInterruption = value;\n return this;\n }\n}\n\nexport type NativeGestureType = InstanceType;\n","import { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport { ContinousBaseGesture } from './gesture';\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent>,\n _previous?: GestureUpdateEvent>\n) {\n 'worklet';\n return current;\n}\n\nexport class ManualGesture extends ContinousBaseGesture<\n Record,\n Record\n> {\n constructor() {\n super();\n\n this.handlerName = 'ManualGestureHandler';\n }\n\n onChange(\n callback: (event: GestureUpdateEvent>) => void\n ) {\n // @ts-ignore TS being overprotective, Record is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ManualGestureType = InstanceType;\n","import * as React from 'react';\nimport { View } from 'react-native';\n\nexport default React.forwardRef((props, ref) => (\n \n));\n","import * as React from 'react';\nimport {\n Animated,\n Platform,\n processColor,\n StyleSheet,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from '../handlers/NativeViewGestureHandler';\n\nexport interface RawButtonProps extends NativeViewGestureHandlerProps {\n /**\n * Defines if more than one button could be pressed simultaneously. By default\n * set true.\n */\n exclusive?: boolean;\n // TODO: we should transform props in `createNativeWrapper`\n\n /**\n * Android only.\n *\n * Defines color of native ripple animation used since API level 21.\n */\n rippleColor?: any; // it was present in BaseButtonProps before but is used here in code\n}\n\nexport interface BaseButtonProps extends RawButtonProps {\n /**\n * Called when the button gets pressed (analogous to `onPress` in\n * `TouchableHighlight` from RN core).\n */\n onPress?: (pointerInside: boolean) => void;\n\n /**\n * Called when button changes from inactive to active and vice versa. It\n * passes active state as a boolean variable as a first parameter for that\n * method.\n */\n onActiveStateChange?: (active: boolean) => void;\n style?: StyleProp;\n testID?: string;\n}\n\nexport interface RectButtonProps extends BaseButtonProps {\n /**\n * Background color that will be dimmed when button is in active state.\n */\n underlayColor?: string;\n\n /**\n * iOS only.\n *\n * Opacity applied to the underlay when button is in active state.\n */\n activeOpacity?: number;\n}\n\nexport interface BorderlessButtonProps extends BaseButtonProps {\n /**\n * Android only.\n *\n * Set this to false if you want the ripple animation to render only within view bounds.\n */\n borderless?: boolean;\n\n /**\n * iOS only.\n *\n * Opacity applied to the button when it is in an active state.\n */\n activeOpacity?: number;\n}\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nexport class BaseButton extends React.Component {\n private lastActive: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n this.lastActive = active;\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, ...rest } = this.props;\n\n return (\n \n );\n }\n}\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nexport class RectButton extends React.Component {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n \n \n {children}\n \n );\n }\n}\n\nexport class BorderlessButton extends React.Component {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n return (\n \n {children}\n \n );\n }\n}\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n","import { TouchableNativeFeedback } from 'react-native';\n\nexport default TouchableNativeFeedback;\n","import * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n Platform,\n StyleProp,\n ViewStyle,\n TouchableWithoutFeedbackProps,\n} from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport { NativeViewGestureHandlerPayload } from '../../handlers/NativeViewGestureHandler';\nimport { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n UNDETERMINED: 0,\n BEGAN: 1,\n MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];\n\nexport interface GenericTouchableProps extends TouchableWithoutFeedbackProps {\n // Decided to drop not used fields from RN's implementation.\n // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment\n\n // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too\n onPress?: () => void;\n onPressIn?: () => void;\n onPressOut?: () => void;\n onLongPress?: () => void;\n\n nativeID?: string;\n shouldActivateOnStart?: boolean;\n disallowInterruption?: boolean;\n\n containerStyle?: StyleProp;\n}\n\ninterface InternalProps {\n extraButtonProps: TouchableNativeFeedbackExtraProps;\n onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n GenericTouchableProps & InternalProps\n> {\n static defaultProps = {\n delayLongPress: 600,\n extraButtonProps: {\n rippleColor: 'transparent',\n exclusive: true,\n },\n };\n\n // timeout handlers\n pressInTimeout: Timeout;\n pressOutTimeout: Timeout;\n longPressTimeout: Timeout;\n\n // This flag is required since recognition of longPress implies not-invoking onPress\n longPressDetected = false;\n\n pointerInside = true;\n\n // State of touchable\n STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n // handlePressIn in called on first touch on traveling inside component.\n // Handles state transition with delay.\n handlePressIn() {\n if (this.props.delayPressIn) {\n this.pressInTimeout = setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n this.pressInTimeout = null;\n }, this.props.delayPressIn);\n } else {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n if (this.props.onLongPress) {\n const time =\n (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n }\n }\n // handleMoveOutside in called on traveling outside component.\n // Handles state transition with delay.\n handleMoveOutside() {\n if (this.props.delayPressOut) {\n this.pressOutTimeout =\n this.pressOutTimeout ||\n setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n }\n }\n\n // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n handleGoToUndetermined() {\n clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n if (this.props.delayPressOut) {\n this.pressOutTimeout = setTimeout(() => {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n }\n }\n\n componentDidMount() {\n this.reset();\n }\n // reset timeout to prevent memory leaks.\n reset() {\n this.longPressDetected = false;\n this.pointerInside = true;\n clearTimeout(this.pressInTimeout!);\n clearTimeout(this.pressOutTimeout!);\n clearTimeout(this.longPressTimeout!);\n this.pressOutTimeout = null;\n this.longPressTimeout = null;\n this.pressInTimeout = null;\n }\n\n // All states' transitions are defined here.\n moveToState(newState: TouchableState) {\n if (newState === this.STATE) {\n // Ignore dummy transitions\n return;\n }\n if (newState === TOUCHABLE_STATE.BEGAN) {\n // First touch and moving inside\n this.props.onPressIn?.();\n } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // Moving outside\n this.props.onPressOut?.();\n } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n // Need to reset each time on transition to UNDETERMINED\n this.reset();\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n // ... and if it happens inside button.\n this.props.onPressOut?.();\n }\n }\n // Finally call lister (used by subclasses)\n this.props.onStateChange?.(this.STATE, newState);\n // ... and make transition.\n this.STATE = newState;\n }\n\n onGestureEvent = ({\n nativeEvent: { pointerInside },\n }: GestureEvent) => {\n if (this.pointerInside !== pointerInside) {\n if (pointerInside) {\n this.onMoveIn();\n } else {\n this.onMoveOut();\n }\n }\n this.pointerInside = pointerInside;\n };\n\n onHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n const { state } = nativeEvent;\n if (state === State.CANCELLED || state === State.FAILED) {\n // Need to handle case with external cancellation (e.g. by ScrollView)\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n } else if (\n // This platform check is an implication of slightly different behavior of handlers on different platform.\n // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n // On iOS event on \"Began\" is not delivered.\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n this.STATE === TOUCHABLE_STATE.UNDETERMINED\n ) {\n // Moving inside requires\n this.handlePressIn();\n } else if (state === State.END) {\n const shouldCallOnPress =\n !this.longPressDetected &&\n this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n this.pressOutTimeout === null;\n this.handleGoToUndetermined();\n if (shouldCallOnPress) {\n // Calls only inside component whether no long press was called previously\n this.props.onPress?.();\n }\n }\n };\n\n onLongPressDetected = () => {\n this.longPressDetected = true;\n // checked for in the caller of `onLongPressDetected`, but better to check twice\n this.props.onLongPress?.();\n };\n\n componentWillUnmount() {\n // to prevent memory leaks\n this.reset();\n }\n\n onMoveIn() {\n if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // This call is not throttled with delays (like in RN's implementation).\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n }\n\n onMoveOut() {\n // long press should no longer be detected\n clearTimeout(this.longPressTimeout!);\n this.longPressTimeout = null;\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n this.handleMoveOutside();\n }\n }\n\n render() {\n const coreProps = {\n accessible: this.props.accessible !== false,\n accessibilityLabel: this.props.accessibilityLabel,\n accessibilityHint: this.props.accessibilityHint,\n accessibilityRole: this.props.accessibilityRole,\n // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n accessibilityState: this.props.accessibilityState,\n nativeID: this.props.nativeID,\n onLayout: this.props.onLayout,\n hitSlop: this.props.hitSlop,\n };\n\n return (\n \n \n {this.props.children}\n \n \n );\n }\n}\n","import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport GenericTouchable, { GenericTouchableProps } from './GenericTouchable';\n\nconst TouchableWithoutFeedback = React.forwardRef<\n GenericTouchable,\n PropsWithChildren\n>((props, ref) => );\n\nTouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;\n\nexport default TouchableWithoutFeedback;\n","import {\n Animated,\n Easing,\n StyleSheet,\n View,\n TouchableOpacityProps,\n} from 'react-native';\nimport GenericTouchable, {\n TOUCHABLE_STATE,\n GenericTouchableProps,\n} from './GenericTouchable';\nimport * as React from 'react';\nimport { Component } from 'react';\n\n/**\n * TouchableOpacity bases on timing animation which has been used in RN's core\n */\nexport default class TouchableOpacity extends Component<\n TouchableOpacityProps & GenericTouchableProps\n> {\n static defaultProps = {\n ...GenericTouchable.defaultProps,\n activeOpacity: 0.2,\n };\n\n // opacity is 1 one by default but could be overwritten\n getChildStyleOpacityWithDefault = () => {\n const childStyle = StyleSheet.flatten(this.props.style) || {};\n return childStyle.opacity == null ? 1 : childStyle.opacity;\n };\n\n opacity = new Animated.Value(this.getChildStyleOpacityWithDefault());\n\n setOpacityTo = (value: number, duration: number) => {\n Animated.timing(this.opacity, {\n toValue: value,\n duration: duration,\n easing: Easing.inOut(Easing.quad),\n useNativeDriver: false,\n }).start();\n };\n\n onStateChange = (_from: number, to: number) => {\n if (to === TOUCHABLE_STATE.BEGAN) {\n this.setOpacityTo(this.props.activeOpacity!, 0);\n } else if (\n to === TOUCHABLE_STATE.UNDETERMINED ||\n to === TOUCHABLE_STATE.MOVED_OUTSIDE\n ) {\n this.setOpacityTo(this.getChildStyleOpacityWithDefault(), 150);\n }\n };\n\n render() {\n const { style = {}, ...rest } = this.props;\n return (\n \n {this.props.children ? this.props.children : }\n \n );\n }\n}\n","import * as React from 'react';\nimport { Component } from 'react';\nimport GenericTouchable, {\n GenericTouchableProps,\n TOUCHABLE_STATE,\n} from './GenericTouchable';\nimport {\n StyleSheet,\n View,\n TouchableHighlightProps,\n ColorValue,\n ViewProps,\n} from 'react-native';\n\ninterface State {\n extraChildStyle: null | {\n opacity?: number;\n };\n extraUnderlayStyle: null | {\n backgroundColor?: ColorValue;\n };\n}\n\n/**\n * TouchableHighlight follows RN's implementation\n */\nexport default class TouchableHighlight extends Component<\n TouchableHighlightProps & GenericTouchableProps,\n State\n> {\n static defaultProps = {\n ...GenericTouchable.defaultProps,\n activeOpacity: 0.85,\n delayPressOut: 100,\n underlayColor: 'black',\n };\n\n constructor(props: TouchableHighlightProps & GenericTouchableProps) {\n super(props);\n this.state = {\n extraChildStyle: null,\n extraUnderlayStyle: null,\n };\n }\n\n // Copied from RN\n showUnderlay = () => {\n if (!this.hasPressHandler()) {\n return;\n }\n this.setState({\n extraChildStyle: {\n opacity: this.props.activeOpacity,\n },\n extraUnderlayStyle: {\n backgroundColor: this.props.underlayColor,\n },\n });\n this.props.onShowUnderlay?.();\n };\n\n hasPressHandler = () =>\n this.props.onPress ||\n this.props.onPressIn ||\n this.props.onPressOut ||\n this.props.onLongPress;\n\n hideUnderlay = () => {\n this.setState({\n extraChildStyle: null,\n extraUnderlayStyle: null,\n });\n this.props.onHideUnderlay?.();\n };\n\n renderChildren() {\n if (!this.props.children) {\n return ;\n }\n\n const child = React.Children.only(\n this.props.children\n ) as React.ReactElement; // TODO: not sure if OK but fixes error\n return React.cloneElement(child, {\n style: StyleSheet.compose(child.props.style, this.state.extraChildStyle),\n });\n }\n\n onStateChange = (_from: number, to: number) => {\n if (to === TOUCHABLE_STATE.BEGAN) {\n this.showUnderlay();\n } else if (\n to === TOUCHABLE_STATE.UNDETERMINED ||\n to === TOUCHABLE_STATE.MOVED_OUTSIDE\n ) {\n this.hideUnderlay();\n }\n };\n\n render() {\n const { style = {}, ...rest } = this.props;\n const { extraUnderlayStyle } = this.state;\n return (\n \n {this.renderChildren()}\n \n );\n }\n}\n","import * as React from 'react';\nimport {\n DrawerLayoutAndroid as RNDrawerLayoutAndroid,\n FlatList as RNFlatList,\n Switch as RNSwitch,\n TextInput as RNTextInput,\n ScrollView as RNScrollView,\n FlatListProps,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\n\nexport const ScrollView = createNativeWrapper(RNScrollView, {\n disallowInterruption: true,\n});\n\nexport const Switch = createNativeWrapper(RNSwitch, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: true,\n disallowInterruption: true,\n});\nexport const TextInput = createNativeWrapper(RNTextInput);\nexport const DrawerLayoutAndroid = createNativeWrapper(RNDrawerLayoutAndroid, {\n disallowInterruption: true,\n});\n// @ts-ignore -- TODO(TS) to investigate if it's needed\nDrawerLayoutAndroid.positions = RNDrawerLayoutAndroid.positions;\n\nexport const FlatList = React.forwardRef(\n (props: FlatListProps, ref: any) => (\n }\n />\n )\n);\n","// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n PanGestureHandlerProps,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\nexport interface SwipeableProps\n extends Pick {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * Called when left action panel gets open.\n */\n onSwipeableLeftOpen?: () => void;\n\n /**\n * Called when right action panel gets open.\n */\n onSwipeableRightOpen?: () => void;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: () => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: () => void;\n\n /**\n * Called when left action panel starts animating on open.\n */\n onSwipeableLeftWillOpen?: () => void;\n\n /**\n * Called when right action panel starts animating on open.\n */\n onSwipeableRightWillOpen?: () => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: () => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: () => void;\n\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progressAnimatedValue: Animated.AnimatedInterpolation,\n dragAnimatedValue: Animated.AnimatedInterpolation\n ) => React.ReactNode;\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progressAnimatedValue: Animated.AnimatedInterpolation,\n dragAnimatedValue: Animated.AnimatedInterpolation\n ) => React.ReactNode;\n\n useNativeAnimations?: boolean;\n\n animationOptions?: Record;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp;\n}\n\ntype SwipeableState = {\n dragX: Animated.Value;\n rowTranslation: Animated.Value;\n rowState: number;\n leftWidth?: number;\n rightOffset?: number;\n rowWidth?: number;\n};\n\nexport default class Swipeable extends Component<\n SwipeableProps,\n SwipeableState\n> {\n static defaultProps = {\n friction: 1,\n overshootFriction: 1,\n useNativeAnimations: true,\n };\n\n constructor(props: SwipeableProps) {\n super(props);\n const dragX = new Animated.Value(0);\n this.state = {\n dragX,\n rowTranslation: new Animated.Value(0),\n rowState: 0,\n leftWidth: undefined,\n rightOffset: undefined,\n rowWidth: undefined,\n };\n this.updateAnimatedEvent(props, this.state);\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragX } }],\n { useNativeDriver: props.useNativeAnimations! }\n );\n }\n\n UNSAFE_componentWillUpdate(props: SwipeableProps, state: SwipeableState) {\n if (\n this.props.friction !== props.friction ||\n this.props.overshootLeft !== props.overshootLeft ||\n this.props.overshootRight !== props.overshootRight ||\n this.props.overshootFriction !== props.overshootFriction ||\n this.state.leftWidth !== state.leftWidth ||\n this.state.rightOffset !== state.rightOffset ||\n this.state.rowWidth !== state.rowWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n }\n\n private onGestureEvent?: (\n event: GestureEvent\n ) => void;\n private transX?: Animated.AnimatedInterpolation;\n private showLeftAction?: Animated.AnimatedInterpolation | Animated.Value;\n private leftActionTranslate?: Animated.AnimatedInterpolation;\n private showRightAction?: Animated.AnimatedInterpolation | Animated.Value;\n private rightActionTranslate?: Animated.AnimatedInterpolation;\n\n private updateAnimatedEvent = (\n props: SwipeableProps,\n state: SwipeableState\n ) => {\n const { friction, overshootFriction } = props;\n const { dragX, rowTranslation, leftWidth = 0, rowWidth = 0 } = state;\n const { rightOffset = rowWidth } = state;\n const rightWidth = Math.max(0, rowWidth - rightOffset);\n\n const {\n overshootLeft = leftWidth > 0,\n overshootRight = rightWidth > 0,\n } = props;\n\n const transX = Animated.add(\n rowTranslation,\n dragX.interpolate({\n inputRange: [0, friction!],\n outputRange: [0, 1],\n })\n ).interpolate({\n inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],\n outputRange: [\n -rightWidth - (overshootRight ? 1 / overshootFriction! : 0),\n -rightWidth,\n leftWidth,\n leftWidth + (overshootLeft ? 1 / overshootFriction! : 0),\n ],\n });\n this.transX = transX;\n this.showLeftAction =\n leftWidth > 0\n ? transX.interpolate({\n inputRange: [-1, 0, leftWidth],\n outputRange: [0, 0, 1],\n })\n : new Animated.Value(0);\n this.leftActionTranslate = this.showLeftAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n this.showRightAction =\n rightWidth > 0\n ? transX.interpolate({\n inputRange: [-rightWidth, 0, 1],\n outputRange: [1, 0, 0],\n })\n : new Animated.Value(0);\n this.rightActionTranslate = this.showRightAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.close();\n }\n };\n\n private onHandlerStateChange = (\n ev: HandlerStateChangeEvent\n ) => {\n if (ev.nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease(ev);\n }\n };\n\n private handleRelease = (\n ev: HandlerStateChangeEvent\n ) => {\n const { velocityX, translationX: dragX } = ev.nativeEvent;\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n const {\n friction,\n leftThreshold = leftWidth / 2,\n rightThreshold = rightWidth / 2,\n } = this.props;\n\n const startOffsetX = this.currentOffset() + dragX / friction!;\n const translationX = (dragX + DRAG_TOSS * velocityX) / friction!;\n\n let toValue = 0;\n if (rowState === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth;\n }\n } else if (rowState === 1) {\n // swiped to left\n if (translationX > -leftThreshold) {\n toValue = leftWidth;\n }\n } else {\n // swiped to right\n if (translationX < rightThreshold) {\n toValue = -rightWidth;\n }\n }\n\n this.animateRow(startOffsetX, toValue, velocityX / friction!);\n };\n\n private animateRow = (\n fromValue: number,\n toValue: number,\n velocityX?:\n | number\n | {\n x: number;\n y: number;\n }\n ) => {\n const { dragX, rowTranslation } = this.state;\n dragX.setValue(0);\n rowTranslation.setValue(fromValue);\n\n this.setState({ rowState: Math.sign(toValue) });\n Animated.spring(rowTranslation, {\n restSpeedThreshold: 1.7,\n restDisplacementThreshold: 0.4,\n velocity: velocityX,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n ...this.props.animationOptions,\n }).start(({ finished }) => {\n if (finished) {\n if (toValue > 0 && this.props.onSwipeableLeftOpen) {\n this.props.onSwipeableLeftOpen();\n } else if (toValue < 0 && this.props.onSwipeableRightOpen) {\n this.props.onSwipeableRightOpen();\n }\n\n if (toValue === 0) {\n this.props.onSwipeableClose?.();\n } else {\n this.props.onSwipeableOpen?.();\n }\n }\n });\n if (toValue > 0 && this.props.onSwipeableLeftWillOpen) {\n this.props.onSwipeableLeftWillOpen();\n } else if (toValue < 0 && this.props.onSwipeableRightWillOpen) {\n this.props.onSwipeableRightWillOpen();\n }\n\n if (toValue === 0) {\n this.props.onSwipeableWillClose?.();\n } else {\n this.props.onSwipeableWillOpen?.();\n }\n };\n\n private onRowLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ rowWidth: nativeEvent.layout.width });\n };\n\n private currentOffset = () => {\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n if (rowState === 1) {\n return leftWidth;\n } else if (rowState === -1) {\n return -rightWidth;\n }\n return 0;\n };\n\n close = () => {\n this.animateRow(this.currentOffset(), 0);\n };\n\n openLeft = () => {\n const { leftWidth = 0 } = this.state;\n this.animateRow(this.currentOffset(), leftWidth);\n };\n\n openRight = () => {\n const { rowWidth = 0 } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n this.animateRow(this.currentOffset(), -rightWidth);\n };\n\n render() {\n const { rowState } = this.state;\n const { children, renderLeftActions, renderRightActions } = this.props;\n\n const left = renderLeftActions && (\n \n {renderLeftActions(this.showLeftAction!, this.transX!)}\n \n this.setState({ leftWidth: nativeEvent.layout.x })\n }\n />\n \n );\n\n const right = renderRightActions && (\n \n {renderRightActions(this.showRightAction!, this.transX!)}\n \n this.setState({ rightOffset: nativeEvent.layout.x })\n }\n />\n \n );\n\n return (\n \n \n {left}\n {right}\n \n \n {children}\n \n \n \n \n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n },\n});\n","// This component is based on RN's DrawerLayoutAndroid API\n//\n// It perhaps deserves to be put in a separate repo, but since it relies on\n// react-native-gesture-handler library which isn't very popular at the moment I\n// decided to keep it here for the time being. It will allow us to move faster\n// and fix issues that may arise in gesture handler library that could be found\n// when using the drawer component\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport invariant from 'invariant';\nimport {\n Animated,\n StyleSheet,\n View,\n Keyboard,\n StatusBar,\n I18nManager,\n StatusBarAnimation,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n NativeSyntheticEvent,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\nconst IDLE: DrawerState = 'Idle';\nconst DRAGGING: DrawerState = 'Dragging';\nconst SETTLING: DrawerState = 'Settling';\n\nexport type DrawerPosition = 'left' | 'right';\n\nexport type DrawerState = 'Idle' | 'Dragging' | 'Settling';\n\nexport type DrawerType = 'front' | 'back' | 'slide';\n\nexport type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';\n\nexport type DrawerKeyboardDismissMode = 'none' | 'on-drag';\n\nexport interface DrawerLayoutProps {\n /**\n * This attribute is present in the standard implementation already and is one\n * of the required params. Gesture handler version of DrawerLayout make it\n * possible for the function passed as `renderNavigationView` to take an\n * Animated value as a parameter that indicates the progress of drawer\n * opening/closing animation (progress value is 0 when closed and 1 when\n * opened). This can be used by the drawer component to animated its children\n * while the drawer is opening or closing.\n */\n renderNavigationView: (\n progressAnimatedValue: Animated.Value\n ) => React.ReactNode;\n\n drawerPosition?: DrawerPosition;\n\n drawerWidth?: number;\n\n drawerBackgroundColor?: string;\n\n drawerLockMode?: DrawerLockMode;\n\n keyboardDismissMode?: DrawerKeyboardDismissMode;\n\n /**\n * Called when the drawer is closed.\n */\n onDrawerClose?: () => void;\n\n /**\n * Called when the drawer is opened.\n */\n onDrawerOpen?: () => void;\n\n /**\n * Called when the status of the drawer changes.\n */\n onDrawerStateChanged?: (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => void;\n useNativeAnimations?: boolean;\n\n drawerType?: DrawerType;\n\n /**\n * Defines how far from the edge of the content view the gesture should\n * activate.\n */\n edgeWidth?: number;\n\n minSwipeDistance?: number;\n\n /**\n * When set to true Drawer component will use\n * {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS\n * status bar whenever the drawer is pulled or when its in an \"open\" state.\n */\n hideStatusBar?: boolean;\n\n /**\n * @default 'slide'\n *\n * Can be used when hideStatusBar is set to true and will select the animation\n * used for hiding/showing the status bar. See\n * {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for\n * more details\n */\n statusBarAnimation?: StatusBarAnimation;\n\n /**\n * @default black\n *\n * Color of a semi-transparent overlay to be displayed on top of the content\n * view when drawer gets open. A solid color should be used as the opacity is\n * added by the Drawer itself and the opacity of the overlay is animated (from\n * 0% to 70%).\n */\n overlayColor?: string;\n\n contentContainerStyle?: StyleProp;\n\n drawerContainerStyle?: StyleProp;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n onDrawerSlide?: (position: number) => void;\n\n onGestureRef?: (ref: PanGestureHandler) => void;\n}\n\nexport type DrawerLayoutState = {\n dragX: Animated.Value;\n touchX: Animated.Value;\n drawerTranslation: Animated.Value;\n containerWidth: number;\n};\n\nexport type DrawerMovementOption = {\n velocity?: number;\n speed?: number;\n};\nexport default class DrawerLayout extends Component<\n DrawerLayoutProps,\n DrawerLayoutState\n> {\n static defaultProps = {\n drawerWidth: 200,\n drawerPosition: 'left',\n useNativeAnimations: true,\n drawerType: 'front',\n edgeWidth: 20,\n minSwipeDistance: 3,\n overlayColor: 'rgba(0, 0, 0, 0.7)',\n drawerLockMode: 'unlocked',\n enableTrackpadTwoFingerGesture: false,\n };\n\n constructor(props: DrawerLayoutProps) {\n super(props);\n\n const dragX = new Animated.Value(0);\n const touchX = new Animated.Value(0);\n const drawerTranslation = new Animated.Value(0);\n\n this.state = {\n dragX,\n touchX,\n drawerTranslation,\n containerWidth: 0,\n };\n\n this.updateAnimatedEvent(props, this.state);\n }\n\n UNSAFE_componentWillUpdate(\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) {\n if (\n this.props.drawerPosition !== props.drawerPosition ||\n this.props.drawerWidth !== props.drawerWidth ||\n this.props.drawerType !== props.drawerType ||\n this.state.containerWidth !== state.containerWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n }\n\n private openValue?: Animated.AnimatedInterpolation;\n private onGestureEvent?: (\n event: GestureEvent\n ) => void;\n private accessibilityIsModalView = React.createRef();\n private pointerEventsView = React.createRef();\n private panGestureHandler = React.createRef();\n private drawerShown = false;\n\n static positions = {\n Left: 'left',\n Right: 'right',\n };\n\n private updateAnimatedEvent = (\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) => {\n // Event definition is based on\n const { drawerPosition, drawerWidth, drawerType } = props;\n const {\n dragX: dragXValue,\n touchX: touchXValue,\n drawerTranslation,\n containerWidth,\n } = state;\n\n let dragX = dragXValue;\n let touchX = touchXValue;\n\n if (drawerPosition !== 'left') {\n // Most of the code is written in a way to handle left-side drawer. In\n // order to handle right-side drawer the only thing we need to do is to\n // reverse events coming from gesture handler in a way they emulate\n // left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is\n // calulcated by subtracing real touchX from the width of the container\n // (such that when touch happens at the right edge the value is simply 0)\n dragX = Animated.multiply(\n new Animated.Value(-1),\n dragXValue\n ) as Animated.Value; // TODO(TS): (for all \"as\" in this file) make sure we can map this\n touchX = Animated.add(\n new Animated.Value(containerWidth),\n Animated.multiply(new Animated.Value(-1), touchXValue)\n ) as Animated.Value; // TODO(TS): make sure we can map this;\n touchXValue.setValue(containerWidth);\n } else {\n touchXValue.setValue(0);\n }\n\n // While closing the drawer when user starts gesture outside of its area (in greyed\n // out part of the window), we want the drawer to follow only once finger reaches the\n // edge of the drawer.\n // E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by\n // dots. The touch gesture starts at '*' and moves left, touch path is indicated by\n // an arrow pointing left\n // 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // +---------------+ +---------------+ +---------------+ +---------------+\n //\n // For the above to work properly we define animated value that will keep\n // start position of the gesture. Then we use that value to calculate how\n // much we need to subtract from the dragX. If the gesture started on the\n // greyed out area we take the distance from the edge of the drawer to the\n // start position. Otherwise we don't subtract at all and the drawer be\n // pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n //\n let translationX = dragX;\n if (drawerType === 'front') {\n const startPositionX = Animated.add(\n touchX,\n Animated.multiply(new Animated.Value(-1), dragX)\n );\n\n const dragOffsetFromOnStartPosition = startPositionX.interpolate({\n inputRange: [drawerWidth! - 1, drawerWidth!, drawerWidth! + 1],\n outputRange: [0, 0, 1],\n });\n translationX = Animated.add(\n dragX,\n dragOffsetFromOnStartPosition\n ) as Animated.Value; // TODO: as above\n }\n\n this.openValue = Animated.add(translationX, drawerTranslation).interpolate({\n inputRange: [0, drawerWidth!],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n\n const gestureOptions: {\n useNativeDriver: boolean;\n // TODO: make sure it is correct\n listener?: (\n ev: NativeSyntheticEvent\n ) => void;\n } = {\n useNativeDriver: props.useNativeAnimations!,\n };\n\n if (this.props.onDrawerSlide) {\n gestureOptions.listener = (ev) => {\n const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));\n const position = translationX / this.state.containerWidth;\n\n this.props.onDrawerSlide?.(position);\n };\n }\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragXValue, x: touchXValue } }],\n gestureOptions\n );\n };\n\n private handleContainerLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ containerWidth: nativeEvent.layout.width });\n };\n\n private emitStateChanged = (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => {\n this.props.onDrawerStateChanged?.(newState, drawerWillShow);\n };\n\n private openingHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease({ nativeEvent });\n } else if (nativeEvent.state === State.ACTIVE) {\n this.emitStateChanged(DRAGGING, false);\n if (this.props.keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');\n }\n }\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n if (\n this.drawerShown &&\n nativeEvent.oldState === State.ACTIVE &&\n this.props.drawerLockMode !== 'locked-open'\n ) {\n this.closeDrawer();\n }\n };\n\n private handleRelease = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n const { drawerWidth, drawerPosition, drawerType } = this.props;\n const { containerWidth } = this.state;\n let { translationX: dragX, velocityX, x: touchX } = nativeEvent;\n\n if (drawerPosition !== 'left') {\n // See description in _updateAnimatedEvent about why events are flipped\n // for right-side drawer\n dragX = -dragX;\n touchX = containerWidth - touchX;\n velocityX = -velocityX;\n }\n\n const gestureStartX = touchX - dragX;\n let dragOffsetBasedOnStart = 0;\n\n if (drawerType === 'front') {\n dragOffsetBasedOnStart =\n gestureStartX > drawerWidth! ? gestureStartX - drawerWidth! : 0;\n }\n\n const startOffsetX =\n dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth! : 0);\n const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;\n\n const shouldOpen = projOffsetX > drawerWidth! / 2;\n\n if (shouldOpen) {\n this.animateDrawer(startOffsetX, drawerWidth!, velocityX);\n } else {\n this.animateDrawer(startOffsetX, 0, velocityX);\n }\n };\n\n private updateShowing = (showing: boolean) => {\n this.drawerShown = showing;\n this.accessibilityIsModalView.current?.setNativeProps({\n accessibilityViewIsModal: showing,\n });\n this.pointerEventsView.current?.setNativeProps({\n pointerEvents: showing ? 'auto' : 'none',\n });\n const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;\n const fromLeft = drawerPosition === 'left';\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: showing ? undefined : edgeWidth }\n : { right: 0, width: showing ? undefined : edgeWidth };\n // @ts-ignore internal API, maybe could be fixed in handler types\n this.panGestureHandler.current?.setNativeProps({\n hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance!,\n });\n };\n\n private animateDrawer = (\n fromValue: number | null | undefined,\n toValue: number,\n velocity: number,\n speed?: number\n ) => {\n this.state.dragX.setValue(0);\n this.state.touchX.setValue(\n this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth\n );\n\n if (fromValue != null) {\n let nextFramePosition = fromValue;\n if (this.props.useNativeAnimations) {\n // When using native driver, we predict the next position of the\n // animation because it takes one frame of a roundtrip to pass RELEASE\n // event from native driver to JS before we can start animating. Without\n // it, it is more noticable that the frame is dropped.\n if (fromValue < toValue && velocity > 0) {\n nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);\n } else if (fromValue > toValue && velocity < 0) {\n nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);\n }\n }\n this.state.drawerTranslation.setValue(nextFramePosition);\n }\n\n const willShow = toValue !== 0;\n this.updateShowing(willShow);\n this.emitStateChanged(SETTLING, willShow);\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');\n }\n Animated.spring(this.state.drawerTranslation, {\n velocity,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n speed: speed ?? undefined,\n }).start(({ finished }) => {\n if (finished) {\n this.emitStateChanged(IDLE, willShow);\n if (willShow) {\n this.props.onDrawerOpen?.();\n } else {\n this.props.onDrawerClose?.();\n }\n }\n });\n };\n\n openDrawer = (options: DrawerMovementOption = {}) => {\n this.animateDrawer(\n // TODO: decide if it should be null or undefined is the proper value\n undefined,\n this.props.drawerWidth!,\n options.velocity ? options.velocity : 0\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would not be clickable\n this.forceUpdate();\n };\n\n closeDrawer = (options: DrawerMovementOption = {}) => {\n // TODO: decide if it should be null or undefined is the proper value\n this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0);\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would be still clickable\n this.forceUpdate();\n };\n\n private renderOverlay = () => {\n /* Overlay styles */\n invariant(this.openValue, 'should be set');\n const overlayOpacity = this.openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n const dynamicOverlayStyles = {\n opacity: overlayOpacity,\n backgroundColor: this.props.overlayColor,\n };\n\n return (\n \n \n \n );\n };\n\n private renderDrawer = () => {\n const {\n drawerBackgroundColor,\n drawerWidth,\n drawerPosition,\n drawerType,\n drawerContainerStyle,\n contentContainerStyle,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n const drawerSlide = drawerType !== 'back';\n const containerSlide = drawerType !== 'front';\n\n // we rely on row and row-reverse flex directions to position the drawer\n // properly. Apparently for RTL these are flipped which requires us to use\n // the opposite setting for the drawer to appear from left or right\n // according to the drawerPosition prop\n const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;\n\n const dynamicDrawerStyles = {\n backgroundColor: drawerBackgroundColor,\n width: drawerWidth,\n };\n const openValue = this.openValue;\n invariant(openValue, 'should be set');\n\n let containerStyles;\n if (containerSlide) {\n const containerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: fromLeft ? [0, drawerWidth!] : [0, -drawerWidth!],\n extrapolate: 'clamp',\n });\n containerStyles = {\n transform: [{ translateX: containerTranslateX }],\n };\n }\n\n let drawerTranslateX: number | Animated.AnimatedInterpolation = 0;\n if (drawerSlide) {\n const closedDrawerOffset = fromLeft ? -drawerWidth! : drawerWidth!;\n drawerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [closedDrawerOffset, 0],\n extrapolate: 'clamp',\n });\n }\n const drawerStyles: {\n transform: { translateX: number | Animated.AnimatedInterpolation }[];\n flexDirection: 'row-reverse' | 'row';\n } = {\n transform: [{ translateX: drawerTranslateX }],\n flexDirection: reverseContentDirection ? 'row-reverse' : 'row',\n };\n\n return (\n \n \n {typeof this.props.children === 'function'\n ? this.props.children(this.openValue)\n : this.props.children}\n {this.renderOverlay()}\n \n \n \n {this.props.renderNavigationView(this.openValue as Animated.Value)}\n \n \n \n );\n };\n\n private setPanGestureRef = (ref: PanGestureHandler) => {\n // TODO(TS): make sure it is OK taken from\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842\n (this\n .panGestureHandler as React.MutableRefObject).current = ref;\n this.props.onGestureRef?.(ref);\n };\n\n render() {\n const {\n drawerPosition,\n drawerLockMode,\n edgeWidth,\n minSwipeDistance,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: this.drawerShown ? undefined : edgeWidth }\n : { right: 0, width: this.drawerShown ? undefined : edgeWidth };\n\n return (\n \n {this.renderDrawer()}\n \n );\n }\n}\n\nconst styles = StyleSheet.create({\n drawerContainer: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1001,\n flexDirection: 'row',\n },\n containerInFront: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1002,\n },\n containerOnBack: {\n ...StyleSheet.absoluteFillObject,\n },\n main: {\n flex: 1,\n zIndex: 0,\n overflow: 'hidden',\n },\n overlay: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1000,\n },\n});\n","import { startListening } from './handlers/gestures/eventReceiver';\n\nexport function initialize() {\n startListening();\n}\n","export function val(v) {\n return v && v.__getValue ? v.__getValue() : v || 0;\n}\n","/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\n'use strict';\n\nimport NativeAnimatedHelper from '../NativeAnimatedHelper';\nvar NativeAnimatedAPI = NativeAnimatedHelper.API;\nimport invariant from 'fbjs/lib/invariant';\nvar _uniqueId = 1; // Note(vjeux): this would be better as an interface but flow doesn't\n// support them yet\n\nvar AnimatedNode = /*#__PURE__*/function () {\n var _proto = AnimatedNode.prototype;\n\n _proto.__attach = function __attach() {};\n\n _proto.__detach = function __detach() {\n if (this.__isNative && this.__nativeTag != null) {\n NativeAnimatedHelper.API.dropAnimatedNode(this.__nativeTag);\n this.__nativeTag = undefined;\n }\n };\n\n _proto.__getValue = function __getValue() {};\n\n _proto.__getAnimatedValue = function __getAnimatedValue() {\n return this.__getValue();\n };\n\n _proto.__addChild = function __addChild(child) {};\n\n _proto.__removeChild = function __removeChild(child) {};\n\n _proto.__getChildren = function __getChildren() {\n return [];\n }\n /* Methods and props used by native Animated impl */\n ;\n\n function AnimatedNode() {\n this._listeners = {};\n }\n\n _proto.__makeNative = function __makeNative() {\n if (!this.__isNative) {\n throw new Error('This node cannot be made a \"native\" animated node');\n }\n\n if (this.hasListeners()) {\n this._startListeningToNativeValueUpdates();\n }\n }\n /**\n * Adds an asynchronous listener to the value so you can observe updates from\n * animations. This is useful because there is no way to\n * synchronously read the value because it might be driven natively.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#addlistener\n */\n ;\n\n _proto.addListener = function addListener(callback) {\n var id = String(_uniqueId++);\n this._listeners[id] = callback;\n\n if (this.__isNative) {\n this._startListeningToNativeValueUpdates();\n }\n\n return id;\n }\n /**\n * Unregister a listener. The `id` param shall match the identifier\n * previously returned by `addListener()`.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#removelistener\n */\n ;\n\n _proto.removeListener = function removeListener(id) {\n delete this._listeners[id];\n\n if (this.__isNative && !this.hasListeners()) {\n this._stopListeningForNativeValueUpdates();\n }\n }\n /**\n * Remove all registered listeners.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#removealllisteners\n */\n ;\n\n _proto.removeAllListeners = function removeAllListeners() {\n this._listeners = {};\n\n if (this.__isNative) {\n this._stopListeningForNativeValueUpdates();\n }\n };\n\n _proto.hasListeners = function hasListeners() {\n return !!Object.keys(this._listeners).length;\n };\n\n _proto._startListeningToNativeValueUpdates = function _startListeningToNativeValueUpdates() {\n var _this = this;\n\n if (this.__nativeAnimatedValueListener && !this.__shouldUpdateListenersForNewNativeTag) {\n return;\n }\n\n if (this.__shouldUpdateListenersForNewNativeTag) {\n this.__shouldUpdateListenersForNewNativeTag = false;\n\n this._stopListeningForNativeValueUpdates();\n }\n\n NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag());\n this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener('onAnimatedValueUpdate', function (data) {\n if (data.tag !== _this.__getNativeTag()) {\n return;\n }\n\n _this._onAnimatedValueUpdateReceived(data.value);\n });\n };\n\n _proto._onAnimatedValueUpdateReceived = function _onAnimatedValueUpdateReceived(value) {\n this.__callListeners(value);\n };\n\n _proto.__callListeners = function __callListeners(value) {\n for (var _key in this._listeners) {\n this._listeners[_key]({\n value: value\n });\n }\n };\n\n _proto._stopListeningForNativeValueUpdates = function _stopListeningForNativeValueUpdates() {\n if (!this.__nativeAnimatedValueListener) {\n return;\n }\n\n this.__nativeAnimatedValueListener.remove();\n\n this.__nativeAnimatedValueListener = null;\n NativeAnimatedAPI.stopListeningToAnimatedNodeValue(this.__getNativeTag());\n };\n\n _proto.__getNativeTag = function __getNativeTag() {\n var _this$__nativeTag;\n\n NativeAnimatedHelper.assertNativeAnimatedModule();\n invariant(this.__isNative, 'Attempt to get native tag from node not marked as \"native\"');\n var nativeTag = (_this$__nativeTag = this.__nativeTag) !== null && _this$__nativeTag !== void 0 ? _this$__nativeTag : NativeAnimatedHelper.generateNewNodeTag();\n\n if (this.__nativeTag == null) {\n this.__nativeTag = nativeTag;\n NativeAnimatedHelper.API.createAnimatedNode(nativeTag, this.__getNativeConfig());\n this.__shouldUpdateListenersForNewNativeTag = true;\n }\n\n return nativeTag;\n };\n\n _proto.__getNativeConfig = function __getNativeConfig() {\n throw new Error('This JS animated node type cannot be used as native animated node');\n };\n\n _proto.toJSON = function toJSON() {\n return this.__getValue();\n };\n\n return AnimatedNode;\n}();\n\nexport default AnimatedNode;","/**\n * Copyright (c) Nicolas Gallagher.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport { findDOMNode } from 'react-dom';\n\nvar findNodeHandle = function findNodeHandle(component) {\n var node;\n\n try {\n node = findDOMNode(component);\n } catch (e) {}\n\n return node;\n};\n\nexport default findNodeHandle;","import AnimatedNode from './AnimatedNode';\nimport { val } from '../val';\nimport ReanimatedModule from '../../ReanimatedModule';\nimport invariant from 'invariant';\n\nfunction sanitizeValue(value) {\n return value === null || value === undefined || typeof value === 'string'\n ? value\n : Number(value);\n}\n\nconst CONSTANT_VALUES = new Map();\n\nfunction initializeConstantValues() {\n if (CONSTANT_VALUES.size !== 0) {\n return;\n }\n [0, -1, 1, -2, 2].forEach((v) =>\n CONSTANT_VALUES.set(v, new InternalAnimatedValue(v, true))\n );\n}\n\n/**\n * This class has been made internal in order to omit dependencies' cycles which\n * were caused by imperative setValue and interpolate – they are currently exposed with AnimatedValue.js\n */\nexport default class InternalAnimatedValue extends AnimatedNode {\n static valueForConstant(number) {\n initializeConstantValues();\n return (\n CONSTANT_VALUES.get(number) || new InternalAnimatedValue(number, true)\n );\n }\n\n constructor(value, constant = false) {\n invariant(value !== null, 'Animated.Value cannot be set to the null');\n super({ type: 'value', value: sanitizeValue(value) });\n this._startingValue = this._value = value;\n this._animation = null;\n this._constant = constant;\n }\n\n __detach() {\n if (!this._constant) {\n if (ReanimatedModule.getValue) {\n ReanimatedModule.getValue(\n this.__nodeID,\n (val) => (this.__nodeConfig.value = val)\n );\n } else {\n this.__nodeConfig.value = this.__getValue();\n }\n }\n this.__detachAnimation(this._animation);\n super.__detach();\n }\n\n __detachAnimation(animation) {\n animation && animation.__detach();\n if (this._animation === animation) {\n this._animation = null;\n }\n }\n\n __attachAnimation(animation) {\n this.__detachAnimation(this._animation);\n this._animation = animation;\n }\n\n __onEvaluate() {\n if (this.__inputNodes && this.__inputNodes.length) {\n this.__inputNodes.forEach(val);\n }\n return this._value;\n }\n\n // AnimatedValue will override this method to modify the value of a native node.\n setValue(value) {\n this.__detachAnimation(this._animation);\n this._updateValue(value);\n }\n\n _updateValue(value) {\n this._value = value;\n this.__forceUpdateCache(value);\n }\n}\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar react = require('react');\n\nfunction _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n}\n\nfunction _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n if (it) return (it = it.call(o)).next.bind(it);\n\n if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n return function () {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nvar SUSPENSE_PROMISE = Symbol();\nvar isSuspensePromise = function isSuspensePromise(promise) {\n return !!promise[SUSPENSE_PROMISE];\n};\nvar isSuspensePromiseAlreadyCancelled = function isSuspensePromiseAlreadyCancelled(suspensePromise) {\n return !suspensePromise[SUSPENSE_PROMISE].c;\n};\nvar cancelSuspensePromise = function cancelSuspensePromise(suspensePromise) {\n var _suspensePromise$SUSP, _suspensePromise$SUSP2;\n\n (_suspensePromise$SUSP = (_suspensePromise$SUSP2 = suspensePromise[SUSPENSE_PROMISE]).c) == null ? void 0 : _suspensePromise$SUSP.call(_suspensePromise$SUSP2);\n};\nvar isEqualSuspensePromise = function isEqualSuspensePromise(oldSuspensePromise, newSuspensePromise) {\n var oldOriginalPromise = oldSuspensePromise[SUSPENSE_PROMISE].o;\n var newOriginalPromise = newSuspensePromise[SUSPENSE_PROMISE].o;\n return oldOriginalPromise === newOriginalPromise || oldSuspensePromise === newOriginalPromise || isSuspensePromise(oldOriginalPromise) && isEqualSuspensePromise(oldOriginalPromise, newSuspensePromise);\n};\nvar createSuspensePromise = function createSuspensePromise(promise) {\n var objectToAttach = {\n o: promise,\n c: null\n };\n var suspensePromise = new Promise(function (resolve) {\n objectToAttach.c = function () {\n objectToAttach.c = null;\n resolve();\n };\n\n promise.then(objectToAttach.c, objectToAttach.c);\n });\n suspensePromise[SUSPENSE_PROMISE] = objectToAttach;\n return suspensePromise;\n};\n\nvar hasInitialValue = function hasInitialValue(atom) {\n return 'init' in atom;\n};\n\nvar READ_ATOM = 'r';\nvar WRITE_ATOM = 'w';\nvar COMMIT_ATOM = 'c';\nvar SUBSCRIBE_ATOM = 's';\nvar RESTORE_ATOMS = 'h';\nvar DEV_SUBSCRIBE_STATE = 'n';\nvar DEV_GET_MOUNTED_ATOMS = 'l';\nvar DEV_GET_ATOM_STATE = 'a';\nvar DEV_GET_MOUNTED = 'm';\nvar createStore = function createStore(initialValues) {\n var _ref4;\n\n var committedAtomStateMap = new WeakMap();\n var mountedMap = new WeakMap();\n var pendingMap = new Map();\n var stateListeners;\n var mountedAtoms;\n\n if (process.env.NODE_ENV !== \"production\") {\n stateListeners = new Set();\n mountedAtoms = new Set();\n }\n\n if (initialValues) {\n for (var _iterator = _createForOfIteratorHelperLoose(initialValues), _step; !(_step = _iterator()).done;) {\n var _step$value = _step.value,\n atom = _step$value[0],\n value = _step$value[1];\n var atomState = {\n v: value,\n r: 0,\n d: new Map()\n };\n\n if (process.env.NODE_ENV !== \"production\") {\n Object.freeze(atomState);\n\n if (!hasInitialValue(atom)) {\n console.warn('Found initial value for derived atom which can cause unexpected behavior', atom);\n }\n }\n\n committedAtomStateMap.set(atom, atomState);\n }\n }\n\n var suspensePromiseCacheMap = new WeakMap();\n\n var addSuspensePromiseToCache = function addSuspensePromiseToCache(version, atom, suspensePromise) {\n var cache = suspensePromiseCacheMap.get(atom);\n\n if (!cache) {\n cache = new Map();\n suspensePromiseCacheMap.set(atom, cache);\n }\n\n suspensePromise.then(function () {\n if (cache.get(version) === suspensePromise) {\n cache.delete(version);\n\n if (!cache.size) {\n suspensePromiseCacheMap.delete(atom);\n }\n }\n });\n cache.set(version, suspensePromise);\n };\n\n var cancelAllSuspensePromiseInCache = function cancelAllSuspensePromiseInCache(atom) {\n var versionSet = new Set();\n var cache = suspensePromiseCacheMap.get(atom);\n\n if (cache) {\n suspensePromiseCacheMap.delete(atom);\n cache.forEach(function (suspensePromise, version) {\n cancelSuspensePromise(suspensePromise);\n versionSet.add(version);\n });\n }\n\n return versionSet;\n };\n\n var versionedAtomStateMapMap = new WeakMap();\n\n var getVersionedAtomStateMap = function getVersionedAtomStateMap(version) {\n var versionedAtomStateMap = versionedAtomStateMapMap.get(version);\n\n if (!versionedAtomStateMap) {\n versionedAtomStateMap = new Map();\n versionedAtomStateMapMap.set(version, versionedAtomStateMap);\n }\n\n return versionedAtomStateMap;\n };\n\n var getAtomState = function getAtomState(version, atom) {\n if (version) {\n var versionedAtomStateMap = getVersionedAtomStateMap(version);\n\n var _atomState = versionedAtomStateMap.get(atom);\n\n if (!_atomState) {\n _atomState = getAtomState(version.p, atom);\n\n if (_atomState) {\n if ('p' in _atomState) {\n _atomState.p.then(function () {\n return versionedAtomStateMap.delete(atom);\n });\n }\n\n versionedAtomStateMap.set(atom, _atomState);\n }\n }\n\n return _atomState;\n }\n\n return committedAtomStateMap.get(atom);\n };\n\n var setAtomState = function setAtomState(version, atom, atomState) {\n if (process.env.NODE_ENV !== \"production\") {\n Object.freeze(atomState);\n }\n\n if (version) {\n var versionedAtomStateMap = getVersionedAtomStateMap(version);\n versionedAtomStateMap.set(atom, atomState);\n } else {\n var prevAtomState = committedAtomStateMap.get(atom);\n committedAtomStateMap.set(atom, atomState);\n\n if (!pendingMap.has(atom)) {\n pendingMap.set(atom, prevAtomState);\n }\n }\n };\n\n var createReadDependencies = function createReadDependencies(version, prevReadDependencies, dependencies) {\n if (prevReadDependencies === void 0) {\n prevReadDependencies = new Map();\n }\n\n if (!dependencies) {\n return prevReadDependencies;\n }\n\n var readDependencies = new Map();\n var changed = false;\n dependencies.forEach(function (atom) {\n var _getAtomState;\n\n var revision = ((_getAtomState = getAtomState(version, atom)) == null ? void 0 : _getAtomState.r) || 0;\n readDependencies.set(atom, revision);\n\n if (prevReadDependencies.get(atom) !== revision) {\n changed = true;\n }\n });\n\n if (prevReadDependencies.size === readDependencies.size && !changed) {\n return prevReadDependencies;\n }\n\n return readDependencies;\n };\n\n var setAtomValue = function setAtomValue(version, atom, value, dependencies, suspensePromise) {\n var atomState = getAtomState(version, atom);\n\n if (atomState) {\n if (suspensePromise && (!('p' in atomState) || !isEqualSuspensePromise(atomState.p, suspensePromise))) {\n return atomState;\n }\n\n if ('p' in atomState) {\n cancelSuspensePromise(atomState.p);\n }\n }\n\n var nextAtomState = {\n v: value,\n r: (atomState == null ? void 0 : atomState.r) || 0,\n d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)\n };\n\n if (!atomState || !('v' in atomState) || !Object.is(atomState.v, value)) {\n ++nextAtomState.r;\n\n if (nextAtomState.d.has(atom)) {\n nextAtomState.d = new Map(nextAtomState.d).set(atom, nextAtomState.r);\n }\n } else if (nextAtomState.d !== atomState.d && (nextAtomState.d.size !== atomState.d.size || !Array.from(nextAtomState.d.keys()).every(function (a) {\n return atomState.d.has(a);\n }))) {\n Promise.resolve().then(function () {\n flushPending(version);\n });\n }\n\n setAtomState(version, atom, nextAtomState);\n return nextAtomState;\n };\n\n var setAtomReadError = function setAtomReadError(version, atom, error, dependencies, suspensePromise) {\n var atomState = getAtomState(version, atom);\n\n if (atomState) {\n if (suspensePromise && (!('p' in atomState) || !isEqualSuspensePromise(atomState.p, suspensePromise))) {\n return atomState;\n }\n\n if ('p' in atomState) {\n cancelSuspensePromise(atomState.p);\n }\n }\n\n var nextAtomState = {\n e: error,\n r: (atomState == null ? void 0 : atomState.r) || 0,\n d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)\n };\n setAtomState(version, atom, nextAtomState);\n return nextAtomState;\n };\n\n var setAtomSuspensePromise = function setAtomSuspensePromise(version, atom, suspensePromise, dependencies) {\n var atomState = getAtomState(version, atom);\n\n if (atomState && 'p' in atomState) {\n if (isEqualSuspensePromise(atomState.p, suspensePromise)) {\n return atomState;\n }\n\n cancelSuspensePromise(atomState.p);\n }\n\n addSuspensePromiseToCache(version, atom, suspensePromise);\n var nextAtomState = {\n p: suspensePromise,\n r: (atomState == null ? void 0 : atomState.r) || 0,\n d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)\n };\n setAtomState(version, atom, nextAtomState);\n return nextAtomState;\n };\n\n var setAtomPromiseOrValue = function setAtomPromiseOrValue(version, atom, promiseOrValue, dependencies) {\n if (promiseOrValue instanceof Promise) {\n var suspensePromise = createSuspensePromise(promiseOrValue.then(function (value) {\n setAtomValue(version, atom, value, dependencies, suspensePromise);\n flushPending(version);\n }).catch(function (e) {\n if (e instanceof Promise) {\n if (isSuspensePromise(e)) {\n return e.then(function () {\n readAtomState(version, atom, true);\n });\n }\n\n return e;\n }\n\n setAtomReadError(version, atom, e, dependencies, suspensePromise);\n flushPending(version);\n }));\n return setAtomSuspensePromise(version, atom, suspensePromise, dependencies);\n }\n\n return setAtomValue(version, atom, promiseOrValue, dependencies);\n };\n\n var setAtomInvalidated = function setAtomInvalidated(version, atom) {\n var atomState = getAtomState(version, atom);\n\n if (atomState) {\n var nextAtomState = _extends({}, atomState, {\n i: atomState.r\n });\n\n setAtomState(version, atom, nextAtomState);\n } else if (process.env.NODE_ENV !== \"production\") {\n console.warn('[Bug] could not invalidate non existing atom', atom);\n }\n };\n\n var readAtomState = function readAtomState(version, atom, force) {\n if (!force) {\n var _atomState2 = getAtomState(version, atom);\n\n if (_atomState2) {\n if (_atomState2.r !== _atomState2.i && 'p' in _atomState2 && !isSuspensePromiseAlreadyCancelled(_atomState2.p)) {\n return _atomState2;\n }\n\n _atomState2.d.forEach(function (_, a) {\n if (a !== atom) {\n if (!mountedMap.has(a)) {\n readAtomState(version, a);\n } else {\n var aState = getAtomState(version, a);\n\n if (aState && aState.r === aState.i) {\n readAtomState(version, a);\n }\n }\n }\n });\n\n if (Array.from(_atomState2.d).every(function (_ref) {\n var a = _ref[0],\n r = _ref[1];\n var aState = getAtomState(version, a);\n return aState && 'v' in aState && aState.r === r;\n })) {\n return _atomState2;\n }\n }\n }\n\n var dependencies = new Set();\n\n try {\n var promiseOrValue = atom.read(function (a) {\n dependencies.add(a);\n var aState = a === atom ? getAtomState(version, a) : readAtomState(version, a);\n\n if (aState) {\n if ('e' in aState) {\n throw aState.e;\n }\n\n if ('p' in aState) {\n throw aState.p;\n }\n\n return aState.v;\n }\n\n if (hasInitialValue(a)) {\n return a.init;\n }\n\n throw new Error('no atom init');\n });\n return setAtomPromiseOrValue(version, atom, promiseOrValue, dependencies);\n } catch (errorOrPromise) {\n if (errorOrPromise instanceof Promise) {\n var suspensePromise = createSuspensePromise(errorOrPromise);\n return setAtomSuspensePromise(version, atom, suspensePromise, dependencies);\n }\n\n return setAtomReadError(version, atom, errorOrPromise, dependencies);\n }\n };\n\n var readAtom = function readAtom(readingAtom, version) {\n var atomState = readAtomState(version, readingAtom);\n return atomState;\n };\n\n var addAtom = function addAtom(addingAtom) {\n var mounted = mountedMap.get(addingAtom);\n\n if (!mounted) {\n mounted = mountAtom(addingAtom);\n }\n\n return mounted;\n };\n\n var canUnmountAtom = function canUnmountAtom(atom, mounted) {\n return !mounted.l.size && (!mounted.t.size || mounted.t.size === 1 && mounted.t.has(atom));\n };\n\n var delAtom = function delAtom(deletingAtom) {\n var mounted = mountedMap.get(deletingAtom);\n\n if (mounted && canUnmountAtom(deletingAtom, mounted)) {\n unmountAtom(deletingAtom);\n }\n };\n\n var invalidateDependents = function invalidateDependents(version, atom) {\n var mounted = mountedMap.get(atom);\n mounted == null ? void 0 : mounted.t.forEach(function (dependent) {\n if (dependent !== atom) {\n setAtomInvalidated(version, dependent);\n invalidateDependents(version, dependent);\n }\n });\n };\n\n var writeAtomState = function writeAtomState(version, atom, update) {\n var isSync = true;\n\n var writeGetter = function writeGetter(a, options) {\n var aState = readAtomState(version, a);\n\n if ('e' in aState) {\n throw aState.e;\n }\n\n if ('p' in aState) {\n if (options != null && options.unstable_promise) {\n return aState.p.then(function () {\n return writeGetter(a, options);\n });\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n console.info('Reading pending atom state in write operation. We throw a promise for now.', a);\n }\n\n throw aState.p;\n }\n\n if ('v' in aState) {\n return aState.v;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n console.warn('[Bug] no value found while reading atom in write operation. This is probably a bug.', a);\n }\n\n throw new Error('no value found');\n };\n\n var setter = function setter(a, v) {\n var promiseOrVoid;\n\n if (a === atom) {\n if (!hasInitialValue(a)) {\n throw new Error('atom not writable');\n }\n\n var versionSet = cancelAllSuspensePromiseInCache(a);\n versionSet.forEach(function (cancelledVersion) {\n if (cancelledVersion !== version) {\n setAtomPromiseOrValue(cancelledVersion, a, v);\n }\n });\n setAtomPromiseOrValue(version, a, v);\n invalidateDependents(version, a);\n } else {\n promiseOrVoid = writeAtomState(version, a, v);\n }\n\n if (!isSync) {\n flushPending(version);\n }\n\n return promiseOrVoid;\n };\n\n var promiseOrVoid = atom.write(writeGetter, setter, update);\n isSync = false;\n version = undefined;\n return promiseOrVoid;\n };\n\n var writeAtom = function writeAtom(writingAtom, update, version) {\n var promiseOrVoid = writeAtomState(version, writingAtom, update);\n flushPending(version);\n return promiseOrVoid;\n };\n\n var isActuallyWritableAtom = function isActuallyWritableAtom(atom) {\n return !!atom.write;\n };\n\n var mountAtom = function mountAtom(atom, initialDependent) {\n var mounted = {\n t: new Set(initialDependent && [initialDependent]),\n l: new Set()\n };\n mountedMap.set(atom, mounted);\n\n if (process.env.NODE_ENV !== \"production\") {\n mountedAtoms.add(atom);\n }\n\n var atomState = readAtomState(undefined, atom);\n atomState.d.forEach(function (_, a) {\n var aMounted = mountedMap.get(a);\n\n if (aMounted) {\n aMounted.t.add(atom);\n } else {\n if (a !== atom) {\n mountAtom(a, atom);\n }\n }\n });\n\n if (isActuallyWritableAtom(atom) && atom.onMount) {\n var setAtom = function setAtom(update) {\n return writeAtom(atom, update);\n };\n\n var onUnmount = atom.onMount(setAtom);\n\n if (onUnmount) {\n mounted.u = onUnmount;\n }\n }\n\n return mounted;\n };\n\n var unmountAtom = function unmountAtom(atom) {\n var _mountedMap$get;\n\n var onUnmount = (_mountedMap$get = mountedMap.get(atom)) == null ? void 0 : _mountedMap$get.u;\n\n if (onUnmount) {\n onUnmount();\n }\n\n mountedMap.delete(atom);\n\n if (process.env.NODE_ENV !== \"production\") {\n mountedAtoms.delete(atom);\n }\n\n var atomState = getAtomState(undefined, atom);\n\n if (atomState) {\n atomState.d.forEach(function (_, a) {\n if (a !== atom) {\n var mounted = mountedMap.get(a);\n\n if (mounted) {\n mounted.t.delete(atom);\n\n if (canUnmountAtom(a, mounted)) {\n unmountAtom(a);\n }\n }\n }\n });\n } else if (process.env.NODE_ENV !== \"production\") {\n console.warn('[Bug] could not find atom state to unmount', atom);\n }\n };\n\n var mountDependencies = function mountDependencies(atom, atomState, prevReadDependencies) {\n var dependencies = new Set(atomState.d.keys());\n prevReadDependencies == null ? void 0 : prevReadDependencies.forEach(function (_, a) {\n if (dependencies.has(a)) {\n dependencies.delete(a);\n return;\n }\n\n var mounted = mountedMap.get(a);\n\n if (mounted) {\n mounted.t.delete(atom);\n\n if (canUnmountAtom(a, mounted)) {\n unmountAtom(a);\n }\n }\n });\n dependencies.forEach(function (a) {\n var mounted = mountedMap.get(a);\n\n if (mounted) {\n mounted.t.add(atom);\n } else if (mountedMap.has(atom)) {\n mountAtom(a, atom);\n }\n });\n };\n\n var flushPending = function flushPending(version) {\n if (version) {\n var versionedAtomStateMap = getVersionedAtomStateMap(version);\n versionedAtomStateMap.forEach(function (atomState, atom) {\n if (atomState !== committedAtomStateMap.get(atom)) {\n var mounted = mountedMap.get(atom);\n mounted == null ? void 0 : mounted.l.forEach(function (listener) {\n return listener(version);\n });\n }\n });\n return;\n }\n\n while (pendingMap.size) {\n var pending = Array.from(pendingMap);\n pendingMap.clear();\n pending.forEach(function (_ref2) {\n var atom = _ref2[0],\n prevAtomState = _ref2[1];\n var atomState = getAtomState(undefined, atom);\n\n if (atomState && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {\n mountDependencies(atom, atomState, prevAtomState == null ? void 0 : prevAtomState.d);\n }\n\n var mounted = mountedMap.get(atom);\n mounted == null ? void 0 : mounted.l.forEach(function (listener) {\n return listener();\n });\n });\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n stateListeners.forEach(function (l) {\n return l();\n });\n }\n };\n\n var commitVersionedAtomStateMap = function commitVersionedAtomStateMap(version) {\n var versionedAtomStateMap = getVersionedAtomStateMap(version);\n versionedAtomStateMap.forEach(function (atomState, atom) {\n var prevAtomState = committedAtomStateMap.get(atom);\n\n if (atomState.r > ((prevAtomState == null ? void 0 : prevAtomState.r) || 0) || 'v' in atomState && atomState.r === (prevAtomState == null ? void 0 : prevAtomState.r) && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {\n committedAtomStateMap.set(atom, atomState);\n\n if (atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {\n mountDependencies(atom, atomState, prevAtomState == null ? void 0 : prevAtomState.d);\n }\n }\n });\n };\n\n var commitAtom = function commitAtom(_atom, version) {\n if (version) {\n commitVersionedAtomStateMap(version);\n }\n\n flushPending(undefined);\n };\n\n var subscribeAtom = function subscribeAtom(atom, callback) {\n var mounted = addAtom(atom);\n var listeners = mounted.l;\n listeners.add(callback);\n return function () {\n listeners.delete(callback);\n delAtom(atom);\n };\n };\n\n var restoreAtoms = function restoreAtoms(values, version) {\n for (var _iterator2 = _createForOfIteratorHelperLoose(values), _step2; !(_step2 = _iterator2()).done;) {\n var _step2$value = _step2.value,\n _atom2 = _step2$value[0],\n _value = _step2$value[1];\n\n if (hasInitialValue(_atom2)) {\n setAtomPromiseOrValue(version, _atom2, _value);\n invalidateDependents(version, _atom2);\n }\n }\n\n flushPending(version);\n };\n\n if (process.env.NODE_ENV !== \"production\") {\n var _ref3;\n\n return _ref3 = {}, _ref3[READ_ATOM] = readAtom, _ref3[WRITE_ATOM] = writeAtom, _ref3[COMMIT_ATOM] = commitAtom, _ref3[SUBSCRIBE_ATOM] = subscribeAtom, _ref3[RESTORE_ATOMS] = restoreAtoms, _ref3[DEV_SUBSCRIBE_STATE] = function (l) {\n stateListeners.add(l);\n return function () {\n stateListeners.delete(l);\n };\n }, _ref3[DEV_GET_MOUNTED_ATOMS] = function () {\n return mountedAtoms.values();\n }, _ref3[DEV_GET_ATOM_STATE] = function (a) {\n return committedAtomStateMap.get(a);\n }, _ref3[DEV_GET_MOUNTED] = function (a) {\n return mountedMap.get(a);\n }, _ref3;\n }\n\n return _ref4 = {}, _ref4[READ_ATOM] = readAtom, _ref4[WRITE_ATOM] = writeAtom, _ref4[COMMIT_ATOM] = commitAtom, _ref4[SUBSCRIBE_ATOM] = subscribeAtom, _ref4[RESTORE_ATOMS] = restoreAtoms, _ref4;\n};\nvar createStoreForExport = function createStoreForExport(initialValues) {\n var store = createStore(initialValues);\n\n var get = function get(atom) {\n var atomState = store[READ_ATOM](atom);\n\n if ('e' in atomState) {\n throw atomState.e;\n }\n\n if ('p' in atomState) {\n return undefined;\n }\n\n return atomState.v;\n };\n\n var asyncGet = function asyncGet(atom) {\n return new Promise(function (resolve, reject) {\n var atomState = store[READ_ATOM](atom);\n\n if ('e' in atomState) {\n reject(atomState.e);\n } else if ('p' in atomState) {\n resolve(atomState.p.then(function () {\n return asyncGet(atom);\n }));\n } else {\n resolve(atomState.v);\n }\n });\n };\n\n var set = function set(atom, update) {\n return store[WRITE_ATOM](atom, update);\n };\n\n var sub = function sub(atom, callback) {\n return store[SUBSCRIBE_ATOM](atom, callback);\n };\n\n return {\n get: get,\n asyncGet: asyncGet,\n set: set,\n sub: sub,\n SECRET_INTERNAL_store: store\n };\n};\n\nvar createScopeContainer = function createScopeContainer(initialValues, unstable_createStore) {\n var store = unstable_createStore ? unstable_createStore(initialValues).SECRET_INTERNAL_store : createStore(initialValues);\n return {\n s: store\n };\n};\nvar ScopeContextMap = new Map();\nvar getScopeContext = function getScopeContext(scope) {\n if (!ScopeContextMap.has(scope)) {\n ScopeContextMap.set(scope, react.createContext(createScopeContainer()));\n }\n\n return ScopeContextMap.get(scope);\n};\n\nvar Provider = function Provider(_ref) {\n var children = _ref.children,\n initialValues = _ref.initialValues,\n scope = _ref.scope,\n unstable_createStore = _ref.unstable_createStore,\n unstable_enableVersionedWrite = _ref.unstable_enableVersionedWrite;\n\n var _useState = react.useState(),\n version = _useState[0],\n setVersion = _useState[1];\n\n react.useEffect(function () {\n if (version) {\n scopeContainerRef.current.s[COMMIT_ATOM](null, version);\n delete version.p;\n }\n }, [version]);\n var scopeContainerRef = react.useRef();\n\n if (!scopeContainerRef.current) {\n scopeContainerRef.current = createScopeContainer(initialValues, unstable_createStore);\n\n if (unstable_enableVersionedWrite) {\n scopeContainerRef.current.w = function (write) {\n setVersion(function (parentVersion) {\n var nextVersion = parentVersion ? {\n p: parentVersion\n } : {};\n write(nextVersion);\n return nextVersion;\n });\n };\n }\n }\n\n if (process.env.NODE_ENV !== \"production\" && (typeof process !== 'object' || process.env.NODE_ENV !== 'test')) {\n useDebugState(scopeContainerRef.current);\n }\n\n var ScopeContainerContext = getScopeContext(scope);\n return react.createElement(ScopeContainerContext.Provider, {\n value: scopeContainerRef.current\n }, children);\n};\n\nvar atomToPrintable = function atomToPrintable(atom) {\n return atom.debugLabel || atom.toString();\n};\n\nvar stateToPrintable = function stateToPrintable(_ref2) {\n var store = _ref2[0],\n atoms = _ref2[1];\n return Object.fromEntries(atoms.flatMap(function (atom) {\n var _store$DEV_GET_MOUNTE, _store$DEV_GET_ATOM_S;\n\n var mounted = (_store$DEV_GET_MOUNTE = store[DEV_GET_MOUNTED]) == null ? void 0 : _store$DEV_GET_MOUNTE.call(store, atom);\n\n if (!mounted) {\n return [];\n }\n\n var dependents = mounted.t;\n var atomState = ((_store$DEV_GET_ATOM_S = store[DEV_GET_ATOM_STATE]) == null ? void 0 : _store$DEV_GET_ATOM_S.call(store, atom)) || {};\n return [[atomToPrintable(atom), _extends({}, 'e' in atomState && {\n error: atomState.e\n }, 'p' in atomState && {\n promise: atomState.p\n }, 'v' in atomState && {\n value: atomState.v\n }, {\n dependents: Array.from(dependents).map(atomToPrintable)\n })]];\n }));\n};\n\nvar useDebugState = function useDebugState(scopeContainer) {\n var store = scopeContainer.s;\n\n var _useState2 = react.useState([]),\n atoms = _useState2[0],\n setAtoms = _useState2[1];\n\n react.useEffect(function () {\n var _store$DEV_SUBSCRIBE_;\n\n var callback = function callback() {\n var _store$DEV_GET_MOUNTE2;\n\n setAtoms(Array.from(((_store$DEV_GET_MOUNTE2 = store[DEV_GET_MOUNTED_ATOMS]) == null ? void 0 : _store$DEV_GET_MOUNTE2.call(store)) || []));\n };\n\n var unsubscribe = (_store$DEV_SUBSCRIBE_ = store[DEV_SUBSCRIBE_STATE]) == null ? void 0 : _store$DEV_SUBSCRIBE_.call(store, callback);\n callback();\n return unsubscribe;\n }, [store]);\n react.useDebugValue([store, atoms], stateToPrintable);\n};\n\nvar keyCount = 0;\nfunction atom(read, write) {\n var key = \"atom\" + ++keyCount;\n var config = {\n toString: function toString() {\n return key;\n }\n };\n\n if (typeof read === 'function') {\n config.read = read;\n } else {\n config.init = read;\n\n config.read = function (get) {\n return get(config);\n };\n\n config.write = function (get, set, update) {\n return set(config, typeof update === 'function' ? update(get(config)) : update);\n };\n }\n\n if (write) {\n config.write = write;\n }\n\n return config;\n}\n\nfunction useAtomValue(atom, scope) {\n var ScopeContext = getScopeContext(scope);\n\n var _useContext = react.useContext(ScopeContext),\n store = _useContext.s;\n\n var getAtomValue = react.useCallback(function (version) {\n var atomState = store[READ_ATOM](atom, version);\n\n if ('e' in atomState) {\n throw atomState.e;\n }\n\n if ('p' in atomState) {\n throw atomState.p;\n }\n\n if ('v' in atomState) {\n return atomState.v;\n }\n\n throw new Error('no atom value');\n }, [store, atom]);\n\n var _useReducer = react.useReducer(react.useCallback(function (prev, nextVersion) {\n var nextValue = getAtomValue(nextVersion);\n\n if (Object.is(prev[1], nextValue) && prev[2] === atom) {\n return prev;\n }\n\n return [nextVersion, nextValue, atom];\n }, [getAtomValue, atom]), undefined, function () {\n var initialVersion = undefined;\n var initialValue = getAtomValue(initialVersion);\n return [initialVersion, initialValue, atom];\n }),\n _useReducer$ = _useReducer[0],\n version = _useReducer$[0],\n value = _useReducer$[1],\n atomFromUseReducer = _useReducer$[2],\n rerenderIfChanged = _useReducer[1];\n\n if (atomFromUseReducer !== atom) {\n rerenderIfChanged(undefined);\n }\n\n react.useEffect(function () {\n var unsubscribe = store[SUBSCRIBE_ATOM](atom, rerenderIfChanged);\n rerenderIfChanged(undefined);\n return unsubscribe;\n }, [store, atom]);\n react.useEffect(function () {\n store[COMMIT_ATOM](atom, version);\n });\n react.useDebugValue(value);\n return value;\n}\n\nfunction useSetAtom(atom, scope) {\n var ScopeContext = getScopeContext(scope);\n\n var _useContext = react.useContext(ScopeContext),\n store = _useContext.s,\n versionedWrite = _useContext.w;\n\n var setAtom = react.useCallback(function (update) {\n if (!('write' in atom) && typeof process === 'object' && process.env.NODE_ENV !== 'production') {\n throw new Error('not writable atom');\n }\n\n var write = function write(version) {\n return store[WRITE_ATOM](atom, update, version);\n };\n\n return versionedWrite ? versionedWrite(write) : write();\n }, [store, versionedWrite, atom]);\n return setAtom;\n}\n\nfunction useAtom(atom, scope) {\n if ('scope' in atom) {\n console.warn('atom.scope is deprecated. Please do useAtom(atom, scope) instead.');\n scope = atom.scope;\n }\n\n return [useAtomValue(atom, scope), useSetAtom(atom, scope)];\n}\n\nexports.Provider = Provider;\nexports.SECRET_INTERNAL_getScopeContext = getScopeContext;\nexports.atom = atom;\nexports.unstable_createStore = createStoreForExport;\nexports.useAtom = useAtom;\nexports.useAtomValue = useAtomValue;\nexports.useSetAtom = useSetAtom;\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","import { scheduleMicrotask } from './utils'; // TYPES\n\n// CLASS\nexport var NotifyManager = /*#__PURE__*/function () {\n function NotifyManager() {\n this.queue = [];\n this.transactions = 0;\n\n this.notifyFn = function (callback) {\n callback();\n };\n\n this.batchNotifyFn = function (callback) {\n callback();\n };\n }\n\n var _proto = NotifyManager.prototype;\n\n _proto.batch = function batch(callback) {\n var result;\n this.transactions++;\n\n try {\n result = callback();\n } finally {\n this.transactions--;\n\n if (!this.transactions) {\n this.flush();\n }\n }\n\n return result;\n };\n\n _proto.schedule = function schedule(callback) {\n var _this = this;\n\n if (this.transactions) {\n this.queue.push(callback);\n } else {\n scheduleMicrotask(function () {\n _this.notifyFn(callback);\n });\n }\n }\n /**\n * All calls to the wrapped function will be batched.\n */\n ;\n\n _proto.batchCalls = function batchCalls(callback) {\n var _this2 = this;\n\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this2.schedule(function () {\n callback.apply(void 0, args);\n });\n };\n };\n\n _proto.flush = function flush() {\n var _this3 = this;\n\n var queue = this.queue;\n this.queue = [];\n\n if (queue.length) {\n scheduleMicrotask(function () {\n _this3.batchNotifyFn(function () {\n queue.forEach(function (callback) {\n _this3.notifyFn(callback);\n });\n });\n });\n }\n }\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n ;\n\n _proto.setNotifyFunction = function setNotifyFunction(fn) {\n this.notifyFn = fn;\n }\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n ;\n\n _proto.setBatchNotifyFunction = function setBatchNotifyFunction(fn) {\n this.batchNotifyFn = fn;\n };\n\n return NotifyManager;\n}(); // SINGLETON\n\nexport var notifyManager = new NotifyManager();","import reanimatedJS from '../js-reanimated';\nimport { shouldBeUseWeb } from '../PlatformChecker';\nimport { NativeReanimated } from './NativeReanimated';\nlet exportedModule;\nif (shouldBeUseWeb()) {\n exportedModule = reanimatedJS;\n}\nelse {\n exportedModule = new NativeReanimated();\n}\nexport default exportedModule;\n","import { Platform } from 'react-native';\nexport function isJest() {\n return !!process.env.JEST_WORKER_ID;\n}\nexport function isChromeDebugger() {\n return !global.nativeCallSyncHook || global.__REMOTEDEV__;\n}\nexport function isWeb() {\n return Platform.OS === 'web';\n}\nexport function shouldBeUseWeb() {\n return isJest() || isChromeDebugger() || isWeb();\n}\nexport function nativeShouldBeMock() {\n return isJest() || isChromeDebugger();\n}\n","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/**\n * Copyright (c) Nicolas Gallagher.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport * as React from 'react';\nimport createElement from '../createElement';\nimport css from '../StyleSheet/css';\nimport * as forwardedProps from '../../modules/forwardedProps';\nimport pick from '../../modules/pick';\nimport useElementLayout from '../../modules/useElementLayout';\nimport useMergeRefs from '../../modules/useMergeRefs';\nimport usePlatformMethods from '../../modules/usePlatformMethods';\nimport useResponderEvents from '../../modules/useResponderEvents';\nimport StyleSheet from '../StyleSheet';\nimport TextAncestorContext from './TextAncestorContext';\n\nvar forwardPropsList = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, forwardedProps.defaultProps), forwardedProps.accessibilityProps), forwardedProps.clickProps), forwardedProps.focusProps), forwardedProps.keyboardProps), forwardedProps.mouseProps), forwardedProps.touchProps), forwardedProps.styleProps), {}, {\n href: true,\n lang: true,\n pointerEvents: true\n});\n\nvar pickProps = function pickProps(props) {\n return pick(props, forwardPropsList);\n};\n\nvar Text = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {\n var dir = props.dir,\n hrefAttrs = props.hrefAttrs,\n numberOfLines = props.numberOfLines,\n onClick = props.onClick,\n onLayout = props.onLayout,\n onPress = props.onPress,\n onMoveShouldSetResponder = props.onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture = props.onMoveShouldSetResponderCapture,\n onResponderEnd = props.onResponderEnd,\n onResponderGrant = props.onResponderGrant,\n onResponderMove = props.onResponderMove,\n onResponderReject = props.onResponderReject,\n onResponderRelease = props.onResponderRelease,\n onResponderStart = props.onResponderStart,\n onResponderTerminate = props.onResponderTerminate,\n onResponderTerminationRequest = props.onResponderTerminationRequest,\n onScrollShouldSetResponder = props.onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture = props.onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder = props.onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture = props.onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder = props.onStartShouldSetResponder,\n onStartShouldSetResponderCapture = props.onStartShouldSetResponderCapture,\n selectable = props.selectable;\n var hasTextAncestor = React.useContext(TextAncestorContext);\n var hostRef = React.useRef(null);\n var classList = [classes.text, hasTextAncestor === true && classes.textHasAncestor, numberOfLines === 1 && classes.textOneLine, numberOfLines != null && numberOfLines > 1 && classes.textMultiLine];\n var style = [props.style, numberOfLines != null && numberOfLines > 1 && {\n WebkitLineClamp: numberOfLines\n }, selectable === true && styles.selectable, selectable === false && styles.notSelectable, onPress && styles.pressable];\n useElementLayout(hostRef, onLayout);\n useResponderEvents(hostRef, {\n onMoveShouldSetResponder: onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture: onMoveShouldSetResponderCapture,\n onResponderEnd: onResponderEnd,\n onResponderGrant: onResponderGrant,\n onResponderMove: onResponderMove,\n onResponderReject: onResponderReject,\n onResponderRelease: onResponderRelease,\n onResponderStart: onResponderStart,\n onResponderTerminate: onResponderTerminate,\n onResponderTerminationRequest: onResponderTerminationRequest,\n onScrollShouldSetResponder: onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture: onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder: onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture: onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder: onStartShouldSetResponder,\n onStartShouldSetResponderCapture: onStartShouldSetResponderCapture\n });\n var handleClick = React.useCallback(function (e) {\n if (onClick != null) {\n onClick(e);\n } else if (onPress != null) {\n e.stopPropagation();\n onPress(e);\n }\n }, [onClick, onPress]);\n var component = hasTextAncestor ? 'span' : 'div';\n var supportedProps = pickProps(props);\n supportedProps.classList = classList;\n supportedProps.dir = dir; // 'auto' by default allows browsers to infer writing direction (root elements only)\n\n if (!hasTextAncestor) {\n supportedProps.dir = dir != null ? dir : 'auto';\n }\n\n if (onClick || onPress) {\n supportedProps.onClick = handleClick;\n }\n\n supportedProps.style = style;\n\n if (props.href != null) {\n component = 'a';\n\n if (hrefAttrs != null) {\n var download = hrefAttrs.download,\n rel = hrefAttrs.rel,\n target = hrefAttrs.target;\n\n if (download != null) {\n supportedProps.download = download;\n }\n\n if (rel != null) {\n supportedProps.rel = rel;\n }\n\n if (typeof target === 'string') {\n supportedProps.target = target.charAt(0) !== '_' ? '_' + target : target;\n }\n }\n }\n\n var platformMethodsRef = usePlatformMethods(supportedProps);\n var setRef = useMergeRefs(hostRef, platformMethodsRef, forwardedRef);\n supportedProps.ref = setRef;\n var element = createElement(component, supportedProps);\n return hasTextAncestor ? element : /*#__PURE__*/React.createElement(TextAncestorContext.Provider, {\n value: true\n }, element);\n});\nText.displayName = 'Text';\nvar classes = css.create({\n text: {\n border: '0 solid black',\n boxSizing: 'border-box',\n color: 'black',\n display: 'inline',\n font: '14px System',\n margin: 0,\n padding: 0,\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word'\n },\n textHasAncestor: {\n color: 'inherit',\n font: 'inherit',\n whiteSpace: 'inherit'\n },\n textOneLine: {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n wordWrap: 'normal'\n },\n // See #13\n textMultiLine: {\n display: '-webkit-box',\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n WebkitBoxOrient: 'vertical'\n }\n});\nvar styles = StyleSheet.create({\n notSelectable: {\n userSelect: 'none'\n },\n selectable: {\n userSelect: 'text'\n },\n pressable: {\n cursor: 'pointer'\n }\n});\nexport default Text;","/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\n'use strict';\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport AnimatedInterpolation from './AnimatedInterpolation';\nimport AnimatedWithChildren from './AnimatedWithChildren';\nimport InteractionManager from '../../../../exports/InteractionManager';\nimport NativeAnimatedHelper from '../NativeAnimatedHelper';\nvar NativeAnimatedAPI = NativeAnimatedHelper.API;\n/**\n * Animated works by building a directed acyclic graph of dependencies\n * transparently when you render your Animated components.\n *\n * new Animated.Value(0)\n * .interpolate() .interpolate() new Animated.Value(1)\n * opacity translateY scale\n * style transform\n * View#234 style\n * View#123\n *\n * A) Top Down phase\n * When an Animated.Value is updated, we recursively go down through this\n * graph in order to find leaf nodes: the views that we flag as needing\n * an update.\n *\n * B) Bottom Up phase\n * When a view is flagged as needing an update, we recursively go back up\n * in order to build the new value that it needs. The reason why we need\n * this two-phases process is to deal with composite props such as\n * transform which can receive values from multiple parents.\n */\n\nfunction _flush(rootNode) {\n var animatedStyles = new Set();\n\n function findAnimatedStyles(node) {\n /* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an\n * error found when Flow v0.68 was deployed. To see the error delete this\n * comment and run Flow. */\n if (typeof node.update === 'function') {\n animatedStyles.add(node);\n } else {\n node.__getChildren().forEach(findAnimatedStyles);\n }\n }\n\n findAnimatedStyles(rootNode);\n /* $FlowFixMe */\n\n animatedStyles.forEach(function (animatedStyle) {\n return animatedStyle.update();\n });\n}\n/**\n * Standard value for driving animations. One `Animated.Value` can drive\n * multiple properties in a synchronized fashion, but can only be driven by one\n * mechanism at a time. Using a new mechanism (e.g. starting a new animation,\n * or calling `setValue`) will stop any previous ones.\n *\n * See https://reactnative.dev/docs/animatedvalue.html\n */\n\n\nvar AnimatedValue = /*#__PURE__*/function (_AnimatedWithChildren) {\n _inheritsLoose(AnimatedValue, _AnimatedWithChildren);\n\n function AnimatedValue(value) {\n var _this;\n\n _this = _AnimatedWithChildren.call(this) || this;\n\n if (typeof value !== 'number') {\n throw new Error('AnimatedValue: Attempting to set value to undefined');\n }\n\n _this._startingValue = _this._value = value;\n _this._offset = 0;\n _this._animation = null;\n return _this;\n }\n\n var _proto = AnimatedValue.prototype;\n\n _proto.__detach = function __detach() {\n var _this2 = this;\n\n if (this.__isNative) {\n NativeAnimatedAPI.getValue(this.__getNativeTag(), function (value) {\n _this2._value = value;\n });\n }\n\n this.stopAnimation();\n\n _AnimatedWithChildren.prototype.__detach.call(this);\n };\n\n _proto.__getValue = function __getValue() {\n return this._value + this._offset;\n }\n /**\n * Directly set the value. This will stop any animations running on the value\n * and update all the bound properties.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#setvalue\n */\n ;\n\n _proto.setValue = function setValue(value) {\n if (this._animation) {\n this._animation.stop();\n\n this._animation = null;\n }\n\n this._updateValue(value, !this.__isNative\n /* don't perform a flush for natively driven values */\n );\n\n if (this.__isNative) {\n NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value);\n }\n }\n /**\n * Sets an offset that is applied on top of whatever value is set, whether via\n * `setValue`, an animation, or `Animated.event`. Useful for compensating\n * things like the start of a pan gesture.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#setoffset\n */\n ;\n\n _proto.setOffset = function setOffset(offset) {\n this._offset = offset;\n\n if (this.__isNative) {\n NativeAnimatedAPI.setAnimatedNodeOffset(this.__getNativeTag(), offset);\n }\n }\n /**\n * Merges the offset value into the base value and resets the offset to zero.\n * The final output of the value is unchanged.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#flattenoffset\n */\n ;\n\n _proto.flattenOffset = function flattenOffset() {\n this._value += this._offset;\n this._offset = 0;\n\n if (this.__isNative) {\n NativeAnimatedAPI.flattenAnimatedNodeOffset(this.__getNativeTag());\n }\n }\n /**\n * Sets the offset value to the base value, and resets the base value to zero.\n * The final output of the value is unchanged.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#extractoffset\n */\n ;\n\n _proto.extractOffset = function extractOffset() {\n this._offset += this._value;\n this._value = 0;\n\n if (this.__isNative) {\n NativeAnimatedAPI.extractAnimatedNodeOffset(this.__getNativeTag());\n }\n }\n /**\n * Stops any running animation or tracking. `callback` is invoked with the\n * final value after stopping the animation, which is useful for updating\n * state to match the animation position with layout.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#stopanimation\n */\n ;\n\n _proto.stopAnimation = function stopAnimation(callback) {\n this.stopTracking();\n this._animation && this._animation.stop();\n this._animation = null;\n callback && callback(this.__getValue());\n }\n /**\n * Stops any animation and resets the value to its original.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#resetanimation\n */\n ;\n\n _proto.resetAnimation = function resetAnimation(callback) {\n this.stopAnimation(callback);\n this._value = this._startingValue;\n };\n\n _proto._onAnimatedValueUpdateReceived = function _onAnimatedValueUpdateReceived(value) {\n this._updateValue(value, false\n /*flush*/\n );\n }\n /**\n * Interpolates the value before updating the property, e.g. mapping 0-1 to\n * 0-10.\n */\n ;\n\n _proto.interpolate = function interpolate(config) {\n return new AnimatedInterpolation(this, config);\n }\n /**\n * Typically only used internally, but could be used by a custom Animation\n * class.\n *\n * See https://reactnative.dev/docs/animatedvalue.html#animate\n */\n ;\n\n _proto.animate = function animate(animation, callback) {\n var _this3 = this;\n\n var handle = null;\n\n if (animation.__isInteraction) {\n handle = InteractionManager.createInteractionHandle();\n }\n\n var previousAnimation = this._animation;\n this._animation && this._animation.stop();\n this._animation = animation;\n animation.start(this._value, function (value) {\n // Natively driven animations will never call into that callback, therefore we can always\n // pass flush = true to allow the updated value to propagate to native with setNativeProps\n _this3._updateValue(value, true\n /* flush */\n );\n }, function (result) {\n _this3._animation = null;\n\n if (handle !== null) {\n InteractionManager.clearInteractionHandle(handle);\n }\n\n callback && callback(result);\n }, previousAnimation, this);\n }\n /**\n * Typically only used internally.\n */\n ;\n\n _proto.stopTracking = function stopTracking() {\n this._tracking && this._tracking.__detach();\n this._tracking = null;\n }\n /**\n * Typically only used internally.\n */\n ;\n\n _proto.track = function track(tracking) {\n this.stopTracking();\n this._tracking = tracking;\n };\n\n _proto._updateValue = function _updateValue(value, flush) {\n if (value === undefined) {\n throw new Error('AnimatedValue: Attempting to set value to undefined');\n }\n\n this._value = value;\n\n if (flush) {\n _flush(this);\n }\n\n _AnimatedWithChildren.prototype.__callListeners.call(this, this.__getValue());\n };\n\n _proto.__getNativeConfig = function __getNativeConfig() {\n return {\n type: 'value',\n value: this._value,\n offset: this._offset\n };\n };\n\n return AnimatedValue;\n}(AnimatedWithChildren);\n\nexport default AnimatedValue;","!function(t,e){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define(e):(t=\"undefined\"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){\"use strict\";var t=1e3,e=6e4,n=36e5,r=\"millisecond\",i=\"second\",s=\"minute\",u=\"hour\",a=\"day\",o=\"week\",f=\"month\",h=\"quarter\",c=\"year\",d=\"date\",$=\"Invalid Date\",l=/^(\\d{4})[-/]?(\\d{1,2})?[-/]?(\\d{0,2})[Tt\\s]*(\\d{1,2})?:?(\\d{1,2})?:?(\\d{1,2})?[.:]?(\\d+)?$/,y=/\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:\"en\",weekdays:\"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday\".split(\"_\"),months:\"January_February_March_April_May_June_July_August_September_October_November_December\".split(\"_\")},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:\"\"+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?\"+\":\"-\")+m(r,2,\"0\")+\":\"+m(i,2,\"0\")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(v=i),i||!r&&v},w=function(t,e){if(p(t))return t.clone();var n=\"object\"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if(\"string\"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||\"0\").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t) -> React.createRef.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { EventType } from '../EventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf;\n}\n\nexport interface HandlerStateChangeEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf;\n oldState: ValueOf;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent> {\n nativeEvent: Readonly;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record\n> {\n nativeEvent: Readonly;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf;\n eventType: EventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<\n GestureEventPayloadT = Record\n> = GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record = Record\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref | React.Ref[];\n simultaneousHandlers?: React.Ref | React.Ref[];\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent\n ) => void;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record,\n validProps: string[],\n defaults: Record = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component | React.ComponentClass\n): null | number | React.Component | React.ComponentClass {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n","/**\n * https://github.com/gre/bezier-easing\n * BezierEasing - use bezier curve for transition easing function\n * by Gaëtan Renaudeau 2014 - 2015 – MIT License\n */\n// These values are established by empiricism with tests (tradeoff: performance VS precision)\nexport function Bezier(mX1, mY1, mX2, mY2) {\n 'worklet';\n const NEWTON_ITERATIONS = 4;\n const NEWTON_MIN_SLOPE = 0.001;\n const SUBDIVISION_PRECISION = 0.0000001;\n const SUBDIVISION_MAX_ITERATIONS = 10;\n const kSplineTableSize = 11;\n const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);\n function A(aA1, aA2) {\n 'worklet';\n return 1.0 - 3.0 * aA2 + 3.0 * aA1;\n }\n function B(aA1, aA2) {\n 'worklet';\n return 3.0 * aA2 - 6.0 * aA1;\n }\n function C(aA1) {\n 'worklet';\n return 3.0 * aA1;\n }\n // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.\n function calcBezier(aT, aA1, aA2) {\n 'worklet';\n return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;\n }\n // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.\n function getSlope(aT, aA1, aA2) {\n 'worklet';\n return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);\n }\n function binarySubdivide(aX, aA, aB, mX1, mX2) {\n 'worklet';\n let currentX;\n let currentT;\n let i = 0;\n do {\n currentT = aA + (aB - aA) / 2.0;\n currentX = calcBezier(currentT, mX1, mX2) - aX;\n if (currentX > 0.0) {\n aB = currentT;\n }\n else {\n aA = currentT;\n }\n } while (Math.abs(currentX) > SUBDIVISION_PRECISION &&\n ++i < SUBDIVISION_MAX_ITERATIONS);\n return currentT;\n }\n function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {\n 'worklet';\n for (let i = 0; i < NEWTON_ITERATIONS; ++i) {\n const currentSlope = getSlope(aGuessT, mX1, mX2);\n if (currentSlope === 0.0) {\n return aGuessT;\n }\n const currentX = calcBezier(aGuessT, mX1, mX2) - aX;\n aGuessT -= currentX / currentSlope;\n }\n return aGuessT;\n }\n function LinearEasing(x) {\n 'worklet';\n return x;\n }\n if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {\n throw new Error('bezier x values must be in [0, 1] range');\n }\n if (mX1 === mY1 && mX2 === mY2) {\n return LinearEasing;\n }\n // FIXME: Float32Array is not available in Hermes right now\n //\n // var float32ArraySupported = typeof Float32Array === 'function';\n // const sampleValues = float32ArraySupported\n // ? new Float32Array(kSplineTableSize)\n // : new Array(kSplineTableSize);\n // Precompute samples table\n const sampleValues = new Array(kSplineTableSize);\n for (let i = 0; i < kSplineTableSize; ++i) {\n sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);\n }\n function getTForX(aX) {\n 'worklet';\n let intervalStart = 0.0;\n let currentSample = 1;\n const lastSample = kSplineTableSize - 1;\n for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {\n intervalStart += kSampleStepSize;\n }\n --currentSample;\n // Interpolate to provide an initial guess for t\n const dist = (aX - sampleValues[currentSample]) /\n (sampleValues[currentSample + 1] - sampleValues[currentSample]);\n const guessForT = intervalStart + dist * kSampleStepSize;\n const initialSlope = getSlope(guessForT, mX1, mX2);\n if (initialSlope >= NEWTON_MIN_SLOPE) {\n return newtonRaphsonIterate(aX, guessForT, mX1, mX2);\n }\n else if (initialSlope === 0.0) {\n return guessForT;\n }\n else {\n return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);\n }\n }\n return function BezierEasing(x) {\n 'worklet';\n if (mX1 === mY1 && mX2 === mY2) {\n return x; // linear\n }\n // Because JavaScript number are imprecise, we should guarantee the extremes are right.\n if (x === 0) {\n return 0;\n }\n if (x === 1) {\n return 1;\n }\n return calcBezier(getTForX(x), mY1, mY2);\n };\n}\n","// spread and rest parameters can't be used in worklets right now\n/* eslint-disable prefer-rest-params */\n/* eslint-disable prefer-spread */\n/* global _WORKLET */\n// @ts-ignore reanimated1/Easing is JS file\nimport EasingNode from '../reanimated1/Easing';\nimport { Bezier } from './Bezier';\n/**\n * A linear function, `f(t) = t`. Position correlates to elapsed time one to\n * one.\n *\n * http://cubic-bezier.com/#0,0,1,1\n */\nfunction linear(t) {\n 'worklet';\n return t;\n}\n/**\n * A simple inertial interaction, similar to an object slowly accelerating to\n * speed.\n *\n * http://cubic-bezier.com/#.42,0,1,1\n */\nfunction ease(t) {\n 'worklet';\n return Bezier(0.42, 0, 1, 1)(t);\n}\n/**\n * A quadratic function, `f(t) = t * t`. Position equals the square of elapsed\n * time.\n *\n * http://easings.net/#easeInQuad\n */\nfunction quad(t) {\n 'worklet';\n return t * t;\n}\n/**\n * A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed\n * time.\n *\n * http://easings.net/#easeInCubic\n */\nfunction cubic(t) {\n 'worklet';\n return t * t * t;\n}\n/**\n * A power function. Position is equal to the Nth power of elapsed time.\n *\n * n = 4: http://easings.net/#easeInQuart\n * n = 5: http://easings.net/#easeInQuint\n */\nfunction poly(n) {\n 'worklet';\n return (t) => {\n 'worklet';\n return Math.pow(t, n);\n };\n}\n/**\n * A sinusoidal function.\n *\n * http://easings.net/#easeInSine\n */\nfunction sin(t) {\n 'worklet';\n return 1 - Math.cos((t * Math.PI) / 2);\n}\n/**\n * A circular function.\n *\n * http://easings.net/#easeInCirc\n */\nfunction circle(t) {\n 'worklet';\n return 1 - Math.sqrt(1 - t * t);\n}\n/**\n * An exponential function.\n *\n * http://easings.net/#easeInExpo\n */\nfunction exp(t) {\n 'worklet';\n return Math.pow(2, 10 * (t - 1));\n}\n/**\n * A simple elastic interaction, similar to a spring oscillating back and\n * forth.\n *\n * Default bounciness is 1, which overshoots a little bit once. 0 bounciness\n * doesn't overshoot at all, and bounciness of N > 1 will overshoot about N\n * times.\n *\n * http://easings.net/#easeInElastic\n */\nfunction elastic(bounciness = 1) {\n 'worklet';\n const p = bounciness * Math.PI;\n return (t) => {\n 'worklet';\n return 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);\n };\n}\n/**\n * Use with `Animated.parallel()` to create a simple effect where the object\n * animates back slightly as the animation starts.\n *\n * Wolfram Plot:\n *\n * - http://tiny.cc/back_default (s = 1.70158, default)\n */\nfunction back(s = 1.70158) {\n 'worklet';\n return (t) => {\n 'worklet';\n return t * t * ((s + 1) * t - s);\n };\n}\n/**\n * Provides a simple bouncing effect.\n *\n * http://easings.net/#easeInBounce\n */\nfunction bounce(t) {\n 'worklet';\n if (t < 1 / 2.75) {\n return 7.5625 * t * t;\n }\n if (t < 2 / 2.75) {\n const t2 = t - 1.5 / 2.75;\n return 7.5625 * t2 * t2 + 0.75;\n }\n if (t < 2.5 / 2.75) {\n const t2 = t - 2.25 / 2.75;\n return 7.5625 * t2 * t2 + 0.9375;\n }\n const t2 = t - 2.625 / 2.75;\n return 7.5625 * t2 * t2 + 0.984375;\n}\n/**\n * Provides a cubic bezier curve, equivalent to CSS Transitions'\n * `transition-timing-function`.\n *\n * A useful tool to visualize cubic bezier curves can be found at\n * http://cubic-bezier.com/\n */\nfunction bezier(x1, y1, x2, y2) {\n 'worklet';\n return {\n factory: () => {\n 'worklet';\n return Bezier(x1, y1, x2, y2);\n },\n };\n}\nfunction bezierFn(x1, y1, x2, y2) {\n 'worklet';\n return Bezier(x1, y1, x2, y2);\n}\n/**\n * Runs an easing function forwards.\n */\nfunction in_(easing) {\n 'worklet';\n return easing;\n}\n/**\n * Runs an easing function backwards.\n */\nfunction out(easing) {\n 'worklet';\n return (t) => {\n 'worklet';\n return 1 - easing(1 - t);\n };\n}\n/**\n * Makes any easing function symmetrical. The easing function will run\n * forwards for half of the duration, then backwards for the rest of the\n * duration.\n */\nfunction inOut(easing) {\n 'worklet';\n return (t) => {\n 'worklet';\n if (t < 0.5) {\n return easing(t * 2) / 2;\n }\n return 1 - easing((1 - t) * 2) / 2;\n };\n}\nconst EasingObject = {\n linear,\n ease,\n quad,\n cubic,\n poly,\n sin,\n circle,\n exp,\n elastic,\n back,\n bounce,\n bezier,\n bezierFn,\n in: in_,\n out,\n inOut,\n};\n// TODO type worklets\nfunction createChecker(worklet, workletName, prevArgs) {\n /* should return Animated.Value or worklet */\n function checkIfReaOne() {\n 'worklet';\n if (arguments && !_WORKLET) {\n for (let i = 0; i < arguments.length; i++) {\n const arg = arguments[i];\n if (arg && arg.__nodeID) {\n console.warn(`Easing was renamed to EasingNode in Reanimated 2. Please use EasingNode instead`);\n if (prevArgs) {\n return EasingNode[workletName]\n .apply(undefined, prevArgs)\n .apply(undefined, arguments);\n }\n return EasingNode[workletName].apply(undefined, arguments);\n }\n }\n }\n // @ts-ignore this is implicitly any - TODO\n const res = worklet.apply(this, arguments);\n if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {\n return createChecker(res, workletName, arguments);\n }\n return res;\n }\n // use original worklet on UI side\n checkIfReaOne._closure = worklet._closure;\n checkIfReaOne.asString = worklet.asString;\n checkIfReaOne.__workletHash = worklet.__workletHash;\n checkIfReaOne.__location = worklet.__location;\n return checkIfReaOne;\n}\nObject.keys(EasingObject).forEach((key) => {\n EasingObject[key] = createChecker(EasingObject[key], key);\n});\nexport const Easing = EasingObject;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import { useEffect, useRef } from 'react';\nimport { processColor } from '../Colors';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport { colorProps } from '../UpdateProps';\nimport WorkletEventHandler from '../WorkletEventHandler';\nexport function useEvent(handler, eventNames = [], rebuild = false) {\n const initRef = useRef(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler(handler, eventNames);\n }\n else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n return initRef;\n}\nexport function useHandler(handlers, dependencies) {\n const initRef = useRef(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote({}),\n savedDependencies: [],\n };\n }\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n const { context, savedDependencies } = initRef.current;\n dependencies = buildDependencies(dependencies, handlers);\n const doDependenciesDiffer = !areDependenciesEqual(dependencies, savedDependencies);\n initRef.current.savedDependencies = dependencies;\n const useWeb = isWeb() || isJest();\n return { context, doDependenciesDiffer, useWeb };\n}\n// builds one big hash from multiple worklets' hashes\nexport function buildWorkletsHash(handlers) {\n return Object.values(handlers).reduce((acc, worklet) => \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n acc + worklet.__workletHash.toString(), '');\n}\n// builds dependencies array for gesture handlers\nexport function buildDependencies(dependencies, handlers) {\n const handlersList = Object.values(handlers).filter((handler) => handler !== undefined);\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler._closure,\n };\n });\n }\n else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n return dependencies;\n}\n// this is supposed to work as useEffect comparison\nexport function areDependenciesEqual(nextDeps, prevDeps) {\n function is(x, y) {\n /* eslint-disable no-self-compare */\n return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);\n /* eslint-enable no-self-compare */\n }\n const objectIs = typeof Object.is === 'function' ? Object.is : is;\n function areHookInputsEqual(nextDeps, prevDeps) {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n return areHookInputsEqual(nextDeps, prevDeps);\n}\nexport function hasColorProps(updates) {\n const colorPropsSet = new Set(colorProps);\n for (const key in updates) {\n if (colorPropsSet.has(key)) {\n return true;\n }\n }\n return false;\n}\nexport function parseColors(updates) {\n 'worklet';\n for (const key in updates) {\n if (colorProps.indexOf(key) !== -1) {\n // value could be an animation in which case processColor will recognize it and will return undefined\n // -> in such a case we don't want to override style of that key\n const processedColor = processColor(updates[key]);\n if (processedColor !== undefined) {\n updates[key] = processedColor;\n }\n }\n }\n}\nexport function canApplyOptimalisation(upadterFn) {\n const FUNCTIONLESS_FLAG = 0b00000001;\n const STATEMENTLESS_FLAG = 0b00000010;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const optimalization = upadterFn.__optimalization;\n return (optimalization & FUNCTIONLESS_FLAG && optimalization & STATEMENTLESS_FLAG);\n}\nexport function isAnimated(prop) {\n 'worklet';\n const propsToCheck = [prop];\n while (propsToCheck.length > 0) {\n const currentProp = propsToCheck.pop();\n if (Array.isArray(currentProp)) {\n for (const item of currentProp) {\n propsToCheck.push(item);\n }\n }\n else if ((currentProp === null || currentProp === void 0 ? void 0 : currentProp.onFrame) !== undefined) {\n return true;\n }\n else if (typeof currentProp === 'object') {\n for (const item of Object.values(currentProp)) {\n propsToCheck.push(item);\n }\n }\n // if none of the above, it's not the animated prop, check next one\n }\n // when none of the props were animated return false\n return false;\n}\nexport function styleDiff(oldStyle, newStyle) {\n 'worklet';\n const diff = {};\n for (const key in oldStyle) {\n if (newStyle[key] === undefined) {\n diff[key] = null;\n }\n }\n for (const key in newStyle) {\n const value = newStyle[key];\n const oldValue = oldStyle[key];\n if (isAnimated(value)) {\n // do nothing\n continue;\n }\n if (oldValue !== value) {\n diff[key] = value;\n }\n }\n return diff;\n}\nexport function getStyleWithoutAnimations(newStyle) {\n 'worklet';\n const diff = {};\n for (const key in newStyle) {\n const value = newStyle[key];\n if (isAnimated(value)) {\n continue;\n }\n diff[key] = value;\n }\n return diff;\n}\nexport const validateAnimatedStyles = (styles) => {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(`useAnimatedStyle has to return an object, found ${typeof styles} instead`);\n }\n else if (Array.isArray(styles)) {\n throw new Error('useAnimatedStyle has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.');\n }\n};\n","/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nexport var defaultProps = {\n children: true,\n dataSet: true,\n nativeID: true,\n ref: true,\n suppressHydrationWarning: true,\n testID: true\n};\nexport var accessibilityProps = {\n accessibilityActiveDescendant: true,\n accessibilityAtomic: true,\n accessibilityAutoComplete: true,\n accessibilityBusy: true,\n accessibilityChecked: true,\n accessibilityColumnCount: true,\n accessibilityColumnIndex: true,\n accessibilityColumnSpan: true,\n accessibilityControls: true,\n accessibilityCurrent: true,\n accessibilityDescribedBy: true,\n accessibilityDetails: true,\n accessibilityDisabled: true,\n accessibilityErrorMessage: true,\n accessibilityExpanded: true,\n accessibilityFlowTo: true,\n accessibilityHasPopup: true,\n accessibilityHidden: true,\n accessibilityInvalid: true,\n accessibilityKeyShortcuts: true,\n accessibilityLabel: true,\n accessibilityLabelledBy: true,\n accessibilityLevel: true,\n accessibilityLiveRegion: true,\n accessibilityModal: true,\n accessibilityMultiline: true,\n accessibilityMultiSelectable: true,\n accessibilityOrientation: true,\n accessibilityOwns: true,\n accessibilityPlaceholder: true,\n accessibilityPosInSet: true,\n accessibilityPressed: true,\n accessibilityReadOnly: true,\n accessibilityRequired: true,\n accessibilityRole: true,\n accessibilityRoleDescription: true,\n accessibilityRowCount: true,\n accessibilityRowIndex: true,\n accessibilityRowSpan: true,\n accessibilitySelected: true,\n accessibilitySetSize: true,\n accessibilitySort: true,\n accessibilityValueMax: true,\n accessibilityValueMin: true,\n accessibilityValueNow: true,\n accessibilityValueText: true,\n dir: true,\n focusable: true,\n // Deprecated\n accessible: true,\n accessibilityState: true,\n accessibilityValue: true\n};\nexport var clickProps = {\n onClick: true,\n onClickCapture: true,\n onContextMenu: true\n};\nexport var focusProps = {\n onBlur: true,\n onFocus: true\n};\nexport var keyboardProps = {\n onKeyDown: true,\n onKeyDownCapture: true,\n onKeyUp: true,\n onKeyUpCapture: true\n};\nexport var mouseProps = {\n onMouseDown: true,\n onMouseEnter: true,\n onMouseLeave: true,\n onMouseMove: true,\n onMouseOver: true,\n onMouseOut: true,\n onMouseUp: true\n};\nexport var touchProps = {\n onTouchCancel: true,\n onTouchCancelCapture: true,\n onTouchEnd: true,\n onTouchEndCapture: true,\n onTouchMove: true,\n onTouchMoveCapture: true,\n onTouchStart: true,\n onTouchStartCapture: true\n};\nexport var styleProps = {\n classList: true,\n style: true\n};","/**\n * lodash 4.0.0 (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation \n * Based on Underscore.js 1.8.3 \n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license \n */\n\n/**\n * Checks if `value` is `null` or `undefined`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is nullish, else `false`.\n * @example\n *\n * _.isNil(null);\n * // => true\n *\n * _.isNil(void 0);\n * // => true\n *\n * _.isNil(NaN);\n * // => false\n */\nfunction isNil(value) {\n return value == null;\n}\n\nmodule.exports = isNil;\n","/* global _WORKLET */\nimport { convertToHSVA, isColor, toRGBA } from '../Colors';\nimport NativeReanimatedModule from '../NativeReanimated';\nlet IN_STYLE_UPDATER = false;\nexport function initialUpdaterRun(updater) {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\nfunction recognizePrefixSuffix(value) {\n 'worklet';\n var _a;\n if (typeof value === 'string') {\n const match = value.match(/([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/);\n if (!match) {\n throw Error(\"Couldn't parse animation value. Check if there isn't any typo.\");\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + ((_a = match[3]) !== null && _a !== void 0 ? _a : '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n }\n else {\n return { strippedValue: value };\n }\n}\nfunction decorateAnimation(animation) {\n 'worklet';\n if (animation.isHigherOrder) {\n return;\n }\n const baseOnStart = animation.onStart;\n const baseOnFrame = animation.onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n const prefNumberSuffOnStart = (animation, value, timestamp, previousAnimation) => {\n var _a, _b, _c, _d;\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(animation.toValue);\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current = previousAnimation.strippedCurrent;\n }\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n animation.current =\n ((_a = animation.__prefix) !== null && _a !== void 0 ? _a : '') +\n animation.current +\n ((_b = animation.__suffix) !== null && _b !== void 0 ? _b : '');\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n ((_c = previousAnimation.__prefix) !== null && _c !== void 0 ? _c : '') +\n previousAnimation.current +\n ((_d = previousAnimation.__suffix) !== null && _d !== void 0 ? _d : '');\n }\n };\n const prefNumberSuffOnFrame = (animation, timestamp) => {\n var _a, _b;\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n ((_a = animation.__prefix) !== null && _a !== void 0 ? _a : '') +\n animation.current +\n ((_b = animation.__suffix) !== null && _b !== void 0 ? _b : '');\n return res;\n };\n const tab = ['H', 'S', 'V', 'A'];\n const colorOnStart = (animation, value, timestamp, previousAnimation) => {\n let HSVAValue;\n let HSVACurrent;\n let HSVAToValue;\n const res = [];\n if (isColor(value)) {\n HSVACurrent = convertToHSVA(animation.current);\n HSVAValue = convertToHSVA(value);\n if (animation.toValue) {\n HSVAToValue = convertToHSVA(animation.toValue);\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = HSVACurrent[index];\n animation[i].toValue = HSVAToValue ? HSVAToValue[index] : undefined;\n animation[i].onStart(animation[i], HSVAValue[index], timestamp, previousAnimation ? previousAnimation[i] : undefined);\n res.push(animation[i].current);\n });\n animation.current = toRGBA(res);\n };\n const colorOnFrame = (animation, timestamp) => {\n const HSVACurrent = convertToHSVA(animation.current);\n const res = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = HSVACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n animation.current = toRGBA(res);\n return finished;\n };\n const arrayOnStart = (animation, value, timestamp, previousAnimation) => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = animation.toValue[i];\n animation[i].onStart(animation[i], v, timestamp, previousAnimation ? previousAnimation[i] : undefined);\n });\n animation.current = value;\n };\n const arrayOnFrame = (animation, timestamp) => {\n let finished = true;\n animation.current.forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n animation.current[i] = animation[i].current;\n });\n return finished;\n };\n animation.onStart = (animation, value, timestamp, previousAnimation) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n }\n else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n }\n else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\nexport function defineAnimation(starting, factory) {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation(animation);\n return animation;\n };\n if (_WORKLET || !NativeReanimatedModule.native) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\nexport function cancelAnimation(sharedValue) {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n// TODO it should work only if there was no animation before.\nexport function withStartValue(startValue, animation) {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n animation.current = startValue;\n return animation;\n });\n}\n","/* eslint-disable */\n\n/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * From React 16.0.0\n * \n */\nimport isUnitlessNumber from '../unitlessNumbers';\n/**\n * Convert a value into the proper css writable value. The style name `name`\n * should be logical (no hyphens), as specified\n * in `CSSProperty.isUnitlessNumber`.\n *\n * @param {string} name CSS property name such as `topMargin`.\n * @param {*} value CSS property value such as `10px`.\n * @return {string} Normalized style value with dimensions applied.\n */\n\nfunction dangerousStyleValue(name, value, isCustomProperty) {\n // Note that we've removed escapeTextForBrowser() calls here since the\n // whole string will be escaped when the attribute is injected into\n // the markup. If you provide unsafe user data here they can inject\n // arbitrary CSS which may be problematic (I couldn't repro this):\n // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet\n // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/\n // This is not an XSS hole but instead a potential CSS injection issue\n // which has lead to a greater discussion about how we're going to\n // trust URLs moving forward. See #2115901\n var isEmpty = value == null || typeof value === 'boolean' || value === '';\n\n if (isEmpty) {\n return '';\n }\n\n if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {\n return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers\n }\n\n return ('' + value).trim();\n}\n\nexport default dangerousStyleValue;","/* eslint-disable */\n\n/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * From React 16.3.0\n * \n */\nimport dangerousStyleValue from './dangerousStyleValue';\n/**\n * Sets the value for multiple styles on a node. If a value is specified as\n * '' (empty string), the corresponding style property will be unset.\n *\n * @param {DOMElement} node\n * @param {object} styles\n */\n\nfunction setValueForStyles(node, styles) {\n var style = node.style;\n\n for (var styleName in styles) {\n if (!styles.hasOwnProperty(styleName)) {\n continue;\n }\n\n var isCustomProperty = styleName.indexOf('--') === 0;\n var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);\n\n if (styleName === 'float') {\n styleName = 'cssFloat';\n }\n\n if (isCustomProperty) {\n style.setProperty(styleName, styleValue);\n } else {\n style[styleName] = styleValue;\n }\n }\n}\n\nexport default setValueForStyles;","/**\n * Copyright (c) Nicolas Gallagher.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport getBoundingClientRect from '../../modules/getBoundingClientRect';\nimport setValueForStyles from '../../modules/setValueForStyles';\n\nvar getRect = function getRect(node) {\n // Unlike the DOM's getBoundingClientRect, React Native layout measurements\n // for \"height\" and \"width\" ignore scale transforms.\n // https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements\n var _getBoundingClientRec = getBoundingClientRect(node),\n x = _getBoundingClientRec.x,\n y = _getBoundingClientRec.y,\n top = _getBoundingClientRec.top,\n left = _getBoundingClientRec.left;\n\n var width = node.offsetWidth;\n var height = node.offsetHeight;\n return {\n x: x,\n y: y,\n width: width,\n height: height,\n top: top,\n left: left\n };\n};\n\nvar _measureLayout = function measureLayout(node, relativeToNativeNode, callback) {\n var relativeNode = relativeToNativeNode || node && node.parentNode;\n\n if (node && relativeNode) {\n setTimeout(function () {\n var relativeRect = getBoundingClientRect(relativeNode);\n\n var _getRect = getRect(node),\n height = _getRect.height,\n left = _getRect.left,\n top = _getRect.top,\n width = _getRect.width;\n\n var x = left - relativeRect.left;\n var y = top - relativeRect.top;\n callback(x, y, width, height, left, top);\n }, 0);\n }\n};\n\nvar focusableElements = {\n A: true,\n INPUT: true,\n SELECT: true,\n TEXTAREA: true\n};\nvar UIManager = {\n blur: function blur(node) {\n try {\n node.blur();\n } catch (err) {}\n },\n focus: function focus(node) {\n try {\n var name = node.nodeName; // A tabIndex of -1 allows element to be programmatically focused but\n // prevents keyboard focus, so we don't want to set the value on elements\n // that support keyboard focus by default.\n\n if (node.getAttribute('tabIndex') == null && focusableElements[name] == null) {\n node.setAttribute('tabIndex', '-1');\n }\n\n node.focus();\n } catch (err) {}\n },\n measure: function measure(node, callback) {\n _measureLayout(node, null, callback);\n },\n measureInWindow: function measureInWindow(node, callback) {\n if (node) {\n setTimeout(function () {\n var _getRect2 = getRect(node),\n height = _getRect2.height,\n left = _getRect2.left,\n top = _getRect2.top,\n width = _getRect2.width;\n\n callback(left, top, width, height);\n }, 0);\n }\n },\n measureLayout: function measureLayout(node, relativeToNativeNode, onFail, onSuccess) {\n _measureLayout(node, relativeToNativeNode, onSuccess);\n },\n updateView: function updateView(node, props) {\n for (var prop in props) {\n if (!Object.prototype.hasOwnProperty.call(props, prop)) {\n continue;\n }\n\n var value = props[prop];\n\n switch (prop) {\n case 'style':\n {\n setValueForStyles(node, value);\n break;\n }\n\n case 'class':\n case 'className':\n {\n node.setAttribute('class', value);\n break;\n }\n\n case 'text':\n case 'value':\n // native platforms use `text` prop to replace text input value\n node.value = value;\n break;\n\n default:\n node.setAttribute(prop, value);\n }\n }\n },\n configureNextLayoutAnimation: function configureNextLayoutAnimation(config, onAnimationDidEnd) {\n onAnimationDidEnd();\n },\n // mocks\n setLayoutAnimationEnabledExperimental: function setLayoutAnimationEnabledExperimental() {}\n};\nexport default UIManager;","/**\n * Copyright (c) Nicolas Gallagher.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport AccessibilityUtil from '../../modules/AccessibilityUtil';\nimport createDOMProps from '../../modules/createDOMProps';\nimport React from 'react';\n\nvar createElement = function createElement(component, props) {\n // Use equivalent platform elements where possible.\n var accessibilityComponent;\n\n if (component && component.constructor === String) {\n accessibilityComponent = AccessibilityUtil.propsToAccessibilityComponent(props);\n }\n\n var Component = accessibilityComponent || component;\n var domProps = createDOMProps(Component, props);\n\n for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n children[_key - 2] = arguments[_key];\n }\n\n return /*#__PURE__*/React.createElement.apply(React, [Component, domProps].concat(children));\n};\n\nexport default createElement;","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n reLeadingDot = /^\\./,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Checks if `value` is a host object in IE < 9.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a host object, else `false`.\n */\nfunction isHostObject(value) {\n // Many host objects are `Object` objects that can coerce to strings\n // despite having improperly defined `toString` methods.\n var result = false;\n if (value != null && typeof value.toString != 'function') {\n try {\n result = !!(value + '');\n } catch (e) {}\n }\n return result;\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n splice = arrayProto.splice;\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map'),\n nativeCreate = getNative(Object, 'create');\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n return this.has(key) && delete this.__data__[key];\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n return getMapData(this, key)['delete'](key);\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n getMapData(this, key).set(key, value);\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = isKey(path, object) ? [path] : castPath(path);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value) {\n return isArray(value) ? value : stringToPath(value);\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoize(function(string) {\n string = toString(string);\n\n var result = [];\n if (reLeadingDot.test(string)) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to process.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result);\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Assign cache to `_.memoize`.\nmemoize.Cache = MapCache;\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\nmodule.exports = get;\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nexport default {\n disconnectNodeFromView() {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n attachEvent(_viewTag, _eventName, _nodeID) {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n detachEvent(_viewTag, _eventName, _nodeID) {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n createNode(_nodeID, _config) {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n dropNode(_nodeID) {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n configureProps(_nativeProps, _uiProps) {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n disconnectNodes() {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n addListener() {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n removeListeners() {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n removeAllListeners() {\n return __awaiter(this, void 0, void 0, function* () {\n // noop\n });\n },\n animateNextTransition() {\n return __awaiter(this, void 0, void 0, function* () {\n console.warn('Reanimated: animateNextTransition is unimplemented on current platform');\n });\n },\n};\n","import ReanimatedModuleCompat from './ReanimatedModuleCompat';\nexport default ReanimatedModuleCompat;\n","/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\n'use strict';\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } it = o[Symbol.iterator](); return it.next.bind(it); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport AnimatedNode from './AnimatedNode';\nimport NativeAnimatedHelper from '../NativeAnimatedHelper';\n\nvar AnimatedWithChildren = /*#__PURE__*/function (_AnimatedNode) {\n _inheritsLoose(AnimatedWithChildren, _AnimatedNode);\n\n function AnimatedWithChildren() {\n var _this;\n\n _this = _AnimatedNode.call(this) || this;\n _this._children = [];\n return _this;\n }\n\n var _proto = AnimatedWithChildren.prototype;\n\n _proto.__makeNative = function __makeNative() {\n if (!this.__isNative) {\n this.__isNative = true;\n\n for (var _iterator = _createForOfIteratorHelperLoose(this._children), _step; !(_step = _iterator()).done;) {\n var child = _step.value;\n\n child.__makeNative();\n\n NativeAnimatedHelper.API.connectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());\n }\n }\n\n _AnimatedNode.prototype.__makeNative.call(this);\n };\n\n _proto.__addChild = function __addChild(child) {\n if (this._children.length === 0) {\n this.__attach();\n }\n\n this._children.push(child);\n\n if (this.__isNative) {\n // Only accept \"native\" animated nodes as children\n child.__makeNative();\n\n NativeAnimatedHelper.API.connectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());\n }\n };\n\n _proto.__removeChild = function __removeChild(child) {\n var index = this._children.indexOf(child);\n\n if (index === -1) {\n console.warn(\"Trying to remove a child that doesn't exist\");\n return;\n }\n\n if (this.__isNative && child.__isNative) {\n NativeAnimatedHelper.API.disconnectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());\n }\n\n this._children.splice(index, 1);\n\n if (this._children.length === 0) {\n this.__detach();\n }\n };\n\n _proto.__getChildren = function __getChildren() {\n return this._children;\n };\n\n _proto.__callListeners = function __callListeners(value) {\n _AnimatedNode.prototype.__callListeners.call(this, value);\n\n if (!this.__isNative) {\n for (var _iterator2 = _createForOfIteratorHelperLoose(this._children), _step2; !(_step2 = _iterator2()).done;) {\n var child = _step2.value;\n\n if (child.__getValue) {\n child.__callListeners(child.__getValue());\n }\n }\n }\n };\n\n return AnimatedWithChildren;\n}(AnimatedNode);\n\nexport default AnimatedWithChildren;","import { createContext } from 'react';\n\nexport interface BottomSheetModalContextType {\n dismiss: (key?: string) => boolean;\n dismissAll: () => void;\n}\n\nexport const BottomSheetModalContext =\n createContext(null);\n\nexport const BottomSheetModalProvider = BottomSheetModalContext.Provider;\n","import { createContext, Ref } from 'react';\nimport type { Insets } from 'react-native';\nimport type Animated from 'react-native-reanimated';\nimport type BottomSheet from '../../components/bottomSheet';\nimport type { BottomSheetModalStackBehavior } from '../../components/bottomSheetModal';\n\nexport interface BottomSheetModalInternalContextType {\n containerHeight: Animated.SharedValue;\n containerOffset: Animated.SharedValue>;\n mountSheet: (\n key: string,\n ref: Ref,\n stackBehavior: BottomSheetModalStackBehavior\n ) => void;\n unmountSheet: (key: string) => void;\n willUnmountSheet: (key: string) => void;\n}\n\nexport const BottomSheetModalInternalContext =\n createContext(null);\n\nexport const BottomSheetModalInternalProvider =\n BottomSheetModalInternalContext.Provider;\n","import { useContext } from 'react';\nimport {\n BottomSheetInternalContext,\n BottomSheetInternalContextType,\n} from '../contexts/internal';\n\nexport function useBottomSheetInternal(\n unsafe?: false\n): BottomSheetInternalContextType;\n\nexport function useBottomSheetInternal(\n unsafe: true\n): BottomSheetInternalContextType | null;\n\nexport function useBottomSheetInternal(\n unsafe?: boolean\n): BottomSheetInternalContextType | null {\n const context = useContext(BottomSheetInternalContext);\n\n if (unsafe !== true && context === null) {\n throw \"'useBottomSheetInternal' cannot be used out of the BottomSheet!\";\n }\n\n return context;\n}\n","import Hammer from '@egjs/hammerjs';\n\nimport { State } from '../State';\n\nexport const CONTENT_TOUCHES_DELAY = 240;\nexport const CONTENT_TOUCHES_QUICK_TAP_END_DELAY = 50;\nexport const MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD = 0.1;\nexport const MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD = 7;\nexport const DEG_RAD = Math.PI / 180;\n\n// Map Hammer values to RNGH\nexport const EventMap = {\n [Hammer.INPUT_START]: State.BEGAN,\n [Hammer.INPUT_MOVE]: State.ACTIVE,\n [Hammer.INPUT_END]: State.END,\n [Hammer.INPUT_CANCEL]: State.FAILED,\n} as const;\n\nexport const Direction = {\n RIGHT: 1,\n LEFT: 2,\n UP: 4,\n DOWN: 8,\n};\n\nexport const DirectionMap = {\n [Hammer.DIRECTION_RIGHT]: Direction.RIGHT,\n [Hammer.DIRECTION_LEFT]: Direction.LEFT,\n [Hammer.DIRECTION_UP]: Direction.UP,\n [Hammer.DIRECTION_DOWN]: Direction.DOWN,\n};\n\nexport const HammerInputNames = {\n [Hammer.INPUT_START]: 'START',\n [Hammer.INPUT_MOVE]: 'MOVE',\n [Hammer.INPUT_END]: 'END',\n [Hammer.INPUT_CANCEL]: 'CANCEL',\n};\nexport const HammerDirectionNames = {\n [Hammer.DIRECTION_HORIZONTAL]: 'HORIZONTAL',\n [Hammer.DIRECTION_UP]: 'UP',\n [Hammer.DIRECTION_DOWN]: 'DOWN',\n [Hammer.DIRECTION_VERTICAL]: 'VERTICAL',\n [Hammer.DIRECTION_NONE]: 'NONE',\n [Hammer.DIRECTION_ALL]: 'ALL',\n [Hammer.DIRECTION_RIGHT]: 'RIGHT',\n [Hammer.DIRECTION_LEFT]: 'LEFT',\n};\n","import { scrollTo, useWorkletCallback } from 'react-native-reanimated';\nimport { useBottomSheetInternal } from './useBottomSheetInternal';\nimport { ANIMATION_STATE, SCROLLABLE_STATE, SHEET_STATE } from '../constants';\nimport type {\n ScrollEventsHandlersHookType,\n ScrollEventHandlerCallbackType,\n} from '../types';\n\nexport type ScrollEventContextType = {\n initialContentOffsetY: number;\n shouldLockInitialPosition: boolean;\n};\n\nexport const useScrollEventsHandlersDefault: ScrollEventsHandlersHookType = (\n scrollableRef,\n scrollableContentOffsetY\n) => {\n // hooks\n const {\n animatedSheetState,\n animatedScrollableState,\n animatedAnimationState,\n animatedScrollableContentOffsetY: rootScrollableContentOffsetY,\n } = useBottomSheetInternal();\n\n //#region callbacks\n const handleOnScroll: ScrollEventHandlerCallbackType =\n useWorkletCallback(\n (_, context) => {\n /**\n * if sheet position is extended or fill parent, then we reset\n * `shouldLockInitialPosition` value to false.\n */\n if (\n animatedSheetState.value === SHEET_STATE.EXTENDED ||\n animatedSheetState.value === SHEET_STATE.FILL_PARENT\n ) {\n context.shouldLockInitialPosition = false;\n }\n\n if (animatedScrollableState.value === SCROLLABLE_STATE.LOCKED) {\n const lockPosition = context.shouldLockInitialPosition\n ? context.initialContentOffsetY ?? 0\n : 0;\n // @ts-ignore\n scrollTo(scrollableRef, 0, lockPosition, false);\n scrollableContentOffsetY.value = lockPosition;\n return;\n }\n },\n [\n scrollableRef,\n scrollableContentOffsetY,\n animatedScrollableState,\n animatedSheetState,\n ]\n );\n const handleOnBeginDrag: ScrollEventHandlerCallbackType =\n useWorkletCallback(\n ({ contentOffset: { y } }, context) => {\n scrollableContentOffsetY.value = y;\n rootScrollableContentOffsetY.value = y;\n context.initialContentOffsetY = y;\n\n /**\n * if sheet position not extended or fill parent and the scrollable position\n * not at the top, then we should lock the initial scrollable position.\n */\n if (\n animatedSheetState.value !== SHEET_STATE.EXTENDED &&\n animatedSheetState.value !== SHEET_STATE.FILL_PARENT &&\n y > 0\n ) {\n context.shouldLockInitialPosition = true;\n } else {\n context.shouldLockInitialPosition = false;\n }\n },\n [\n scrollableContentOffsetY,\n animatedSheetState,\n rootScrollableContentOffsetY,\n ]\n );\n const handleOnEndDrag: ScrollEventHandlerCallbackType =\n useWorkletCallback(\n ({ contentOffset: { y } }, context) => {\n if (animatedScrollableState.value === SCROLLABLE_STATE.LOCKED) {\n const lockPosition = context.shouldLockInitialPosition\n ? context.initialContentOffsetY ?? 0\n : 0;\n // @ts-ignore\n scrollTo(scrollableRef, 0, lockPosition, false);\n scrollableContentOffsetY.value = lockPosition;\n return;\n }\n if (animatedAnimationState.value !== ANIMATION_STATE.RUNNING) {\n scrollableContentOffsetY.value = y;\n rootScrollableContentOffsetY.value = y;\n }\n },\n [\n scrollableRef,\n scrollableContentOffsetY,\n animatedAnimationState,\n animatedScrollableState,\n rootScrollableContentOffsetY,\n ]\n );\n const handleOnMomentumEnd: ScrollEventHandlerCallbackType =\n useWorkletCallback(\n ({ contentOffset: { y } }, context) => {\n if (animatedScrollableState.value === SCROLLABLE_STATE.LOCKED) {\n const lockPosition = context.shouldLockInitialPosition\n ? context.initialContentOffsetY ?? 0\n : 0;\n // @ts-ignore\n scrollTo(scrollableRef, 0, lockPosition, false);\n scrollableContentOffsetY.value = 0;\n return;\n }\n if (animatedAnimationState.value !== ANIMATION_STATE.RUNNING) {\n scrollableContentOffsetY.value = y;\n rootScrollableContentOffsetY.value = y;\n }\n },\n [\n scrollableContentOffsetY,\n scrollableRef,\n animatedAnimationState,\n animatedScrollableState,\n rootScrollableContentOffsetY,\n ]\n );\n //#endregion\n\n return {\n handleOnScroll,\n handleOnBeginDrag,\n handleOnEndDrag,\n handleOnMomentumEnd,\n };\n};\n","/**\n * Converts a snap point to fixed numbers.\n */\nexport const normalizeSnapPoint = (\n snapPoint: number | string,\n containerHeight: number,\n _topInset: number,\n _bottomInset: number,\n _$modal: boolean = false\n) => {\n 'worklet';\n let normalizedSnapPoint = snapPoint;\n\n // percentage snap point\n if (typeof normalizedSnapPoint === 'string') {\n normalizedSnapPoint =\n (Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100;\n }\n return Math.max(0, containerHeight - normalizedSnapPoint);\n};\n","import {\n WithSpringConfig,\n WithTimingConfig,\n withTiming,\n withSpring,\n AnimationCallback,\n} from 'react-native-reanimated';\nimport { ANIMATION_CONFIGS, ANIMATION_METHOD } from '../constants';\n\ninterface AnimateParams {\n point: number;\n velocity?: number;\n configs?: WithSpringConfig | WithTimingConfig;\n onComplete?: AnimationCallback;\n}\n\nexport const animate = ({\n point,\n configs = undefined,\n velocity = 0,\n onComplete,\n}: AnimateParams) => {\n 'worklet';\n\n if (!configs) {\n configs = ANIMATION_CONFIGS;\n }\n\n // detect animation type\n const type =\n 'duration' in configs || 'easing' in configs\n ? ANIMATION_METHOD.TIMING\n : ANIMATION_METHOD.SPRING;\n\n if (type === ANIMATION_METHOD.TIMING) {\n return withTiming(point, configs as WithTimingConfig, onComplete);\n } else {\n return withSpring(\n point,\n Object.assign({ velocity }, configs) as WithSpringConfig,\n onComplete\n );\n }\n};\n","import { Easing } from 'react-native-reanimated';\nimport type { KeyboardEventEasing } from 'react-native';\n\nexport const getKeyboardAnimationConfigs = (\n easing: KeyboardEventEasing,\n duration: number\n) => {\n 'worklet';\n switch (easing) {\n case 'easeIn':\n return {\n easing: Easing.in(Easing.ease),\n duration,\n };\n\n case 'easeOut':\n return {\n easing: Easing.out(Easing.ease),\n duration,\n };\n\n case 'easeInEaseOut':\n return {\n easing: Easing.inOut(Easing.ease),\n duration,\n };\n\n case 'linear':\n return {\n easing: Easing.linear,\n duration,\n };\n\n case 'keyboard':\n return {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n };\n }\n};\n","interface PrintOptions {\n component?: string;\n method?: string;\n params?: Record | string | number | boolean;\n}\n\ntype Print = (options: PrintOptions) => void;\n\nlet isLoggingEnabled = false;\n\nconst enableLogging = () => {\n if (!__DEV__) {\n console.warn('[Portal] could not enable logging on production!');\n return;\n }\n isLoggingEnabled = true;\n};\n\nlet print: Print = () => {};\n\nif (__DEV__) {\n print = ({ component, method, params }) => {\n if (!isLoggingEnabled) {\n return;\n }\n let message = '';\n\n if (typeof params === 'object') {\n message = Object.keys(params)\n .map(key => `${key}:${params[key]}`)\n .join(' ');\n } else {\n message = `${params ?? ''}`;\n }\n console.log(\n `[Portal::${[component, method].filter(Boolean).join('::')}]`,\n message\n );\n };\n}\n\nObject.freeze(print);\n\nexport { print, enableLogging };\n","const workletNoop = () => {\n 'worklet';\n};\n\nconst noop = () => {};\n\nexport { noop, workletNoop };\n","import Animated, { useAnimatedGestureHandler } from 'react-native-reanimated';\nimport {\n State,\n PanGestureHandlerGestureEvent,\n} from 'react-native-gesture-handler';\nimport { GESTURE_SOURCE } from '../constants';\nimport type {\n GestureEventContextType,\n GestureEventHandlerCallbackType,\n} from '../types';\n\nconst resetContext = (context: any) => {\n 'worklet';\n\n Object.keys(context).map(key => {\n context[key] = undefined;\n });\n};\n\nexport const useGestureHandler = (\n type: GESTURE_SOURCE,\n state: Animated.SharedValue,\n gestureSource: Animated.SharedValue,\n handleOnStart: GestureEventHandlerCallbackType,\n handleOnActive: GestureEventHandlerCallbackType,\n handleOnEnd: GestureEventHandlerCallbackType\n): ((event: PanGestureHandlerGestureEvent) => void) => {\n const gestureHandler = useAnimatedGestureHandler<\n PanGestureHandlerGestureEvent,\n GestureEventContextType\n >(\n {\n onActive: (payload, context) => {\n if (!context.didStart) {\n context.didStart = true;\n\n state.value = State.BEGAN;\n gestureSource.value = type;\n\n handleOnStart(type, payload, context);\n return;\n }\n\n if (gestureSource.value !== type) {\n return;\n }\n\n state.value = payload.state;\n handleOnActive(type, payload, context);\n },\n onEnd: (payload, context) => {\n if (gestureSource.value !== type) {\n return;\n }\n\n state.value = payload.state;\n gestureSource.value = GESTURE_SOURCE.UNDETERMINED;\n\n handleOnEnd(type, payload, context);\n resetContext(context);\n },\n onCancel: (payload, context) => {\n if (gestureSource.value !== type) {\n return;\n }\n\n state.value = payload.state;\n gestureSource.value = GESTURE_SOURCE.UNDETERMINED;\n\n resetContext(context);\n },\n onFail: (payload, context) => {\n if (gestureSource.value !== type) {\n return;\n }\n\n state.value = payload.state;\n gestureSource.value = GESTURE_SOURCE.UNDETERMINED;\n\n resetContext(context);\n },\n onFinish: (payload, context) => {\n if (gestureSource.value !== type) {\n return;\n }\n\n state.value = payload.state;\n gestureSource.value = GESTURE_SOURCE.UNDETERMINED;\n\n resetContext(context);\n },\n },\n [type, state, handleOnStart, handleOnActive, handleOnEnd]\n );\n return gestureHandler;\n};\n","import type { Vector } from \"./Vectors\";\n\nexport const { PI } = Math;\nexport const TAU = PI * 2;\n\n/**\n * @summary Convert a boolean value into a number.\n * This can be useful in reanimated since 0 and 1 are used for conditional statements.\n * @worklet\n */\nexport const bin = (value: boolean): 0 | 1 => {\n \"worklet\";\n return value ? 1 : 0;\n};\n\n/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n * @worklet\n */\nexport const mix = (value: number, x: number, y: number) => {\n \"worklet\";\n return x * (1 - value) + y * value;\n};\n\n/**\n * @summary Check is value is almost equal to the target.\n * @worklet\n */\nexport const approximates = (\n value: number,\n target: number,\n epsilon = 0.001\n) => {\n \"worklet\";\n return Math.abs(value - target) < epsilon;\n};\n\n/**\n * @summary Normalize any radian value between 0 and 2PI.\n * For example, if the value is -PI/2, it will be comverted to 1.5PI.\n * Or 4PI will be converted to 0.\n * @worklet\n */\nexport const normalizeRad = (value: number) => {\n \"worklet\";\n const rest = value % TAU;\n return rest > 0 ? rest : TAU + rest;\n};\n\n/**\n * @summary Transforms an angle from radians to degrees.\n * @worklet\n */\nexport const toDeg = (rad: number) => {\n \"worklet\";\n return (rad * 180) / Math.PI;\n};\n\n/**\n * @summary Transforms an angle from degrees to radians.\n * @worklet\n */\nexport const toRad = (deg: number) => {\n \"worklet\";\n return (deg * Math.PI) / 180;\n};\n\n/**\n *\n * @summary Returns the average value\n * @worklet\n */\nexport const avg = (values: number[]) => {\n \"worklet\";\n return values.reduce((a, v) => a + v, 0) / values.length;\n};\n\n/**\n * @summary Returns true if node is within lowerBound and upperBound.\n * @worklet\n */\nexport const between = (\n value: number,\n lowerBound: number,\n upperBound: number,\n inclusive = true\n) => {\n \"worklet\";\n if (inclusive) {\n return value >= lowerBound && value <= upperBound;\n }\n return value > lowerBound && value < upperBound;\n};\n\n/**\n * @summary Clamps a node with a lower and upper bound.\n * @example\n clamp(-1, 0, 100); // 0\n clamp(1, 0, 100); // 1\n clamp(101, 0, 100); // 100\n * @worklet\n */\nexport const clamp = (\n value: number,\n lowerBound: number,\n upperBound: number\n) => {\n \"worklet\";\n return Math.min(Math.max(lowerBound, value), upperBound);\n};\n\n/**\n * @description Returns the coordinate of a cubic bezier curve. t is the length of the curve from 0 to 1.\n * cubicBezier(0, p0, p1, p2, p3) equals p0 and cubicBezier(1, p0, p1, p2, p3) equals p3.\n * p0 and p3 are respectively the starting and ending point of the curve. p1 and p2 are the control points.\n * @worklet\n */\nexport const cubicBezier = (\n t: number,\n from: number,\n c1: number,\n c2: number,\n to: number\n) => {\n \"worklet\";\n const term = 1 - t;\n const a = 1 * term ** 3 * t ** 0 * from;\n const b = 3 * term ** 2 * t ** 1 * c1;\n const c = 3 * term ** 1 * t ** 2 * c2;\n const d = 1 * term ** 0 * t ** 3 * to;\n return a + b + c + d;\n};\n\n/**\n * @summary Computes animation node rounded to precision.\n * @worklet\n */\nexport const round = (value: number, precision = 0) => {\n \"worklet\";\n const p = Math.pow(10, precision);\n return Math.round(value * p) / p;\n};\n\n// https://stackoverflow.com/questions/27176423/function-to-solve-cubic-equation-analytically\nconst cuberoot = (x: number) => {\n \"worklet\";\n const y = Math.pow(Math.abs(x), 1 / 3);\n return x < 0 ? -y : y;\n};\n\nconst solveCubic = (a: number, b: number, c: number, d: number) => {\n \"worklet\";\n if (Math.abs(a) < 1e-8) {\n // Quadratic case, ax^2+bx+c=0\n a = b;\n b = c;\n c = d;\n if (Math.abs(a) < 1e-8) {\n // Linear case, ax+b=0\n a = b;\n b = c;\n if (Math.abs(a) < 1e-8) {\n // Degenerate case\n return [];\n }\n return [-b / a];\n }\n\n const D = b * b - 4 * a * c;\n if (Math.abs(D) < 1e-8) {\n return [-b / (2 * a)];\n } else if (D > 0) {\n return [(-b + Math.sqrt(D)) / (2 * a), (-b - Math.sqrt(D)) / (2 * a)];\n }\n return [];\n }\n\n // Convert to depressed cubic t^3+pt+q = 0 (subst x = t - b/3a)\n const p = (3 * a * c - b * b) / (3 * a * a);\n const q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (27 * a * a * a);\n let roots;\n\n if (Math.abs(p) < 1e-8) {\n // p = 0 -> t^3 = -q -> t = -q^1/3\n roots = [cuberoot(-q)];\n } else if (Math.abs(q) < 1e-8) {\n // q = 0 -> t^3 + pt = 0 -> t(t^2+p)=0\n roots = [0].concat(p < 0 ? [Math.sqrt(-p), -Math.sqrt(-p)] : []);\n } else {\n const D = (q * q) / 4 + (p * p * p) / 27;\n if (Math.abs(D) < 1e-8) {\n // D = 0 -> two roots\n roots = [(-1.5 * q) / p, (3 * q) / p];\n } else if (D > 0) {\n // Only one real root\n const u = cuberoot(-q / 2 - Math.sqrt(D));\n roots = [u - p / (3 * u)];\n } else {\n // D < 0, three roots, but needs to use complex numbers/trigonometric solution\n const u = 2 * Math.sqrt(-p / 3);\n const t = Math.acos((3 * q) / p / u) / 3; // D < 0 implies p < 0 and acos argument in [-1..1]\n const k = (2 * Math.PI) / 3;\n roots = [u * Math.cos(t), u * Math.cos(t - k), u * Math.cos(t - 2 * k)];\n }\n }\n\n // Convert back from depressed cubic\n for (let i = 0; i < roots.length; i++) {\n roots[i] -= b / (3 * a);\n }\n\n return roots;\n};\n\n/**\n * @summary Given a cubic Bèzier curve, return the y value for x.\n * @example\n const x = 116;\n const from = vec.create(59, 218);\n const c1 = vec.create(131, 39);\n const c2 = vec.create(204, 223);\n const to = vec.create(227, 89);\n // y= 139\n const y = cubicBezierYForX(x, from, c1, c2, to)));\n * @worklet\n */\nexport const cubicBezierYForX = (\n x: number,\n a: Vector,\n b: Vector,\n c: Vector,\n d: Vector,\n precision = 2\n) => {\n \"worklet\";\n const pa = -a.x + 3 * b.x - 3 * c.x + d.x;\n const pb = 3 * a.x - 6 * b.x + 3 * c.x;\n const pc = -3 * a.x + 3 * b.x;\n const pd = a.x - x;\n // eslint-disable-next-line prefer-destructuring\n const t = solveCubic(pa, pb, pc, pd)\n .map((root) => round(root, precision))\n .filter((root) => root >= 0 && root <= 1)[0];\n return cubicBezier(t, a.y, b.y, c.y, d.y);\n};\n\nexport const fract = (x: number) => {\n \"worklet\";\n return x - Math.floor(x);\n};\n","/**\n * @summary Select a point where the animation should snap to given the value of the gesture and it's velocity.\n * @worklet\n */\nexport const snapPoint = (\n value: number,\n velocity: number,\n points: ReadonlyArray\n): number => {\n \"worklet\";\n const point = value + 0.2 * velocity;\n const deltas = points.map((p) => Math.abs(point - p));\n const minDelta = Math.min.apply(null, deltas);\n return points.filter((p) => Math.abs(point - p) === minDelta)[0];\n};\n","import { Keyboard, Platform } from 'react-native';\nimport { runOnJS, useWorkletCallback } from 'react-native-reanimated';\nimport { clamp, snapPoint } from 'react-native-redash';\nimport { useBottomSheetInternal } from './useBottomSheetInternal';\nimport {\n ANIMATION_SOURCE,\n GESTURE_SOURCE,\n KEYBOARD_STATE,\n SCROLLABLE_TYPE,\n WINDOW_HEIGHT,\n} from '../constants';\nimport type {\n GestureEventsHandlersHookType,\n GestureEventHandlerCallbackType,\n} from '../types';\n\ntype GestureEventContextType = {\n initialPosition: number;\n initialKeyboardState: KEYBOARD_STATE;\n isScrollablePositionLocked: boolean;\n};\n\nexport const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =\n () => {\n //#region variables\n const {\n animatedPosition,\n animatedSnapPoints,\n animatedKeyboardState,\n animatedKeyboardHeight,\n animatedContainerHeight,\n animatedScrollableType,\n animatedHighestSnapPoint,\n animatedClosedPosition,\n animatedScrollableContentOffsetY,\n enableOverDrag,\n enablePanDownToClose,\n overDragResistanceFactor,\n isInTemporaryPosition,\n isScrollableRefreshable,\n animateToPosition,\n stopAnimation,\n } = useBottomSheetInternal();\n //#endregion\n\n //#region gesture methods\n const handleOnStart: GestureEventHandlerCallbackType =\n useWorkletCallback(\n function handleOnStart(__, _, context) {\n // cancel current animation\n stopAnimation();\n\n // store current animated position\n context.initialPosition = animatedPosition.value;\n context.initialKeyboardState = animatedKeyboardState.value;\n\n /**\n * if the scrollable content is scrolled, then\n * we lock the position.\n */\n if (animatedScrollableContentOffsetY.value > 0) {\n context.isScrollablePositionLocked = true;\n }\n },\n [\n stopAnimation,\n animatedPosition,\n animatedKeyboardState,\n animatedScrollableContentOffsetY,\n ]\n );\n const handleOnActive: GestureEventHandlerCallbackType =\n useWorkletCallback(\n function handleOnActive(source, { translationY }, context) {\n let highestSnapPoint = animatedHighestSnapPoint.value;\n\n /**\n * if keyboard is shown, then we set the highest point to the current\n * position which includes the keyboard height.\n */\n if (\n isInTemporaryPosition.value &&\n context.initialKeyboardState === KEYBOARD_STATE.SHOWN\n ) {\n highestSnapPoint = context.initialPosition;\n }\n\n /**\n * if current position is out of provided `snapPoints` and smaller then\n * highest snap pont, then we set the highest point to the current position.\n */\n if (\n isInTemporaryPosition.value &&\n context.initialPosition < highestSnapPoint\n ) {\n highestSnapPoint = context.initialPosition;\n }\n\n const lowestSnapPoint = enablePanDownToClose\n ? animatedContainerHeight.value\n : animatedSnapPoints.value[0];\n\n /**\n * if scrollable is refreshable and sheet position at the highest\n * point, then do not interact with current gesture.\n */\n if (\n source === GESTURE_SOURCE.SCROLLABLE &&\n isScrollableRefreshable.value &&\n animatedPosition.value === highestSnapPoint\n ) {\n return;\n }\n\n /**\n * a negative scrollable content offset to be subtracted from accumulated\n * current position and gesture translation Y to allow user to drag the sheet,\n * when scrollable position at the top.\n * a negative scrollable content offset when the scrollable is not locked.\n */\n const negativeScrollableContentOffset =\n (context.initialPosition === highestSnapPoint &&\n source === GESTURE_SOURCE.SCROLLABLE) ||\n !context.isScrollablePositionLocked\n ? animatedScrollableContentOffsetY.value * -1\n : 0;\n\n /**\n * an accumulated value of starting position with gesture translation y.\n */\n const draggedPosition = context.initialPosition + translationY;\n\n /**\n * an accumulated value of dragged position and negative scrollable content offset,\n * this will insure locking sheet position when user is scrolling the scrollable until,\n * they reach to the top of the scrollable.\n */\n const accumulatedDraggedPosition =\n draggedPosition + negativeScrollableContentOffset;\n\n /**\n * a clamped value of the accumulated dragged position, to insure keeping the dragged\n * position between the highest and lowest snap points.\n */\n const clampedPosition = clamp(\n accumulatedDraggedPosition,\n highestSnapPoint,\n lowestSnapPoint\n );\n\n /**\n * if scrollable position is locked and the animated position\n * reaches the highest point, then we unlock the scrollable position.\n */\n if (\n context.isScrollablePositionLocked &&\n source === GESTURE_SOURCE.SCROLLABLE &&\n animatedPosition.value === highestSnapPoint\n ) {\n context.isScrollablePositionLocked = false;\n }\n\n /**\n * over-drag implementation.\n */\n if (enableOverDrag) {\n if (\n (source === GESTURE_SOURCE.HANDLE ||\n animatedScrollableType.value === SCROLLABLE_TYPE.VIEW) &&\n draggedPosition < highestSnapPoint\n ) {\n const resistedPosition =\n highestSnapPoint -\n Math.sqrt(1 + (highestSnapPoint - draggedPosition)) *\n overDragResistanceFactor;\n animatedPosition.value = resistedPosition;\n return;\n }\n\n if (\n source === GESTURE_SOURCE.HANDLE &&\n draggedPosition > lowestSnapPoint\n ) {\n const resistedPosition =\n lowestSnapPoint +\n Math.sqrt(1 + (draggedPosition - lowestSnapPoint)) *\n overDragResistanceFactor;\n animatedPosition.value = resistedPosition;\n return;\n }\n\n if (\n source === GESTURE_SOURCE.SCROLLABLE &&\n draggedPosition + negativeScrollableContentOffset >\n lowestSnapPoint\n ) {\n const resistedPosition =\n lowestSnapPoint +\n Math.sqrt(\n 1 +\n (draggedPosition +\n negativeScrollableContentOffset -\n lowestSnapPoint)\n ) *\n overDragResistanceFactor;\n animatedPosition.value = resistedPosition;\n return;\n }\n }\n\n animatedPosition.value = clampedPosition;\n },\n [\n enableOverDrag,\n enablePanDownToClose,\n overDragResistanceFactor,\n isInTemporaryPosition,\n isScrollableRefreshable,\n animatedHighestSnapPoint,\n animatedContainerHeight,\n animatedSnapPoints,\n animatedPosition,\n animatedScrollableType,\n animatedScrollableContentOffsetY,\n ]\n );\n const handleOnEnd: GestureEventHandlerCallbackType =\n useWorkletCallback(\n function handleOnEnd(\n source,\n { translationY, absoluteY, velocityY },\n context\n ) {\n const highestSnapPoint = animatedHighestSnapPoint.value;\n const isSheetAtHighestSnapPoint =\n animatedPosition.value === highestSnapPoint;\n\n /**\n * if scrollable is refreshable and sheet position at the highest\n * point, then do not interact with current gesture.\n */\n if (\n source === GESTURE_SOURCE.SCROLLABLE &&\n isScrollableRefreshable.value &&\n isSheetAtHighestSnapPoint\n ) {\n return;\n }\n\n /**\n * if the sheet is in a temporary position and the gesture ended above\n * the current position, then we snap back to the temporary position.\n */\n if (\n isInTemporaryPosition.value &&\n context.initialPosition >= animatedPosition.value\n ) {\n if (context.initialPosition > animatedPosition.value) {\n animateToPosition(\n context.initialPosition,\n ANIMATION_SOURCE.GESTURE,\n velocityY / 2\n );\n }\n return;\n }\n\n /**\n * close keyboard if current position is below the recorded\n * start position and keyboard still shown.\n */\n const isScrollable =\n animatedScrollableType.value !== SCROLLABLE_TYPE.UNDETERMINED &&\n animatedScrollableType.value !== SCROLLABLE_TYPE.VIEW;\n\n /**\n * if keyboard is shown and the sheet is dragged down,\n * then we dismiss the keyboard.\n */\n if (\n context.initialKeyboardState === KEYBOARD_STATE.SHOWN &&\n animatedPosition.value > context.initialPosition\n ) {\n /**\n * if the platform is ios, current content is scrollable and\n * the end touch point is below the keyboard position then\n * we exit the method.\n *\n * because the the keyboard dismiss is interactive in iOS.\n */\n if (\n !(\n Platform.OS === 'ios' &&\n isScrollable &&\n absoluteY > WINDOW_HEIGHT - animatedKeyboardHeight.value\n )\n ) {\n runOnJS(Keyboard.dismiss)();\n }\n }\n\n /**\n * reset isInTemporaryPosition value\n */\n if (isInTemporaryPosition.value) {\n isInTemporaryPosition.value = false;\n }\n\n /**\n * clone snap points array, and insert the container height\n * if pan down to close is enabled.\n */\n const snapPoints = animatedSnapPoints.value.slice();\n if (enablePanDownToClose) {\n snapPoints.unshift(animatedClosedPosition.value);\n }\n\n /**\n * calculate the destination point, using redash.\n */\n const destinationPoint = snapPoint(\n translationY + context.initialPosition,\n velocityY,\n snapPoints\n );\n\n /**\n * if destination point is the same as the current position,\n * then no need to perform animation.\n */\n if (destinationPoint === animatedPosition.value) {\n return;\n }\n\n const wasGestureHandledByScrollView =\n source === GESTURE_SOURCE.SCROLLABLE &&\n animatedScrollableContentOffsetY.value > 0;\n /**\n * prevents snapping from top to middle / bottom with repeated interrupted scrolls\n */\n if (wasGestureHandledByScrollView && isSheetAtHighestSnapPoint) {\n return;\n }\n\n animateToPosition(\n destinationPoint,\n ANIMATION_SOURCE.GESTURE,\n velocityY / 2\n );\n },\n [\n enablePanDownToClose,\n isInTemporaryPosition,\n isScrollableRefreshable,\n animatedClosedPosition,\n animatedHighestSnapPoint,\n animatedKeyboardHeight,\n animatedPosition,\n animatedScrollableType,\n animatedSnapPoints,\n animatedScrollableContentOffsetY,\n animateToPosition,\n ]\n );\n //#endregion\n\n return {\n handleOnStart,\n handleOnActive,\n handleOnEnd,\n };\n };\n","import { useEffect } from 'react';\nimport {\n Keyboard,\n KeyboardEvent,\n KeyboardEventEasing,\n KeyboardEventName,\n Platform,\n} from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useSharedValue,\n useWorkletCallback,\n} from 'react-native-reanimated';\nimport { KEYBOARD_STATE } from '../constants';\n\nconst KEYBOARD_EVENT_MAPPER = {\n KEYBOARD_SHOW: Platform.select({\n ios: 'keyboardWillShow',\n android: 'keyboardDidShow',\n default: '',\n }) as KeyboardEventName,\n KEYBOARD_HIDE: Platform.select({\n ios: 'keyboardWillHide',\n android: 'keyboardDidHide',\n default: '',\n }) as KeyboardEventName,\n};\n\nexport const useKeyboard = () => {\n //#region variables\n const shouldHandleKeyboardEvents = useSharedValue(false);\n const keyboardState = useSharedValue(\n KEYBOARD_STATE.UNDETERMINED\n );\n const keyboardHeight = useSharedValue(0);\n const keyboardAnimationEasing =\n useSharedValue('keyboard');\n const keyboardAnimationDuration = useSharedValue(500);\n const temporaryCachedKeyboardEvent = useSharedValue([]);\n //#endregion\n\n //#region worklets\n const handleKeyboardEvent = useWorkletCallback(\n (state, height, duration, easing) => {\n if (state === KEYBOARD_STATE.SHOWN && !shouldHandleKeyboardEvents.value) {\n /**\n * if the keyboard event was fired before the `onFocus` on TextInput,\n * then we cache the input, and wait till the `shouldHandleKeyboardEvents`\n * to be updated then fire this function again.\n */\n temporaryCachedKeyboardEvent.value = [state, height, duration, easing];\n return;\n }\n keyboardHeight.value =\n state === KEYBOARD_STATE.SHOWN\n ? height\n : height === 0\n ? keyboardHeight.value\n : height;\n keyboardAnimationDuration.value = duration;\n keyboardAnimationEasing.value = easing;\n keyboardState.value = state;\n temporaryCachedKeyboardEvent.value = [];\n },\n []\n );\n //#endregion\n\n //#region effects\n useEffect(() => {\n const handleOnKeyboardShow = (event: KeyboardEvent) => {\n runOnUI(handleKeyboardEvent)(\n KEYBOARD_STATE.SHOWN,\n event.endCoordinates.height,\n event.duration,\n event.easing\n );\n };\n const handleOnKeyboardHide = (event: KeyboardEvent) => {\n runOnUI(handleKeyboardEvent)(\n KEYBOARD_STATE.HIDDEN,\n event.endCoordinates.height,\n event.duration,\n event.easing\n );\n };\n\n const showSubscription = Keyboard.addListener(\n KEYBOARD_EVENT_MAPPER.KEYBOARD_SHOW,\n handleOnKeyboardShow\n );\n\n const hideSubscription = Keyboard.addListener(\n KEYBOARD_EVENT_MAPPER.KEYBOARD_HIDE,\n handleOnKeyboardHide\n );\n\n return () => {\n showSubscription.remove();\n hideSubscription.remove();\n };\n }, [handleKeyboardEvent]);\n\n /**\n * This reaction is needed to handle the issue with multiline text input.\n *\n * @link https://github.com/gorhom/react-native-bottom-sheet/issues/411\n */\n useAnimatedReaction(\n () => shouldHandleKeyboardEvents.value,\n result => {\n const params = temporaryCachedKeyboardEvent.value;\n if (result && params.length > 0) {\n handleKeyboardEvent(params[0], params[1], params[2], params[3]);\n }\n }\n );\n //#endregion\n\n return {\n state: keyboardState,\n height: keyboardHeight,\n animationEasing: keyboardAnimationEasing,\n animationDuration: keyboardAnimationDuration,\n shouldHandleKeyboardEvents,\n };\n};\n","import { useEffect, useRef } from 'react';\nimport Animated, {\n cancelAnimation,\n makeMutable,\n} from 'react-native-reanimated';\nimport type { Primitive } from '../types';\n\nexport const useReactiveSharedValue = (\n value: T\n): T extends Primitive ? Animated.SharedValue : T => {\n const initialValueRef = useRef(null);\n const valueRef = useRef>(null);\n\n if (typeof value === 'object' && 'value' in value) {\n /**\n * if provided value is a shared value,\n * then we do not initialize another one.\n */\n } else if (valueRef.current === null) {\n // @ts-ignore\n initialValueRef.current = value;\n /**\n * if value is an object, then we need to\n * pass a clone.\n */\n if (typeof value === 'object') {\n // @ts-ignore\n valueRef.current = makeMutable({ ...value });\n } else {\n // @ts-ignore\n valueRef.current = makeMutable(value);\n }\n } else if (initialValueRef.current !== value) {\n valueRef.current.value = value as T;\n }\n\n useEffect(() => {\n return () => {\n if (valueRef.current) {\n cancelAnimation(valueRef.current);\n }\n };\n }, []);\n\n // @ts-ignore\n return valueRef.current ?? value;\n};\n","import { useContext } from 'react';\nimport { BottomSheetGestureHandlersContext } from '../contexts/gesture';\n\nexport const useBottomSheetGestureHandlers = () => {\n const context = useContext(BottomSheetGestureHandlersContext);\n\n if (context === null) {\n throw \"'useBottomSheetGestureHandlers' cannot be used out of the BottomSheet!\";\n }\n\n return context;\n};\n","import { StyleSheet } from 'react-native';\n\nexport const styles = StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 9999,\n },\n});\n","import React, { memo, useCallback, useMemo, useRef } from 'react';\nimport { LayoutChangeEvent, StatusBar, View, ViewStyle } from 'react-native';\nimport { WINDOW_HEIGHT } from '../../constants';\nimport { print } from '../../utilities';\nimport { styles } from './styles';\nimport type { BottomSheetContainerProps } from './types';\n\nfunction BottomSheetContainerComponent({\n containerHeight,\n containerOffset,\n topInset = 0,\n bottomInset = 0,\n shouldCalculateHeight = true,\n detached,\n children,\n}: BottomSheetContainerProps) {\n const containerRef = useRef(null);\n //#region styles\n const containerStyle = useMemo(\n () => [\n styles.container,\n {\n top: topInset,\n bottom: bottomInset,\n overflow: detached ? 'visible' : 'hidden',\n },\n ],\n [detached, topInset, bottomInset]\n );\n //#endregion\n\n //#region callbacks\n const handleContainerLayout = useCallback(\n function handleContainerLayout({\n nativeEvent: {\n layout: { height },\n },\n }: LayoutChangeEvent) {\n containerHeight.value = height;\n\n containerRef.current?.measure(\n (_x, _y, _width, _height, _pageX, pageY) => {\n containerOffset.value = {\n top: pageY,\n left: 0,\n right: 0,\n bottom: Math.max(\n 0,\n WINDOW_HEIGHT - (pageY + height + (StatusBar.currentHeight ?? 0))\n ),\n };\n }\n );\n\n print({\n component: BottomSheetContainer.displayName,\n method: 'handleContainerLayout',\n params: {\n height,\n },\n });\n },\n [containerHeight, containerOffset, containerRef]\n );\n //#endregion\n\n //#region render\n return (\n \n );\n //#endregion\n}\n\nconst BottomSheetContainer = memo(BottomSheetContainerComponent);\nBottomSheetContainer.displayName = 'BottomSheetContainer';\n\nexport default BottomSheetContainer;\n","import React, { useMemo } from 'react';\nimport { GESTURE_SOURCE } from '../../constants';\nimport {\n useGestureHandler,\n useBottomSheetInternal,\n useGestureEventsHandlersDefault,\n} from '../../hooks';\nimport { BottomSheetGestureHandlersContext } from '../../contexts';\nimport type { BottomSheetGestureHandlersProviderProps } from './types';\nimport { useSharedValue } from 'react-native-reanimated';\n\nconst BottomSheetGestureHandlersProvider = ({\n gestureEventsHandlersHook:\n useGestureEventsHandlers = useGestureEventsHandlersDefault,\n children,\n}: BottomSheetGestureHandlersProviderProps) => {\n //#region variables\n const animatedGestureSource = useSharedValue(\n GESTURE_SOURCE.UNDETERMINED\n );\n //#endregion\n\n //#region hooks\n const { animatedContentGestureState, animatedHandleGestureState } =\n useBottomSheetInternal();\n const { handleOnStart, handleOnActive, handleOnEnd } =\n useGestureEventsHandlers();\n //#endregion\n\n //#region gestures\n const contentPanGestureHandler = useGestureHandler(\n GESTURE_SOURCE.CONTENT,\n animatedContentGestureState,\n animatedGestureSource,\n handleOnStart,\n handleOnActive,\n handleOnEnd\n );\n\n const scrollablePanGestureHandler = useGestureHandler(\n GESTURE_SOURCE.SCROLLABLE,\n animatedContentGestureState,\n animatedGestureSource,\n handleOnStart,\n handleOnActive,\n handleOnEnd\n );\n\n const handlePanGestureHandler = useGestureHandler(\n GESTURE_SOURCE.HANDLE,\n animatedHandleGestureState,\n animatedGestureSource,\n handleOnStart,\n handleOnActive,\n handleOnEnd\n );\n //#endregion\n\n //#region context\n const contextValue = useMemo(\n () => ({\n contentPanGestureHandler,\n handlePanGestureHandler,\n scrollablePanGestureHandler,\n animatedGestureSource,\n }),\n [\n contentPanGestureHandler,\n handlePanGestureHandler,\n scrollablePanGestureHandler,\n animatedGestureSource,\n ]\n );\n //#endregion\n return (\n \n {children}\n \n );\n};\n\nexport default BottomSheetGestureHandlersProvider;\n","import React, { memo } from 'react';\nimport type { BottomSheetBackdropContainerProps } from './types';\nimport { styles } from './styles';\n\nconst BottomSheetBackdropContainerComponent = ({\n animatedIndex,\n animatedPosition,\n backdropComponent: BackdropComponent,\n}: BottomSheetBackdropContainerProps) => {\n return BackdropComponent ? (\n \n ) : null;\n};\n\nconst BottomSheetBackdropContainer = memo(\n BottomSheetBackdropContainerComponent\n);\nBottomSheetBackdropContainer.displayName = 'BottomSheetBackdropContainer';\n\nexport default BottomSheetBackdropContainer;\n","import React, { memo, useMemo } from 'react';\nimport Animated from 'react-native-reanimated';\nimport { styles } from './styles';\nimport type { BottomSheetDefaultHandleProps } from './types';\n\nconst BottomSheetHandleComponent = ({\n style,\n indicatorStyle: _indicatorStyle,\n children,\n}: BottomSheetDefaultHandleProps) => {\n // styles\n const containerStyle = useMemo(\n () => [styles.container, ...[Array.isArray(style) ? style : [style]]],\n [style]\n );\n const indicatorStyle = useMemo(\n () => [\n styles.indicator,\n ...[Array.isArray(_indicatorStyle) ? _indicatorStyle : [_indicatorStyle]],\n ],\n [_indicatorStyle]\n );\n\n // render\n return (\n \n \n {children}\n \n );\n};\n\nconst BottomSheetHandle = memo(BottomSheetHandleComponent);\nBottomSheetHandle.displayName = 'BottomSheetHandle';\n\nexport default BottomSheetHandle;\n","import React, { memo, useCallback, useMemo } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { PanGestureHandler } from 'react-native-gesture-handler';\nimport Animated from 'react-native-reanimated';\nimport BottomSheetHandle from '../bottomSheetHandle';\nimport {\n useBottomSheetGestureHandlers,\n useBottomSheetInternal,\n} from '../../hooks';\nimport { print } from '../../utilities';\nimport type { BottomSheetHandleContainerProps } from './types';\n\nfunction BottomSheetHandleContainerComponent({\n animatedIndex,\n animatedPosition,\n simultaneousHandlers: _internalSimultaneousHandlers,\n enableHandlePanningGesture,\n handleHeight,\n handleComponent: _providedHandleComponent,\n handleStyle: _providedHandleStyle,\n handleIndicatorStyle: _providedIndicatorStyle,\n}: BottomSheetHandleContainerProps) {\n //#region hooks\n const {\n activeOffsetX,\n activeOffsetY,\n failOffsetX,\n failOffsetY,\n waitFor,\n simultaneousHandlers: _providedSimultaneousHandlers,\n } = useBottomSheetInternal();\n const { handlePanGestureHandler } = useBottomSheetGestureHandlers();\n //#endregion\n\n //#region variables\n const simultaneousHandlers = useMemo(() => {\n const refs = [];\n\n if (_internalSimultaneousHandlers) {\n refs.push(_internalSimultaneousHandlers);\n }\n\n if (_providedSimultaneousHandlers) {\n if (Array.isArray(_providedSimultaneousHandlers)) {\n refs.push(..._providedSimultaneousHandlers);\n } else {\n refs.push(_providedSimultaneousHandlers);\n }\n }\n\n return refs;\n }, [_providedSimultaneousHandlers, _internalSimultaneousHandlers]);\n //#endregion\n\n //#region callbacks\n const handleContainerLayout = useCallback(\n function handleContainerLayout({\n nativeEvent: {\n layout: { height },\n },\n }: LayoutChangeEvent) {\n handleHeight.value = height;\n\n print({\n component: BottomSheetHandleContainer.displayName,\n method: 'handleContainerLayout',\n params: {\n height,\n },\n });\n },\n [handleHeight]\n );\n //#endregion\n\n //#region renders\n const HandleComponent =\n _providedHandleComponent === undefined\n ? BottomSheetHandle\n : _providedHandleComponent;\n return HandleComponent !== null ? (\n \n \n \n \n \n ) : null;\n //#endregion\n}\n\nconst BottomSheetHandleContainer = memo(BottomSheetHandleContainerComponent);\nBottomSheetHandleContainer.displayName = 'BottomSheetHandleContainer';\n\nexport default BottomSheetHandleContainer;\n","import React, { memo } from 'react';\nimport { View } from 'react-native';\nimport type { BottomSheetBackgroundProps } from './types';\nimport { styles } from './styles';\n\nconst BottomSheetBackgroundComponent = ({\n pointerEvents,\n style,\n}: BottomSheetBackgroundProps) => (\n \n);\n\nconst BottomSheetBackground = memo(BottomSheetBackgroundComponent);\nBottomSheetBackground.displayName = 'BottomSheetBackground';\n\nexport default BottomSheetBackground;\n","import React, { memo, useMemo } from 'react';\nimport BottomSheetBackground from '../bottomSheetBackground';\nimport type { BottomSheetBackgroundContainerProps } from './types';\nimport { styles } from './styles';\nimport { StyleSheet } from 'react-native';\n\nconst BottomSheetBackgroundContainerComponent = ({\n animatedIndex,\n animatedPosition,\n backgroundComponent: _providedBackgroundComponent,\n backgroundStyle: _providedBackgroundStyle,\n}: BottomSheetBackgroundContainerProps) => {\n const BackgroundComponent =\n _providedBackgroundComponent || BottomSheetBackground;\n\n const backgroundStyle = useMemo(\n () => StyleSheet.flatten([styles.container, _providedBackgroundStyle]),\n [_providedBackgroundStyle]\n );\n\n return _providedBackgroundComponent === null ? null : (\n \n );\n};\n\nconst BottomSheetBackgroundContainer = memo(\n BottomSheetBackgroundContainerComponent\n);\nBottomSheetBackgroundContainer.displayName = 'BottomSheetBackgroundContainer';\n\nexport default BottomSheetBackgroundContainer;\n","import React, { memo } from 'react';\nimport { useDerivedValue } from 'react-native-reanimated';\nimport { useBottomSheetInternal } from '../../hooks';\nimport { KEYBOARD_STATE } from '../../constants';\nimport type { BottomSheetFooterContainerProps } from './types';\n\nconst BottomSheetFooterContainerComponent = ({\n footerComponent: FooterComponent,\n}: BottomSheetFooterContainerProps) => {\n //#region hooks\n const {\n animatedContainerHeight,\n animatedHandleHeight,\n animatedFooterHeight,\n animatedPosition,\n animatedKeyboardState,\n getKeyboardHeightInContainer,\n } = useBottomSheetInternal();\n //#endregion\n\n //#region variables\n const animatedFooterPosition = useDerivedValue(() => {\n const keyboardHeight = getKeyboardHeightInContainer();\n let footerTranslateY = Math.max(\n 0,\n animatedContainerHeight.value - animatedPosition.value\n );\n\n if (animatedKeyboardState.value === KEYBOARD_STATE.SHOWN) {\n footerTranslateY = footerTranslateY - keyboardHeight;\n }\n\n footerTranslateY =\n footerTranslateY -\n animatedFooterHeight.value -\n animatedHandleHeight.value;\n\n return footerTranslateY;\n }, [\n animatedContainerHeight,\n animatedFooterHeight,\n animatedHandleHeight,\n animatedPosition,\n animatedKeyboardState,\n getKeyboardHeightInContainer,\n ]);\n //#endregion\n\n return ;\n};\n\nconst BottomSheetFooterContainer = memo(BottomSheetFooterContainerComponent);\nBottomSheetFooterContainer.displayName = 'BottomSheetFooterContainer';\n\nexport default BottomSheetFooterContainer;\n","import React, { useMemo, useRef, memo } from 'react';\nimport Animated from 'react-native-reanimated';\nimport { PanGestureHandler } from 'react-native-gesture-handler';\nimport {\n useBottomSheetGestureHandlers,\n useBottomSheetInternal,\n} from '../../hooks';\nimport { GESTURE_SOURCE } from '../../constants';\nimport type { BottomSheetDraggableViewProps } from './types';\nimport { styles } from './styles';\n\nconst BottomSheetDraggableViewComponent = ({\n gestureType = GESTURE_SOURCE.CONTENT,\n nativeGestureRef,\n refreshControlGestureRef,\n style,\n children,\n ...rest\n}: BottomSheetDraggableViewProps) => {\n //#region hooks\n const {\n enableContentPanningGesture,\n simultaneousHandlers: _providedSimultaneousHandlers,\n waitFor,\n activeOffsetX,\n activeOffsetY,\n failOffsetX,\n failOffsetY,\n } = useBottomSheetInternal();\n const { contentPanGestureHandler, scrollablePanGestureHandler } =\n useBottomSheetGestureHandlers();\n //#endregion\n\n //#region variables\n const panGestureRef = useRef(null);\n const gestureHandler = useMemo(\n () =>\n gestureType === GESTURE_SOURCE.CONTENT\n ? contentPanGestureHandler\n : scrollablePanGestureHandler,\n [gestureType, contentPanGestureHandler, scrollablePanGestureHandler]\n );\n const simultaneousHandlers = useMemo(() => {\n const refs = [];\n\n if (nativeGestureRef) {\n refs.push(nativeGestureRef);\n }\n\n if (refreshControlGestureRef) {\n refs.push(refreshControlGestureRef);\n }\n\n if (_providedSimultaneousHandlers) {\n if (Array.isArray(_providedSimultaneousHandlers)) {\n refs.push(..._providedSimultaneousHandlers);\n } else {\n refs.push(_providedSimultaneousHandlers);\n }\n }\n\n return refs;\n }, [\n _providedSimultaneousHandlers,\n nativeGestureRef,\n refreshControlGestureRef,\n ]);\n //#endregion\n\n //#region styles\n const containerStyle = useMemo(() => {\n if (!style) {\n return styles.container;\n }\n if (Array.isArray(style)) {\n return [styles.container, ...style];\n }\n return [styles.container, style];\n }, [style]);\n //#endregion\n\n return (\n \n \n {children}\n \n \n );\n};\n\nconst BottomSheetDraggableView = memo(BottomSheetDraggableViewComponent);\nBottomSheetDraggableView.displayName = 'BottomSheetDraggableView';\n\nexport default BottomSheetDraggableView;\n","import React, {\n useMemo,\n useCallback,\n forwardRef,\n useImperativeHandle,\n memo,\n useEffect,\n} from 'react';\nimport { Platform } from 'react-native';\nimport invariant from 'invariant';\nimport Animated, {\n useAnimatedReaction,\n useSharedValue,\n useAnimatedStyle,\n useDerivedValue,\n runOnJS,\n interpolate,\n Extrapolate,\n runOnUI,\n cancelAnimation,\n useWorkletCallback,\n WithSpringConfig,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { State } from 'react-native-gesture-handler';\nimport {\n useScrollable,\n usePropsValidator,\n useReactiveSharedValue,\n useNormalizedSnapPoints,\n useKeyboard,\n} from '../../hooks';\nimport {\n BottomSheetInternalProvider,\n BottomSheetProvider,\n} from '../../contexts';\nimport BottomSheetContainer from '../bottomSheetContainer';\nimport BottomSheetGestureHandlersProvider from '../bottomSheetGestureHandlersProvider';\nimport BottomSheetBackdropContainer from '../bottomSheetBackdropContainer';\nimport BottomSheetHandleContainer from '../bottomSheetHandleContainer';\nimport BottomSheetBackgroundContainer from '../bottomSheetBackgroundContainer';\nimport BottomSheetFooterContainer from '../bottomSheetFooterContainer/BottomSheetFooterContainer';\nimport BottomSheetDraggableView from '../bottomSheetDraggableView';\n// import BottomSheetDebugView from '../bottomSheetDebugView';\nimport {\n ANIMATION_STATE,\n KEYBOARD_STATE,\n KEYBOARD_BEHAVIOR,\n SHEET_STATE,\n SCROLLABLE_STATE,\n KEYBOARD_BLUR_BEHAVIOR,\n KEYBOARD_INPUT_MODE,\n ANIMATION_SOURCE,\n} from '../../constants';\nimport {\n animate,\n getKeyboardAnimationConfigs,\n normalizeSnapPoint,\n print,\n} from '../../utilities';\nimport {\n DEFAULT_OVER_DRAG_RESISTANCE_FACTOR,\n DEFAULT_ENABLE_CONTENT_PANNING_GESTURE,\n DEFAULT_ENABLE_HANDLE_PANNING_GESTURE,\n DEFAULT_ENABLE_OVER_DRAG,\n DEFAULT_ANIMATE_ON_MOUNT,\n DEFAULT_KEYBOARD_BEHAVIOR,\n DEFAULT_KEYBOARD_BLUR_BEHAVIOR,\n DEFAULT_KEYBOARD_INPUT_MODE,\n INITIAL_CONTAINER_HEIGHT,\n INITIAL_HANDLE_HEIGHT,\n INITIAL_POSITION,\n INITIAL_SNAP_POINT,\n DEFAULT_ENABLE_PAN_DOWN_TO_CLOSE,\n INITIAL_CONTAINER_OFFSET,\n} from './constants';\nimport type { BottomSheetMethods, Insets } from '../../types';\nimport type { BottomSheetProps, AnimateToPositionType } from './types';\nimport { styles } from './styles';\n\nAnimated.addWhitelistedUIProps({\n decelerationRate: true,\n});\n\ntype BottomSheet = BottomSheetMethods;\n\nconst BottomSheetComponent = forwardRef(\n function BottomSheet(props, ref) {\n //#region validate props\n usePropsValidator(props);\n //#endregion\n\n //#region extract props\n const {\n // animations configurations\n animationConfigs: _providedAnimationConfigs,\n\n // configurations\n index: _providedIndex = 0,\n snapPoints: _providedSnapPoints,\n animateOnMount = DEFAULT_ANIMATE_ON_MOUNT,\n enableContentPanningGesture = DEFAULT_ENABLE_CONTENT_PANNING_GESTURE,\n enableHandlePanningGesture = DEFAULT_ENABLE_HANDLE_PANNING_GESTURE,\n enableOverDrag = DEFAULT_ENABLE_OVER_DRAG,\n enablePanDownToClose = DEFAULT_ENABLE_PAN_DOWN_TO_CLOSE,\n overDragResistanceFactor = DEFAULT_OVER_DRAG_RESISTANCE_FACTOR,\n\n // styles\n style: _providedStyle,\n backgroundStyle: _providedBackgroundStyle,\n handleStyle: _providedHandleStyle,\n handleIndicatorStyle: _providedHandleIndicatorStyle,\n\n // hooks\n gestureEventsHandlersHook,\n\n // keyboard\n keyboardBehavior = DEFAULT_KEYBOARD_BEHAVIOR,\n keyboardBlurBehavior = DEFAULT_KEYBOARD_BLUR_BEHAVIOR,\n android_keyboardInputMode = DEFAULT_KEYBOARD_INPUT_MODE,\n\n // layout\n handleHeight: _providedHandleHeight,\n containerHeight: _providedContainerHeight,\n contentHeight: _providedContentHeight,\n containerOffset: _providedContainerOffset,\n topInset = 0,\n bottomInset = 0,\n\n // animated callback shared values\n animatedPosition: _providedAnimatedPosition,\n animatedIndex: _providedAnimatedIndex,\n\n // gestures\n simultaneousHandlers: _providedSimultaneousHandlers,\n waitFor: _providedWaitFor,\n activeOffsetX: _providedActiveOffsetX,\n activeOffsetY: _providedActiveOffsetY,\n failOffsetX: _providedFailOffsetX,\n failOffsetY: _providedFailOffsetY,\n\n // callbacks\n onChange: _providedOnChange,\n onClose: _providedOnClose,\n onAnimate: _providedOnAnimate,\n\n // private\n $modal = false,\n detached = false,\n\n // components\n handleComponent,\n backdropComponent,\n backgroundComponent,\n footerComponent,\n children,\n } = props;\n //#endregion\n\n //#region layout variables\n /**\n * This variable is consider an internal variable,\n * that will be used conditionally in `animatedContainerHeight`\n */\n const _animatedContainerHeight = useReactiveSharedValue(\n _providedContainerHeight ?? INITIAL_CONTAINER_HEIGHT\n );\n /**\n * This is a conditional variable, where if the `BottomSheet` is used\n * in a modal, then it will subset vertical insets (top+bottom) from\n * provided container height.\n */\n const animatedContainerHeight = useDerivedValue(() => {\n const verticalInset = topInset + bottomInset;\n return $modal\n ? _animatedContainerHeight.value - verticalInset\n : _animatedContainerHeight.value;\n }, [$modal, topInset, bottomInset]);\n const animatedContainerOffset = useReactiveSharedValue(\n _providedContainerOffset ?? INITIAL_CONTAINER_OFFSET\n ) as Animated.SharedValue;\n const animatedHandleHeight = useReactiveSharedValue(\n _providedHandleHeight ?? INITIAL_HANDLE_HEIGHT\n );\n const animatedFooterHeight = useSharedValue(0);\n const animatedSnapPoints = useNormalizedSnapPoints(\n _providedSnapPoints,\n animatedContainerHeight,\n topInset,\n bottomInset,\n $modal\n );\n const animatedHighestSnapPoint = useDerivedValue(\n () => animatedSnapPoints.value[animatedSnapPoints.value.length - 1]\n );\n const animatedClosedPosition = useDerivedValue(() => {\n let closedPosition = animatedContainerHeight.value;\n\n if ($modal || detached) {\n closedPosition = animatedContainerHeight.value + bottomInset;\n }\n\n return closedPosition;\n }, [$modal, detached, bottomInset]);\n const animatedSheetHeight = useDerivedValue(\n () => animatedContainerHeight.value - animatedHighestSnapPoint.value\n );\n const animatedCurrentIndex = useReactiveSharedValue(\n animateOnMount ? -1 : _providedIndex\n );\n const animatedPosition = useSharedValue(INITIAL_POSITION);\n const animatedNextPosition = useSharedValue(0);\n const animatedNextPositionIndex = useSharedValue(0);\n\n // conditional\n const isAnimatedOnMount = useSharedValue(false);\n const isContentHeightFixed = useSharedValue(false);\n const isLayoutCalculated = useDerivedValue(() => {\n let isContainerHeightCalculated = false;\n //container height was provided.\n if (\n _providedContainerHeight !== null ||\n _providedContainerHeight !== undefined\n ) {\n isContainerHeightCalculated = true;\n }\n // container height did set.\n if (animatedContainerHeight.value !== INITIAL_CONTAINER_HEIGHT) {\n isContainerHeightCalculated = true;\n }\n\n let isHandleHeightCalculated = false;\n // handle height is provided.\n if (\n _providedHandleHeight !== null &&\n _providedHandleHeight !== undefined &&\n typeof _providedHandleHeight === 'number'\n ) {\n isHandleHeightCalculated = true;\n }\n // handle component is null.\n if (handleComponent === null) {\n animatedHandleHeight.value = 0;\n isHandleHeightCalculated = true;\n }\n // handle height did set.\n if (animatedHandleHeight.value !== INITIAL_HANDLE_HEIGHT) {\n isHandleHeightCalculated = true;\n }\n\n let isSnapPointsNormalized = false;\n // the first snap point did normalized\n if (animatedSnapPoints.value[0] !== INITIAL_SNAP_POINT) {\n isSnapPointsNormalized = true;\n }\n\n return (\n isContainerHeightCalculated &&\n isHandleHeightCalculated &&\n isSnapPointsNormalized\n );\n });\n const isInTemporaryPosition = useSharedValue(false);\n const isForcedClosing = useSharedValue(false);\n\n // gesture\n const animatedContentGestureState = useSharedValue(\n State.UNDETERMINED\n );\n const animatedHandleGestureState = useSharedValue(\n State.UNDETERMINED\n );\n //#endregion\n\n //#region hooks variables\n // scrollable variables\n const {\n animatedScrollableType,\n animatedScrollableContentOffsetY,\n animatedScrollableOverrideState,\n isScrollableRefreshable,\n setScrollableRef,\n removeScrollableRef,\n } = useScrollable();\n // keyboard\n const {\n state: animatedKeyboardState,\n height: animatedKeyboardHeight,\n animationDuration: keyboardAnimationDuration,\n animationEasing: keyboardAnimationEasing,\n shouldHandleKeyboardEvents,\n } = useKeyboard();\n /**\n * Returns keyboard height that in the root container.\n */\n const getKeyboardHeightInContainer = useWorkletCallback(() => {\n /**\n * if android software input mode is not `adjustPan`, than keyboard\n * height will be 0 all the time.\n */\n if (\n Platform.OS === 'android' &&\n android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize\n ) {\n return 0;\n }\n\n return $modal\n ? Math.abs(\n animatedKeyboardHeight.value -\n Math.abs(bottomInset - animatedContainerOffset.value.bottom)\n )\n : Math.abs(\n animatedKeyboardHeight.value - animatedContainerOffset.value.bottom\n );\n }, [$modal, bottomInset]);\n //#endregion\n\n //#region state/dynamic variables\n // states\n const animatedAnimationState = useSharedValue(ANIMATION_STATE.UNDETERMINED);\n const animatedAnimationSource = useSharedValue(\n ANIMATION_SOURCE.MOUNT\n );\n const animatedSheetState = useDerivedValue(() => {\n // closed position = position >= container height\n if (animatedPosition.value >= animatedClosedPosition.value)\n return SHEET_STATE.CLOSED;\n\n // extended position = container height - sheet height\n const extendedPosition =\n animatedContainerHeight.value - animatedSheetHeight.value;\n if (animatedPosition.value === extendedPosition)\n return SHEET_STATE.EXTENDED;\n\n // extended position with keyboard =\n // container height - (sheet height + keyboard height in root container)\n const keyboardHeightInContainer = getKeyboardHeightInContainer();\n const extendedPositionWithKeyboard = Math.max(\n 0,\n animatedContainerHeight.value -\n (animatedSheetHeight.value + keyboardHeightInContainer)\n );\n\n // detect if keyboard is open and the sheet is in temporary position\n if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&\n isInTemporaryPosition.value &&\n animatedPosition.value === extendedPositionWithKeyboard\n ) {\n return SHEET_STATE.EXTENDED;\n }\n\n // fill parent = 0\n if (animatedPosition.value === 0) {\n return SHEET_STATE.FILL_PARENT;\n }\n\n // detect if position is below extended point\n if (animatedPosition.value < extendedPosition) {\n return SHEET_STATE.OVER_EXTENDED;\n }\n\n return SHEET_STATE.OPENED;\n }, [keyboardBehavior]);\n const animatedScrollableState = useDerivedValue(() => {\n /**\n * if scrollable override state is set, then we just return its value.\n */\n if (\n animatedScrollableOverrideState.value !== SCROLLABLE_STATE.UNDETERMINED\n ) {\n return animatedScrollableOverrideState.value;\n }\n /**\n * if sheet state is fill parent, then unlock scrolling\n */\n if (animatedSheetState.value === SHEET_STATE.FILL_PARENT) {\n return SCROLLABLE_STATE.UNLOCKED;\n }\n\n /**\n * if sheet state is extended, then unlock scrolling\n */\n if (animatedSheetState.value === SHEET_STATE.EXTENDED) {\n return SCROLLABLE_STATE.UNLOCKED;\n }\n\n /**\n * if keyboard is shown and sheet is animating\n * then we do not lock the scrolling to not lose\n * current scrollable scroll position.\n */\n if (\n animatedKeyboardState.value === KEYBOARD_STATE.SHOWN &&\n animatedAnimationState.value === ANIMATION_STATE.RUNNING\n ) {\n return SCROLLABLE_STATE.UNLOCKED;\n }\n\n return SCROLLABLE_STATE.LOCKED;\n });\n // dynamic\n const animatedContentHeight = useDerivedValue(() => {\n const keyboardHeightInContainer = getKeyboardHeightInContainer();\n const handleHeight = Math.max(0, animatedHandleHeight.value);\n let contentHeight = animatedSheetHeight.value - handleHeight;\n\n if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.extend &&\n animatedKeyboardState.value === KEYBOARD_STATE.SHOWN\n ) {\n contentHeight = contentHeight - keyboardHeightInContainer;\n } else if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.fillParent &&\n isInTemporaryPosition.value\n ) {\n if (animatedKeyboardState.value === KEYBOARD_STATE.SHOWN) {\n contentHeight =\n animatedContainerHeight.value -\n handleHeight -\n keyboardHeightInContainer;\n } else {\n contentHeight = animatedContainerHeight.value - handleHeight;\n }\n } else if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&\n isInTemporaryPosition.value\n ) {\n const contentWithKeyboardHeight =\n contentHeight + keyboardHeightInContainer;\n\n if (animatedKeyboardState.value === KEYBOARD_STATE.SHOWN) {\n if (\n keyboardHeightInContainer + animatedSheetHeight.value >\n animatedContainerHeight.value\n ) {\n contentHeight =\n animatedContainerHeight.value -\n keyboardHeightInContainer -\n handleHeight;\n }\n } else if (\n contentWithKeyboardHeight + handleHeight >\n animatedContainerHeight.value\n ) {\n contentHeight = animatedContainerHeight.value - handleHeight;\n } else {\n contentHeight = contentWithKeyboardHeight;\n }\n }\n\n /**\n * before the container is measured, `contentHeight` value will be below zero,\n * which will lead to freeze the scrollable.\n *\n * @link (https://github.com/gorhom/react-native-bottom-sheet/issues/470)\n */\n return Math.max(contentHeight, 0);\n }, [keyboardBehavior]);\n const animatedIndex = useDerivedValue(() => {\n const adjustedSnapPoints = animatedSnapPoints.value.slice().reverse();\n const adjustedSnapPointsIndexes = animatedSnapPoints.value\n .slice()\n .map((_: any, index: number) => index)\n .reverse();\n\n /**\n * we add the close state index `-1`\n */\n adjustedSnapPoints.push(animatedContainerHeight.value);\n adjustedSnapPointsIndexes.push(-1);\n\n const currentIndex = isLayoutCalculated.value\n ? interpolate(\n animatedPosition.value,\n adjustedSnapPoints,\n adjustedSnapPointsIndexes,\n Extrapolate.CLAMP\n )\n : -1;\n\n /**\n * if the sheet is currently running an animation by the keyboard opening,\n * then we clamp the index on android with resize keyboard mode.\n */\n if (\n android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize &&\n animatedAnimationSource.value === ANIMATION_SOURCE.KEYBOARD &&\n animatedAnimationState.value === ANIMATION_STATE.RUNNING &&\n isInTemporaryPosition.value\n ) {\n return Math.max(animatedCurrentIndex.value, currentIndex);\n }\n\n /**\n * if the sheet is currently running an animation by snap point change - usually caused\n * by dynamic content height -, then we return the next position index.\n */\n if (\n animatedAnimationSource.value === ANIMATION_SOURCE.SNAP_POINT_CHANGE &&\n animatedAnimationState.value === ANIMATION_STATE.RUNNING\n ) {\n return animatedNextPositionIndex.value;\n }\n\n return currentIndex;\n }, [android_keyboardInputMode]);\n //#endregion\n\n //#region private methods\n /**\n * Calculate the next position based on keyboard state.\n */\n const getNextPosition = useWorkletCallback(\n function getNextPosition() {\n 'worklet';\n const currentIndex = animatedCurrentIndex.value;\n const snapPoints = animatedSnapPoints.value;\n const keyboardState = animatedKeyboardState.value;\n const highestSnapPoint = animatedHighestSnapPoint.value;\n\n /**\n * Handle restore sheet position on blur\n */\n if (\n keyboardBlurBehavior === KEYBOARD_BLUR_BEHAVIOR.restore &&\n keyboardState === KEYBOARD_STATE.HIDDEN &&\n animatedContentGestureState.value !== State.ACTIVE &&\n animatedHandleGestureState.value !== State.ACTIVE\n ) {\n isInTemporaryPosition.value = false;\n const nextPosition = snapPoints[currentIndex];\n return nextPosition;\n }\n\n /**\n * Handle extend behavior\n */\n if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.extend &&\n keyboardState === KEYBOARD_STATE.SHOWN\n ) {\n return highestSnapPoint;\n }\n\n /**\n * Handle full screen behavior\n */\n if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.fillParent &&\n keyboardState === KEYBOARD_STATE.SHOWN\n ) {\n isInTemporaryPosition.value = true;\n return 0;\n }\n\n /**\n * handle interactive behavior\n */\n if (\n keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&\n keyboardState === KEYBOARD_STATE.SHOWN\n ) {\n isInTemporaryPosition.value = true;\n const keyboardHeightInContainer = getKeyboardHeightInContainer();\n return Math.max(0, highestSnapPoint - keyboardHeightInContainer);\n }\n\n if (isInTemporaryPosition.value) {\n return animatedPosition.value;\n }\n\n return snapPoints[currentIndex];\n },\n [keyboardBehavior, keyboardBlurBehavior]\n );\n const handleOnChange = useCallback(\n function handleOnChange(index: number) {\n print({\n component: BottomSheet.name,\n method: handleOnChange.name,\n params: {\n index,\n animatedCurrentIndex: animatedCurrentIndex.value,\n },\n });\n\n if (_providedOnChange) {\n _providedOnChange(index);\n }\n },\n [_providedOnChange, animatedCurrentIndex]\n );\n const handleOnAnimate = useCallback(\n function handleOnAnimate(toPoint: number) {\n const snapPoints = animatedSnapPoints.value;\n const toIndex = snapPoints.indexOf(toPoint);\n\n print({\n component: BottomSheet.name,\n method: handleOnAnimate.name,\n params: {\n toIndex,\n fromIndex: animatedCurrentIndex.value,\n },\n });\n\n if (!_providedOnAnimate) {\n return;\n }\n\n if (toIndex !== animatedCurrentIndex.value) {\n _providedOnAnimate(animatedCurrentIndex.value, toIndex);\n }\n },\n [_providedOnAnimate, animatedSnapPoints, animatedCurrentIndex]\n );\n //#endregion\n\n //#region animation\n const stopAnimation = useWorkletCallback(() => {\n cancelAnimation(animatedPosition);\n isForcedClosing.value = false;\n animatedAnimationSource.value = ANIMATION_SOURCE.NONE;\n animatedAnimationState.value = ANIMATION_STATE.STOPPED;\n }, [animatedPosition, animatedAnimationState, animatedAnimationSource]);\n const animateToPositionCompleted = useWorkletCallback(\n function animateToPositionCompleted(isFinished?: boolean) {\n isForcedClosing.value = false;\n\n if (!isFinished) {\n return;\n }\n runOnJS(print)({\n component: BottomSheet.name,\n method: animateToPositionCompleted.name,\n params: {\n animatedCurrentIndex: animatedCurrentIndex.value,\n animatedNextPosition: animatedNextPosition.value,\n animatedNextPositionIndex: animatedNextPositionIndex.value,\n },\n });\n\n animatedAnimationSource.value = ANIMATION_SOURCE.NONE;\n animatedAnimationState.value = ANIMATION_STATE.STOPPED;\n animatedNextPosition.value = Number.NEGATIVE_INFINITY;\n animatedNextPositionIndex.value = Number.NEGATIVE_INFINITY;\n }\n );\n const animateToPosition: AnimateToPositionType = useWorkletCallback(\n function animateToPosition(\n position: number,\n source: ANIMATION_SOURCE,\n velocity: number = 0,\n configs?: WithTimingConfig | WithSpringConfig\n ) {\n if (\n position === animatedPosition.value ||\n position === undefined ||\n (animatedAnimationState.value === ANIMATION_STATE.RUNNING &&\n position === animatedNextPosition.value)\n ) {\n return;\n }\n\n runOnJS(print)({\n component: BottomSheet.name,\n method: animateToPosition.name,\n params: {\n currentPosition: animatedPosition.value,\n position,\n velocity,\n },\n });\n\n stopAnimation();\n\n /**\n * set animation state to running, and source\n */\n animatedAnimationState.value = ANIMATION_STATE.RUNNING;\n animatedAnimationSource.value = source;\n\n /**\n * store next position\n */\n animatedNextPosition.value = position;\n animatedNextPositionIndex.value =\n animatedSnapPoints.value.indexOf(position);\n\n /**\n * fire `onAnimate` callback\n */\n runOnJS(handleOnAnimate)(position);\n\n /**\n * force animation configs from parameters, if provided\n */\n if (configs !== undefined) {\n animatedPosition.value = animate({\n point: position,\n configs,\n velocity,\n onComplete: animateToPositionCompleted,\n });\n } else {\n /**\n * use animationConfigs callback, if provided\n */\n animatedPosition.value = animate({\n point: position,\n velocity,\n configs: _providedAnimationConfigs,\n onComplete: animateToPositionCompleted,\n });\n }\n },\n [handleOnAnimate, _providedAnimationConfigs]\n );\n //#endregion\n\n //#region public methods\n const handleSnapToIndex = useCallback(\n function handleSnapToIndex(\n index: number,\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n const snapPoints = animatedSnapPoints.value;\n invariant(\n index >= -1 && index <= snapPoints.length - 1,\n `'index' was provided but out of the provided snap points range! expected value to be between -1, ${\n snapPoints.length - 1\n }`\n );\n print({\n component: BottomSheet.name,\n method: handleSnapToIndex.name,\n params: {\n index,\n },\n });\n\n const nextPosition = snapPoints[index];\n\n /**\n * exit method if :\n * - layout is not calculated.\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n !isLayoutCalculated.value ||\n index === animatedNextPositionIndex.value ||\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * reset temporary position boolean.\n */\n isInTemporaryPosition.value = false;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n isLayoutCalculated,\n isInTemporaryPosition,\n isForcedClosing,\n animatedSnapPoints,\n animatedNextPosition,\n animatedNextPositionIndex,\n ]\n );\n const handleSnapToPosition = useWorkletCallback(\n function handleSnapToPosition(\n position: number | string,\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n print({\n component: BottomSheet.name,\n method: handleSnapToPosition.name,\n params: {\n position,\n },\n });\n\n /**\n * normalized provided position.\n */\n const nextPosition = normalizeSnapPoint(\n position,\n animatedContainerHeight.value,\n topInset,\n bottomInset\n );\n\n /**\n * exit method if :\n * - layout is not calculated.\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n !isLayoutCalculated ||\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * mark the new position as temporary.\n */\n isInTemporaryPosition.value = true;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n bottomInset,\n topInset,\n isLayoutCalculated,\n isForcedClosing,\n animatedContainerHeight,\n animatedPosition,\n ]\n );\n const handleClose = useCallback(\n function handleClose(\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n print({\n component: BottomSheet.name,\n method: handleClose.name,\n });\n\n const nextPosition = animatedClosedPosition.value;\n\n /**\n * exit method if :\n * - layout is not calculated.\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n !isLayoutCalculated.value ||\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * reset temporary position variable.\n */\n isInTemporaryPosition.value = false;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n isForcedClosing,\n isLayoutCalculated,\n isInTemporaryPosition,\n animatedNextPosition,\n animatedClosedPosition,\n ]\n );\n const handleForceClose = useCallback(\n function handleForceClose(\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n print({\n component: BottomSheet.name,\n method: handleForceClose.name,\n });\n\n const nextPosition = animatedClosedPosition.value;\n\n /**\n * exit method if :\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * reset temporary position variable.\n */\n isInTemporaryPosition.value = false;\n\n /**\n * set force closing variable.\n */\n isForcedClosing.value = true;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n isForcedClosing,\n isInTemporaryPosition,\n animatedNextPosition,\n animatedClosedPosition,\n ]\n );\n const handleExpand = useCallback(\n function handleExpand(\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n print({\n component: BottomSheet.name,\n method: handleExpand.name,\n });\n\n const snapPoints = animatedSnapPoints.value;\n const nextPosition = snapPoints[snapPoints.length - 1];\n\n /**\n * exit method if :\n * - layout is not calculated.\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n !isLayoutCalculated.value ||\n snapPoints.length - 1 === animatedNextPositionIndex.value ||\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * reset temporary position boolean.\n */\n isInTemporaryPosition.value = false;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n isInTemporaryPosition,\n isLayoutCalculated,\n isForcedClosing,\n animatedSnapPoints,\n animatedNextPosition,\n animatedNextPositionIndex,\n ]\n );\n const handleCollapse = useCallback(\n function handleCollapse(\n animationConfigs?: WithSpringConfig | WithTimingConfig\n ) {\n print({\n component: BottomSheet.name,\n method: handleCollapse.name,\n });\n\n const nextPosition = animatedSnapPoints.value[0];\n\n /**\n * exit method if :\n * - layout is not calculated.\n * - already animating to next position.\n * - sheet is forced closing.\n */\n if (\n !isLayoutCalculated ||\n animatedNextPositionIndex.value === 0 ||\n nextPosition === animatedNextPosition.value ||\n isForcedClosing.value\n ) {\n return;\n }\n\n /**\n * reset temporary position boolean.\n */\n isInTemporaryPosition.value = false;\n\n runOnUI(animateToPosition)(\n nextPosition,\n ANIMATION_SOURCE.USER,\n 0,\n animationConfigs\n );\n },\n [\n animateToPosition,\n isForcedClosing,\n isLayoutCalculated,\n isInTemporaryPosition,\n animatedSnapPoints,\n animatedNextPosition,\n animatedNextPositionIndex,\n ]\n );\n\n useImperativeHandle(ref, () => ({\n snapToIndex: handleSnapToIndex,\n snapToPosition: handleSnapToPosition,\n expand: handleExpand,\n collapse: handleCollapse,\n close: handleClose,\n forceClose: handleForceClose,\n }));\n //#endregion\n\n //#region contexts variables\n const internalContextVariables = useMemo(\n () => ({\n enableContentPanningGesture,\n overDragResistanceFactor,\n enableOverDrag,\n enablePanDownToClose,\n animatedAnimationState,\n animatedSheetState,\n animatedScrollableState,\n animatedScrollableOverrideState,\n animatedContentGestureState,\n animatedHandleGestureState,\n animatedKeyboardState,\n animatedScrollableType,\n animatedIndex,\n animatedPosition,\n animatedContentHeight,\n animatedClosedPosition,\n animatedHandleHeight,\n animatedFooterHeight,\n animatedKeyboardHeight,\n animatedContainerHeight,\n animatedSnapPoints,\n animatedHighestSnapPoint,\n animatedScrollableContentOffsetY,\n isInTemporaryPosition,\n isContentHeightFixed,\n isScrollableRefreshable,\n shouldHandleKeyboardEvents,\n simultaneousHandlers: _providedSimultaneousHandlers,\n waitFor: _providedWaitFor,\n activeOffsetX: _providedActiveOffsetX,\n activeOffsetY: _providedActiveOffsetY,\n failOffsetX: _providedFailOffsetX,\n failOffsetY: _providedFailOffsetY,\n animateToPosition,\n stopAnimation,\n getKeyboardHeightInContainer,\n setScrollableRef,\n removeScrollableRef,\n }),\n [\n animatedIndex,\n animatedPosition,\n animatedContentHeight,\n animatedScrollableType,\n animatedContentGestureState,\n animatedHandleGestureState,\n animatedClosedPosition,\n animatedFooterHeight,\n animatedContainerHeight,\n animatedHandleHeight,\n animatedAnimationState,\n animatedKeyboardState,\n animatedKeyboardHeight,\n animatedSheetState,\n animatedHighestSnapPoint,\n animatedScrollableState,\n animatedScrollableOverrideState,\n animatedSnapPoints,\n shouldHandleKeyboardEvents,\n animatedScrollableContentOffsetY,\n isScrollableRefreshable,\n isContentHeightFixed,\n isInTemporaryPosition,\n enableContentPanningGesture,\n overDragResistanceFactor,\n enableOverDrag,\n enablePanDownToClose,\n _providedSimultaneousHandlers,\n _providedWaitFor,\n _providedActiveOffsetX,\n _providedActiveOffsetY,\n _providedFailOffsetX,\n _providedFailOffsetY,\n getKeyboardHeightInContainer,\n setScrollableRef,\n removeScrollableRef,\n animateToPosition,\n stopAnimation,\n ]\n );\n const externalContextVariables = useMemo(\n () => ({\n animatedIndex,\n animatedPosition,\n snapToIndex: handleSnapToIndex,\n snapToPosition: handleSnapToPosition,\n expand: handleExpand,\n collapse: handleCollapse,\n close: handleClose,\n forceClose: handleForceClose,\n }),\n [\n animatedIndex,\n animatedPosition,\n handleSnapToIndex,\n handleSnapToPosition,\n handleExpand,\n handleCollapse,\n handleClose,\n handleForceClose,\n ]\n );\n //#endregion\n\n //#region styles\n const containerAnimatedStyle = useAnimatedStyle(\n () => ({\n opacity:\n Platform.OS === 'android' && animatedIndex.value === -1 ? 0 : 1,\n transform: [\n {\n translateY: animatedPosition.value,\n },\n ],\n }),\n [animatedPosition, animatedIndex]\n );\n const containerStyle = useMemo(\n () => [_providedStyle, styles.container, containerAnimatedStyle],\n [_providedStyle, containerAnimatedStyle]\n );\n const contentContainerAnimatedStyle = useAnimatedStyle(() => {\n /**\n * if content height was provided, then we skip setting\n * calculated height.\n */\n if (_providedContentHeight) {\n return {};\n }\n\n return {\n height: animate({\n point: animatedContentHeight.value,\n configs: _providedAnimationConfigs,\n }),\n };\n }, [animatedContentHeight, _providedContentHeight]);\n const contentContainerStyle = useMemo(\n () => [styles.contentContainer, contentContainerAnimatedStyle],\n [contentContainerAnimatedStyle]\n );\n /**\n * added safe area to prevent the sheet from floating above\n * the bottom of the screen, when sheet being over dragged or\n * when the sheet is resized.\n */\n const contentMaskContainerAnimatedStyle = useAnimatedStyle(() => {\n if (detached) {\n return {\n overflow: 'visible',\n };\n }\n return {\n paddingBottom: animatedContainerHeight.value,\n };\n }, [detached]);\n const contentMaskContainerStyle = useMemo(\n () => [styles.contentMaskContainer, contentMaskContainerAnimatedStyle],\n [contentMaskContainerAnimatedStyle]\n );\n //#endregion\n\n //#region effects\n /**\n * React to `isLayoutCalculated` change, to insure that the sheet will\n * appears/mounts only when all layout is been calculated.\n *\n * @alias OnMount\n */\n useAnimatedReaction(\n () => isLayoutCalculated.value,\n _isLayoutCalculated => {\n /**\n * exit method if:\n * - layout is not calculated yet.\n * - already did animate on mount.\n */\n if (!_isLayoutCalculated || isAnimatedOnMount.value) {\n return;\n }\n\n let nextPosition;\n if (_providedIndex === -1) {\n nextPosition = animatedClosedPosition.value;\n animatedNextPositionIndex.value = -1;\n } else {\n nextPosition = animatedSnapPoints.value[_providedIndex];\n }\n\n runOnJS(print)({\n component: BottomSheet.name,\n method: 'useAnimatedReaction::OnMount',\n params: {\n isLayoutCalculated: _isLayoutCalculated,\n animatedSnapPoints: animatedSnapPoints.value,\n nextPosition,\n },\n });\n\n /**\n * here we exit method early because the next position\n * is out of the screen, this happens when `snapPoints`\n * still being calculated.\n */\n if (\n nextPosition === INITIAL_POSITION ||\n nextPosition === animatedClosedPosition.value\n ) {\n isAnimatedOnMount.value = true;\n animatedCurrentIndex.value = _providedIndex;\n return;\n }\n\n if (animateOnMount) {\n animateToPosition(nextPosition, ANIMATION_SOURCE.MOUNT);\n } else {\n animatedPosition.value = nextPosition;\n }\n isAnimatedOnMount.value = true;\n },\n [_providedIndex, animateOnMount]\n );\n\n /**\n * React to `snapPoints` change, to insure that the sheet position reflect\n * to the current point correctly.\n *\n * @alias OnSnapPointsChange\n */\n useAnimatedReaction(\n () => ({\n snapPoints: animatedSnapPoints.value,\n containerHeight: animatedContainerHeight.value,\n }),\n (result, _previousResult) => {\n const { snapPoints, containerHeight } = result;\n const _previousSnapPoints = _previousResult?.snapPoints;\n const _previousContainerHeight = _previousResult?.containerHeight;\n\n if (\n JSON.stringify(snapPoints) === JSON.stringify(_previousSnapPoints) ||\n !isLayoutCalculated.value ||\n !isAnimatedOnMount.value\n ) {\n return;\n }\n\n runOnJS(print)({\n component: BottomSheet.name,\n method: 'useAnimatedReaction::OnSnapPointChange',\n params: {\n snapPoints,\n },\n });\n\n let nextPosition;\n let animationConfig;\n let animationSource = ANIMATION_SOURCE.SNAP_POINT_CHANGE;\n\n /**\n * if snap points changed while sheet is animating, then\n * we stop the animation and animate to the updated point.\n */\n if (animatedAnimationState.value === ANIMATION_STATE.RUNNING) {\n nextPosition =\n animatedNextPositionIndex.value !== -1\n ? snapPoints[animatedNextPositionIndex.value]\n : animatedNextPosition.value;\n } else if (animatedCurrentIndex.value === -1) {\n nextPosition = animatedClosedPosition.value;\n } else if (isInTemporaryPosition.value) {\n nextPosition = getNextPosition();\n } else {\n nextPosition = snapPoints[animatedCurrentIndex.value];\n\n /**\n * if snap points changes because of the container height change,\n * then we skip the snap animation by setting the duration to 0.\n */\n if (containerHeight !== _previousContainerHeight) {\n animationSource = ANIMATION_SOURCE.CONTAINER_RESIZE;\n animationConfig = {\n duration: 0,\n };\n }\n }\n animateToPosition(nextPosition, animationSource, 0, animationConfig);\n }\n );\n\n /**\n * React to keyboard appearance state.\n *\n * @alias OnKeyboardStateChange\n */\n useAnimatedReaction(\n () => ({\n _keyboardState: animatedKeyboardState.value,\n _keyboardHeight: animatedKeyboardHeight.value,\n }),\n (result, _previousResult) => {\n const { _keyboardState, _keyboardHeight } = result;\n const _previousKeyboardState = _previousResult?._keyboardState;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n const hasActiveGesture =\n animatedContentGestureState.value === State.ACTIVE ||\n animatedContentGestureState.value === State.BEGAN ||\n animatedHandleGestureState.value === State.ACTIVE ||\n animatedHandleGestureState.value === State.BEGAN;\n\n if (\n /**\n * if keyboard state is equal to the previous state, then exit the method\n */\n (_keyboardState === _previousKeyboardState &&\n _keyboardHeight === _previousKeyboardHeight) ||\n /**\n * if user is interacting with sheet, then exit the method\n */\n hasActiveGesture ||\n /**\n * if sheet not animated on mount yet, then exit the method\n */\n !isAnimatedOnMount.value ||\n /**\n * if new keyboard state is hidden and blur behavior is none, then exit the method\n */\n (_keyboardState === KEYBOARD_STATE.HIDDEN &&\n keyboardBlurBehavior === KEYBOARD_BLUR_BEHAVIOR.none) ||\n /**\n * if platform is android and the input mode is resize, then exit the method\n */\n (Platform.OS === 'android' &&\n keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&\n android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize)\n ) {\n return;\n }\n\n runOnJS(print)({\n component: BottomSheet.name,\n method: 'useAnimatedReaction::OnKeyboardStateChange',\n params: {\n keyboardState: _keyboardState,\n keyboardHeight: _keyboardHeight,\n },\n });\n\n let animationConfigs = getKeyboardAnimationConfigs(\n keyboardAnimationEasing.value,\n keyboardAnimationDuration.value\n );\n const nextPosition = getNextPosition();\n animateToPosition(\n nextPosition,\n ANIMATION_SOURCE.KEYBOARD,\n 0,\n animationConfigs\n );\n },\n [\n keyboardBehavior,\n keyboardBlurBehavior,\n android_keyboardInputMode,\n getNextPosition,\n ]\n );\n\n /**\n * sets provided animated position\n */\n useAnimatedReaction(\n () => animatedPosition.value,\n _animatedPosition => {\n if (_providedAnimatedPosition) {\n _providedAnimatedPosition.value = _animatedPosition + topInset;\n }\n }\n );\n\n /**\n * sets provided animated index\n */\n useAnimatedReaction(\n () => animatedIndex.value,\n _animatedIndex => {\n if (_providedAnimatedIndex) {\n _providedAnimatedIndex.value = _animatedIndex;\n }\n }\n );\n\n /**\n * React to internal variables to detect change in snap position.\n *\n * @alias OnChange\n */\n useAnimatedReaction(\n () => ({\n _animatedIndex: animatedIndex.value,\n _animatedPosition: animatedPosition.value,\n _animationState: animatedAnimationState.value,\n _contentGestureState: animatedContentGestureState.value,\n _handleGestureState: animatedHandleGestureState.value,\n }),\n ({\n _animatedIndex,\n _animationState,\n _contentGestureState,\n _handleGestureState,\n }) => {\n /**\n * exit the method if animation state is not stopped.\n */\n if (_animationState !== ANIMATION_STATE.STOPPED) {\n return;\n }\n\n /**\n * exit the method if animated index value\n * has fraction, e.g. 1.99, 0.52\n */\n if (_animatedIndex % 1 !== 0) {\n return;\n }\n\n /**\n * exit the method if there any active gesture.\n */\n const hasNoActiveGesture =\n (_contentGestureState === State.END ||\n _contentGestureState === State.UNDETERMINED ||\n _contentGestureState === State.CANCELLED) &&\n (_handleGestureState === State.END ||\n _handleGestureState === State.UNDETERMINED ||\n _handleGestureState === State.CANCELLED);\n if (!hasNoActiveGesture) {\n return;\n }\n\n /**\n * if the index is not equal to the current index,\n * than the sheet position had changed and we trigger\n * the `onChange` callback.\n */\n if (_animatedIndex !== animatedCurrentIndex.value) {\n runOnJS(print)({\n component: BottomSheet.name,\n method: 'useAnimatedReaction::OnChange',\n params: {\n animatedCurrentIndex: animatedCurrentIndex.value,\n animatedIndex: _animatedIndex,\n },\n });\n\n animatedCurrentIndex.value = _animatedIndex;\n runOnJS(handleOnChange)(_animatedIndex);\n }\n\n /**\n * if index is `-1` than we fire the `onClose` callback.\n */\n if (_animatedIndex === -1 && _providedOnClose) {\n runOnJS(print)({\n component: BottomSheet.name,\n method: 'useAnimatedReaction::onClose',\n params: {\n animatedCurrentIndex: animatedCurrentIndex.value,\n animatedIndex: _animatedIndex,\n },\n });\n runOnJS(_providedOnClose)();\n }\n },\n [handleOnChange, _providedOnClose]\n );\n\n /**\n * React to `index` prop to snap the sheet to the new position.\n *\n * @alias onIndexChange\n */\n useEffect(() => {\n if (isAnimatedOnMount.value) {\n handleSnapToIndex(_providedIndex);\n }\n }, [\n _providedIndex,\n animatedCurrentIndex,\n isAnimatedOnMount,\n handleSnapToIndex,\n ]);\n //#endregion\n\n // render\n print({\n component: BottomSheet.name,\n method: 'render',\n params: {\n animatedSnapPoints: animatedSnapPoints.value,\n animatedCurrentIndex: animatedCurrentIndex.value,\n providedIndex: _providedIndex,\n },\n });\n return (\n \n \n \n \n \n \n \n \n \n {typeof children === 'function'\n ? (children as Function)()\n : children}\n\n {footerComponent && (\n \n )}\n \n \n \n \n {/* */}\n \n \n \n \n );\n }\n);\n\nconst BottomSheet = memo(BottomSheetComponent);\nBottomSheet.displayName = 'BottomSheet';\n\nexport default BottomSheet;\n","import { useMemo } from 'react';\nimport invariant from 'invariant';\nimport { INITIAL_SNAP_POINT } from '../components/bottomSheet/constants';\nimport type { BottomSheetProps } from '../components/bottomSheet';\n\n/**\n * @todo\n * replace this with `prop-types`.\n */\n\nexport const usePropsValidator = ({\n index,\n snapPoints,\n topInset,\n bottomInset,\n}: BottomSheetProps) => {\n useMemo(() => {\n //#region snap points\n const _snapPoints = 'value' in snapPoints ? snapPoints.value : snapPoints;\n invariant(\n _snapPoints,\n `'snapPoints' was not provided! please provide at least one snap point.`\n );\n\n _snapPoints.map(snapPoint => {\n const _snapPoint =\n typeof snapPoint === 'number'\n ? snapPoint\n : parseInt(snapPoint.replace('%', ''), 10);\n\n invariant(\n _snapPoint > 0 || _snapPoint === INITIAL_SNAP_POINT,\n `Snap point '${snapPoint}' is invalid. if you want to allow user to close the sheet, Please use 'enablePanDownToClose' prop.`\n );\n });\n\n invariant(\n 'value' in _snapPoints || _snapPoints.length > 0,\n `'snapPoints' was provided with no points! please provide at least one snap point.`\n );\n //#endregion\n\n //#region index\n invariant(\n typeof index === 'number' || typeof index === 'undefined',\n `'index' was provided but with wrong type ! expected type is a number.`\n );\n\n invariant(\n typeof index === 'number'\n ? index >= -1 && index <= _snapPoints.length - 1\n : true,\n `'index' was provided but out of the provided snap points range! expected value to be between -1, ${\n _snapPoints.length - 1\n }`\n );\n //#endregion\n\n //#region insets\n invariant(\n typeof topInset === 'number' || typeof topInset === 'undefined',\n `'topInset' was provided but with wrong type ! expected type is a number.`\n );\n invariant(\n typeof bottomInset === 'number' || typeof bottomInset === 'undefined',\n `'bottomInset' was provided but with wrong type ! expected type is a number.`\n );\n //#endregion\n\n // animations\n }, [index, snapPoints, topInset, bottomInset]);\n};\n","import Animated, { useDerivedValue } from 'react-native-reanimated';\nimport { normalizeSnapPoint } from '../utilities';\nimport type { BottomSheetProps } from '../components/bottomSheet';\nimport {\n INITIAL_CONTAINER_HEIGHT,\n INITIAL_SNAP_POINT,\n} from '../components/bottomSheet/constants';\n\n/**\n * Convert percentage snap points to pixels in screen and calculate\n * the accurate snap points positions.\n * @param providedSnapPoints provided snap points.\n * @param containerHeight BottomSheetContainer height.\n * @param topInset top inset.\n * @param bottomInset bottom inset.\n * @param $modal is sheet in a modal.\n * @returns {Animated.SharedValue}\n */\nexport const useNormalizedSnapPoints = (\n providedSnapPoints: BottomSheetProps['snapPoints'],\n containerHeight: Animated.SharedValue,\n topInset: number,\n bottomInset: number,\n $modal: boolean\n) => {\n const normalizedSnapPoints = useDerivedValue(() =>\n ('value' in providedSnapPoints\n ? providedSnapPoints.value\n : providedSnapPoints\n ).map(snapPoint => {\n if (containerHeight.value === INITIAL_CONTAINER_HEIGHT) {\n return INITIAL_SNAP_POINT;\n }\n\n return normalizeSnapPoint(\n snapPoint,\n containerHeight.value,\n topInset,\n bottomInset,\n $modal\n );\n })\n );\n\n return normalizedSnapPoints;\n};\n","import { useCallback, RefObject, useRef } from 'react';\nimport { findNodeHandle } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { SCROLLABLE_STATE, SCROLLABLE_TYPE } from '../constants';\nimport type { ScrollableRef, Scrollable } from '../types';\n\nexport const useScrollable = () => {\n // refs\n const scrollableRef = useRef(null);\n const previousScrollableRef = useRef(null);\n\n // variables\n const animatedScrollableType = useSharedValue(\n SCROLLABLE_TYPE.UNDETERMINED\n );\n const animatedScrollableContentOffsetY = useSharedValue(0);\n const animatedScrollableOverrideState = useSharedValue(\n SCROLLABLE_STATE.UNDETERMINED\n );\n const isScrollableRefreshable = useSharedValue(false);\n\n // callbacks\n const setScrollableRef = useCallback((ref: ScrollableRef) => {\n // get current node handle id\n let currentRefId = scrollableRef.current?.id ?? null;\n\n if (currentRefId !== ref.id) {\n if (scrollableRef.current) {\n // @ts-ignore\n previousScrollableRef.current = scrollableRef.current;\n }\n // @ts-ignore\n scrollableRef.current = ref;\n }\n }, []);\n\n const removeScrollableRef = useCallback((ref: RefObject) => {\n // find node handle id\n let id;\n try {\n id = findNodeHandle(ref.current);\n } catch {\n return;\n }\n\n // get current node handle id\n let currentRefId = scrollableRef.current?.id ?? null;\n\n /**\n * @DEV\n * when the incoming node is actually the current node, we reset\n * the current scrollable ref to the previous one.\n */\n if (id === currentRefId) {\n // @ts-ignore\n scrollableRef.current = previousScrollableRef.current;\n }\n }, []);\n\n return {\n scrollableRef,\n animatedScrollableType,\n animatedScrollableContentOffsetY,\n animatedScrollableOverrideState,\n isScrollableRefreshable,\n setScrollableRef,\n removeScrollableRef,\n };\n};\n","let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nlet nanoid = (size = 21) => {\n let id = ''\n let i = size\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\nexport { nanoid, customAlphabet }\n","import { createContext } from 'react';\nimport type { ActionTypes } from '../state/types';\nimport type { PortalType } from '../types';\n\nexport const PortalStateContext = createContext\n> | null>(null);\nexport const PortalDispatchContext =\n createContext | null>(null);\n","import { ReactNode, useCallback, useContext } from 'react';\nimport { ACTIONS } from '../state/constants';\nimport { PortalDispatchContext } from '../contexts/portal';\n\nexport const usePortal = (hostName: string = 'root') => {\n const dispatch = useContext(PortalDispatchContext);\n\n if (dispatch === null) {\n throw new Error(\n \"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.\"\n );\n }\n\n //#region methods\n const registerHost = useCallback(() => {\n dispatch({\n type: ACTIONS.REGISTER_HOST,\n hostName: hostName,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const deregisterHost = useCallback(() => {\n dispatch({\n type: ACTIONS.DEREGISTER_HOST,\n hostName: hostName,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const addUpdatePortal = useCallback((name: string, node: ReactNode) => {\n dispatch({\n type: ACTIONS.ADD_UPDATE_PORTAL,\n hostName,\n portalName: name,\n node,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const removePortal = useCallback((name: string) => {\n dispatch({\n type: ACTIONS.REMOVE_PORTAL,\n hostName,\n portalName: name,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n //#endregion\n\n return {\n registerHost,\n deregisterHost,\n addPortal: addUpdatePortal,\n updatePortal: addUpdatePortal,\n removePortal,\n };\n};\n","import React, { useEffect } from 'react';\nimport type { ReactNode } from 'react';\nimport { StyleSheet, View, ViewProps } from 'react-native';\n\ntype OverlayItem = {\n id: number;\n node: ReactNode;\n};\n\ninterface PortalContext {\n items: Array;\n setOverlayItem: (node: ReactNode) => number;\n removeOverlayItem: (id: number) => void;\n updateOverlayItem: (id: number, node: ReactNode) => void;\n}\n\ninterface ModalProviderProps extends ViewProps {\n children: ReactNode;\n provider?: boolean;\n}\n\nconst PortalContext = React.createContext(null);\n\nlet globalOverlayCounter = 0;\n\nexport function PortalProvider(props: { children: ReactNode }) {\n const [items, setItems] = React.useState>([]);\n\n const setOverlayItem = (item: ReactNode) => {\n const overlayId = ++globalOverlayCounter;\n setItems((prev) => prev.concat([{ id: overlayId, node: item }]));\n return overlayId;\n };\n\n const updateOverlayItem = (id: number, node: ReactNode) => {\n setItems((prev) =>\n prev.map((item) => {\n if (item.id === id) {\n return { id, node };\n }\n return item;\n })\n );\n };\n\n const removeOverlayItem = (id: number) => {\n setItems((prev) => {\n const newItems = prev.filter((item) => item.id !== id);\n return newItems;\n });\n };\n\n return (\n \n {props.children}\n\n {/* Render Overlays */}\n {items.map((item) => {\n return {item.node};\n })}\n \n );\n}\n\nfunction OverlayView({style, ...props}: ModalProviderProps) {\n return (\n \n );\n}\n\nexport const OverlayProvider = PortalProvider;\n\nexport function OverlayContainer(props: ModalProviderProps) {\n const context = usePortalProvider();\n const overlayId = React.useRef(undefined);\n let contents = ;\n\n useEffect(\n () => {\n // Mount\n if (overlayId.current === undefined) {\n overlayId.current = context?.setOverlayItem(contents);\n }\n // Update\n else {\n if (overlayId.current) {\n context?.updateOverlayItem(overlayId.current, contents);\n }\n }\n },\n // To re-render the child\n [props]\n );\n\n // Unmount\n useEffect(() => {\n return () => {\n if (overlayId.current) {\n context?.removeOverlayItem(overlayId.current);\n }\n };\n }, []);\n\n return null;\n}\n\nfunction usePortalProvider() {\n const context = React.useContext(PortalContext);\n return context;\n}\n","import { useContext } from 'react';\nimport { PortalStateContext } from '../contexts/portal';\n\nexport const usePortalState = (hostName: string) => {\n const state = useContext(PortalStateContext);\n\n if (state === null) {\n throw new Error(\n \"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.\"\n );\n }\n\n return state[hostName] || [];\n};\n","import React, { memo, useEffect } from 'react';\nimport { usePortalState } from '../../hooks/usePortalState';\nimport { usePortal } from '../../hooks/usePortal';\nimport type { PortalHostProps } from './types';\n\nconst PortalHostComponent = ({ name }: PortalHostProps) => {\n //#region hooks\n const state = usePortalState(name);\n const { registerHost, deregisterHost } = usePortal(name);\n //#endregion\n\n //#region effects\n useEffect(() => {\n registerHost();\n return () => {\n deregisterHost();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n //#endregion\n\n //#region render\n return <>{state.map(item => item.node)}>;\n //#endregion\n};\n\nexport const PortalHost = memo(PortalHostComponent);\nPortalHost.displayName = 'PortalHost';\n","import { ACTIONS } from './constants';\nimport { print } from '../utilities/logger';\nimport type { PortalType } from '../types';\nimport type {\n ActionTypes,\n AddUpdatePortalAction,\n RemovePortalAction,\n} from './types';\n\nconst registerHost = (\n state: Record>,\n hostName: string\n) => {\n if (!(hostName in state)) {\n state[hostName] = [];\n }\n return state;\n};\n\nconst deregisterHost = (\n state: Record>,\n hostName: string\n) => {\n delete state[hostName];\n return state;\n};\n\nconst addUpdatePortal = (\n state: Record>,\n hostName: string,\n portalName: string,\n node: any\n) => {\n if (!(hostName in state)) {\n state = registerHost(state, hostName);\n }\n\n /**\n * updated portal, if it was already added.\n */\n const index = state[hostName].findIndex(item => item.name === portalName);\n if (index !== -1) {\n state[hostName][index].node = node;\n } else {\n state[hostName].push({\n name: portalName,\n node,\n });\n }\n return state;\n};\n\nconst removePortal = (\n state: Record>,\n hostName: string,\n portalName: string\n) => {\n if (!(hostName in state)) {\n print({\n component: reducer.name,\n method: removePortal.name,\n params: `Failed to remove portal '${portalName}', '${hostName}' was not registered!`,\n });\n return state;\n }\n\n const index = state[hostName].findIndex(item => item.name === portalName);\n if (index !== -1) state[hostName].splice(index, 1);\n return state;\n};\n\nexport const reducer = (\n state: Record>,\n action: ActionTypes\n) => {\n const { type } = action;\n let clonedState = { ...state };\n switch (type) {\n case ACTIONS.REGISTER_HOST:\n return registerHost(clonedState, action.hostName);\n case ACTIONS.DEREGISTER_HOST:\n return deregisterHost(clonedState, action.hostName);\n case ACTIONS.ADD_UPDATE_PORTAL:\n return addUpdatePortal(\n clonedState,\n action.hostName,\n (action as AddUpdatePortalAction).portalName,\n (action as AddUpdatePortalAction).node\n );\n case ACTIONS.REMOVE_PORTAL:\n return removePortal(\n clonedState,\n action.hostName,\n (action as RemovePortalAction).portalName\n );\n default:\n return state;\n }\n};\n","import React, { memo, useReducer } from 'react';\nimport { PortalHost } from '../portalHost/PortalHost';\nimport {\n PortalDispatchContext,\n PortalStateContext,\n} from '../../contexts/portal';\nimport { INITIAL_STATE } from '../../state/constants';\nimport { reducer } from '../../state/reducer';\nimport type { PortalProviderProps } from './types';\n\nconst PortalProviderComponent = ({\n rootHostName = 'root',\n shouldAddRootHost = true,\n children,\n}: PortalProviderProps) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_STATE);\n return (\n \n \n {children}\n {shouldAddRootHost && }\n \n \n );\n};\n\nexport const PortalProvider = memo(PortalProviderComponent);\nPortalProvider.displayName = 'PortalProvider';\n","let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nlet nanoid = (size = 21) => {\n let id = ''\n let i = size\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\nexport { nanoid, customAlphabet }\n","import React, {\n forwardRef,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Portal, usePortal } from '@gorhom/portal';\nimport { nanoid } from 'nanoid/non-secure';\nimport BottomSheet from '../bottomSheet';\nimport { useBottomSheetModalInternal } from '../../hooks';\nimport { print } from '../../utilities';\nimport {\n DEFAULT_STACK_BEHAVIOR,\n DEFAULT_ENABLE_DISMISS_ON_CLOSE,\n} from './constants';\nimport type { BottomSheetModalMethods, BottomSheetMethods } from '../../types';\nimport type { BottomSheetModalProps } from './types';\n\ntype BottomSheetModal = BottomSheetModalMethods;\n\nconst BottomSheetModalComponent = forwardRef<\n BottomSheetModal,\n BottomSheetModalProps\n>(function BottomSheetModal(props, ref) {\n const {\n // modal props\n name,\n stackBehavior = DEFAULT_STACK_BEHAVIOR,\n enableDismissOnClose = DEFAULT_ENABLE_DISMISS_ON_CLOSE,\n onDismiss: _providedOnDismiss,\n\n // bottom sheet props\n index = 0,\n snapPoints,\n enablePanDownToClose = true,\n\n // callbacks\n onChange: _providedOnChange,\n\n // components\n children,\n ...bottomSheetProps\n } = props;\n\n //#region state\n const [mount, setMount] = useState(false);\n //#endregion\n\n //#region hooks\n const {\n containerHeight,\n containerOffset,\n mountSheet,\n unmountSheet,\n willUnmountSheet,\n } = useBottomSheetModalInternal();\n const { removePortal: unmountPortal } = usePortal();\n //#endregion\n\n //#region refs\n const bottomSheetRef = useRef(null);\n const currentIndexRef = useRef(-1);\n const restoreIndexRef = useRef(-1);\n const minimized = useRef(false);\n const forcedDismissed = useRef(false);\n const mounted = useRef(false);\n mounted.current = mount;\n //#endregion\n\n //#region variables\n const key = useMemo(() => name || `bottom-sheet-modal-${nanoid()}`, [name]);\n //#endregion\n\n //#region private methods\n const resetVariables = useCallback(function resetVariables() {\n print({\n component: BottomSheetModal.name,\n method: resetVariables.name,\n });\n currentIndexRef.current = -1;\n restoreIndexRef.current = -1;\n minimized.current = false;\n mounted.current = false;\n forcedDismissed.current = false;\n }, []);\n const unmount = useCallback(\n function unmount() {\n print({\n component: BottomSheetModal.name,\n method: unmount.name,\n });\n const _mounted = mounted.current;\n\n // reset variables\n resetVariables();\n\n // unmount sheet and portal\n unmountSheet(key);\n unmountPortal(key);\n\n // unmount the node, if sheet is still mounted\n if (_mounted) {\n setMount(false);\n }\n\n // fire `onDismiss` callback\n if (_providedOnDismiss) {\n _providedOnDismiss();\n }\n },\n [key, resetVariables, unmountSheet, unmountPortal, _providedOnDismiss]\n );\n //#endregion\n\n //#region bottom sheet methods\n const handleSnapToIndex = useCallback(\n (...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.snapToIndex(...args);\n },\n []\n );\n const handleSnapToPosition = useCallback<\n BottomSheetMethods['snapToPosition']\n >((...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.snapToPosition(...args);\n }, []);\n const handleExpand = useCallback((...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.expand(...args);\n }, []);\n const handleCollapse = useCallback((...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.collapse(...args);\n }, []);\n const handleClose = useCallback((...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.close(...args);\n }, []);\n const handleForceClose = useCallback((...args) => {\n if (minimized.current) {\n return;\n }\n bottomSheetRef.current?.forceClose(...args);\n }, []);\n //#endregion\n\n //#region bottom sheet modal methods\n const handlePresent = useCallback(\n function handlePresent() {\n requestAnimationFrame(() => {\n setMount(true);\n mountSheet(key, ref, stackBehavior);\n\n print({\n component: BottomSheetModal.name,\n method: handlePresent.name,\n });\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [key, stackBehavior, mountSheet]\n );\n const handleDismiss = useCallback(\n function handleDismiss(animationConfigs) {\n print({\n component: BottomSheetModal.name,\n method: handleDismiss.name,\n params: {\n currentIndexRef: currentIndexRef.current,\n minimized: minimized.current,\n },\n });\n /**\n * if modal is already been dismiss, we exit the method.\n */\n if (currentIndexRef.current === -1 && minimized.current === false) {\n return;\n }\n\n if (\n minimized.current ||\n (currentIndexRef.current === -1 && enablePanDownToClose)\n ) {\n unmount();\n return;\n }\n willUnmountSheet(key);\n forcedDismissed.current = true;\n bottomSheetRef.current?.forceClose(animationConfigs);\n },\n [willUnmountSheet, unmount, key, enablePanDownToClose]\n );\n const handleMinimize = useCallback(\n function handleMinimize() {\n print({\n component: BottomSheetModal.name,\n method: handleMinimize.name,\n params: {\n minimized: minimized.current,\n },\n });\n if (minimized.current) {\n return;\n }\n minimized.current = true;\n\n /**\n * if modal got minimized before it finish its mounting\n * animation, we set the `restoreIndexRef` to the\n * provided index.\n */\n if (currentIndexRef.current === -1) {\n restoreIndexRef.current = index;\n } else {\n restoreIndexRef.current = currentIndexRef.current;\n }\n bottomSheetRef.current?.close();\n },\n [index]\n );\n const handleRestore = useCallback(function handleRestore() {\n print({\n component: BottomSheetModal.name,\n method: handleRestore.name,\n params: {\n minimized: minimized.current,\n forcedDismissed: forcedDismissed.current,\n },\n });\n if (!minimized.current || forcedDismissed.current) {\n return;\n }\n minimized.current = false;\n bottomSheetRef.current?.snapToIndex(restoreIndexRef.current);\n }, []);\n //#endregion\n\n //#region callbacks\n const handlePortalOnUnmount = useCallback(\n function handlePortalOnUnmount() {\n print({\n component: BottomSheetModal.name,\n method: handlePortalOnUnmount.name,\n params: {\n minimized: minimized.current,\n forcedDismissed: forcedDismissed.current,\n },\n });\n /**\n * if modal is already been dismiss, we exit the method.\n */\n if (currentIndexRef.current === -1 && minimized.current === false) {\n return;\n }\n\n mounted.current = false;\n forcedDismissed.current = true;\n\n if (minimized.current) {\n unmount();\n return;\n }\n willUnmountSheet(key);\n bottomSheetRef.current?.close();\n },\n [key, unmount, willUnmountSheet]\n );\n const handlePortalRender = useCallback(function handlePortalRender(\n render: () => void\n ) {\n if (mounted.current) {\n render();\n }\n },\n []);\n const handleBottomSheetOnChange = useCallback(\n function handleBottomSheetOnChange(_index: number) {\n print({\n component: BottomSheetModal.name,\n method: handleBottomSheetOnChange.name,\n params: {\n minimized: minimized.current,\n forcedDismissed: forcedDismissed.current,\n },\n });\n currentIndexRef.current = _index;\n\n if (_providedOnChange) {\n _providedOnChange(_index);\n }\n },\n [_providedOnChange]\n );\n const handleBottomSheetOnClose = useCallback(\n function handleBottomSheetOnClose() {\n print({\n component: BottomSheetModal.name,\n method: handleBottomSheetOnClose.name,\n params: {\n minimized: minimized.current,\n forcedDismissed: forcedDismissed.current,\n },\n });\n\n if (minimized.current) {\n return;\n }\n\n if (enableDismissOnClose) {\n unmount();\n }\n },\n [enableDismissOnClose, unmount]\n );\n //#endregion\n\n //#region expose methods\n useImperativeHandle(ref, () => ({\n // sheet\n snapToIndex: handleSnapToIndex,\n snapToPosition: handleSnapToPosition,\n expand: handleExpand,\n collapse: handleCollapse,\n close: handleClose,\n forceClose: handleForceClose,\n // modal methods\n dismiss: handleDismiss,\n present: handlePresent,\n // internal\n minimize: handleMinimize,\n restore: handleRestore,\n }));\n //#endregion\n\n // render\n // console.log('BottomSheetModal', index, snapPoints)\n return mount ? (\n \n \n \n ) : null;\n});\n\nconst BottomSheetModal = memo(BottomSheetModalComponent);\nBottomSheetModal.displayName = 'BottomSheetModal';\n\nexport default BottomSheetModal;\n","import { useContext } from 'react';\nimport {\n BottomSheetModalInternalContext,\n BottomSheetModalInternalContextType,\n} from '../contexts';\n\nexport function useBottomSheetModalInternal(\n unsafe?: false\n): BottomSheetModalInternalContextType;\n\nexport function useBottomSheetModalInternal(\n unsafe: true\n): BottomSheetModalInternalContextType | null;\n\nexport function useBottomSheetModalInternal(\n unsafe?: boolean\n): BottomSheetModalInternalContextType | null {\n const context = useContext(BottomSheetModalInternalContext);\n\n if (unsafe !== true && context === null) {\n throw \"'BottomSheetModalInternalContext' cannot be null!\";\n }\n\n return context;\n}\n","export default () => null;\n","import React, { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Platform } from 'react-native';\nimport { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';\nimport { NativeViewGestureHandler } from 'react-native-gesture-handler';\nimport BottomSheetDraggableView from '../bottomSheetDraggableView';\nimport BottomSheetRefreshControl from '../bottomSheetRefreshControl';\nimport {\n useScrollHandler,\n useScrollableSetter,\n useBottomSheetInternal,\n} from '../../hooks';\nimport {\n GESTURE_SOURCE,\n SCROLLABLE_DECELERATION_RATE_MAPPER,\n SCROLLABLE_STATE,\n SCROLLABLE_TYPE,\n} from '../../constants';\nimport { styles } from './styles';\n\nexport function createBottomSheetScrollableComponent(\n type: SCROLLABLE_TYPE,\n ScrollableComponent: any\n) {\n return forwardRef((props, ref) => {\n // props\n const {\n // hooks\n focusHook,\n scrollEventsHandlersHook,\n // props\n enableFooterMarginAdjustment = false,\n overScrollMode = 'never',\n keyboardDismissMode = 'interactive',\n showsVerticalScrollIndicator = true,\n style,\n refreshing,\n onRefresh,\n progressViewOffset,\n refreshControl,\n ...rest\n }: any = props;\n\n //#region refs\n const nativeGestureRef = useRef(null);\n const refreshControlGestureRef = useRef(null);\n //#endregion\n\n //#region hooks\n const { scrollableRef, scrollableContentOffsetY, scrollHandler } =\n useScrollHandler(scrollEventsHandlersHook);\n const {\n enableContentPanningGesture,\n animatedFooterHeight,\n animatedScrollableState,\n } = useBottomSheetInternal();\n //#endregion\n\n //#region variables\n const scrollableAnimatedProps = useAnimatedProps(\n () => ({\n decelerationRate:\n SCROLLABLE_DECELERATION_RATE_MAPPER[animatedScrollableState.value],\n showsVerticalScrollIndicator: showsVerticalScrollIndicator\n ? animatedScrollableState.value === SCROLLABLE_STATE.UNLOCKED\n : showsVerticalScrollIndicator,\n }),\n [showsVerticalScrollIndicator]\n );\n //#endregion\n\n //#region styles\n const containerAnimatedStyle = useAnimatedStyle(\n () => ({\n marginBottom: enableFooterMarginAdjustment\n ? animatedFooterHeight.value\n : 0,\n }),\n [enableFooterMarginAdjustment]\n );\n const containerStyle = useMemo(() => {\n return enableFooterMarginAdjustment\n ? [\n ...(style ? ('length' in style ? style : [style]) : []),\n containerAnimatedStyle,\n ]\n : style;\n }, [enableFooterMarginAdjustment, style, containerAnimatedStyle]);\n //#endregion\n\n //#region effects\n // @ts-ignore\n useImperativeHandle(ref, () => scrollableRef.current);\n useScrollableSetter(\n scrollableRef,\n type,\n scrollableContentOffsetY,\n onRefresh !== undefined,\n focusHook\n );\n //#endregion\n\n //#region render\n if (Platform.OS === 'android') {\n const scrollableContent = (\n \n \n \n );\n return (\n \n {onRefresh ? (\n \n {scrollableContent}\n \n ) : (\n scrollableContent\n )}\n \n );\n }\n return (\n \n \n \n \n \n );\n //#endregion\n });\n}\n","import {\n useAnimatedRef,\n useAnimatedScrollHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport { useScrollEventsHandlersDefault } from './useScrollEventsHandlersDefault';\nimport { workletNoop as noop } from '../utilities';\nimport type { Scrollable } from '../types';\n\nexport const useScrollHandler = (\n useScrollEventsHandlers = useScrollEventsHandlersDefault\n) => {\n // refs\n const scrollableRef = useAnimatedRef();\n\n // variables\n const scrollableContentOffsetY = useSharedValue(0);\n\n // hooks\n const {\n handleOnScroll = noop,\n handleOnBeginDrag = noop,\n handleOnEndDrag = noop,\n handleOnMomentumEnd = noop,\n handleOnMomentumBegin = noop,\n } = useScrollEventsHandlers(scrollableRef, scrollableContentOffsetY);\n\n // callbacks\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: handleOnScroll,\n onBeginDrag: handleOnBeginDrag,\n onEndDrag: handleOnEndDrag,\n onMomentumBegin: handleOnMomentumBegin,\n onMomentumEnd: handleOnMomentumEnd,\n },\n [\n handleOnScroll,\n handleOnBeginDrag,\n handleOnEndDrag,\n handleOnMomentumBegin,\n handleOnMomentumEnd,\n ]\n );\n\n return { scrollHandler, scrollableRef, scrollableContentOffsetY };\n};\n","import React, { useCallback, useEffect } from 'react';\nimport { findNodeHandle } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useBottomSheetInternal } from './useBottomSheetInternal';\nimport { SCROLLABLE_TYPE } from '../constants';\nimport type { Scrollable } from '../types';\n\nexport const useScrollableSetter = (\n ref: React.RefObject,\n type: SCROLLABLE_TYPE,\n contentOffsetY: Animated.SharedValue,\n refreshable: boolean,\n useFocusHook = useEffect\n) => {\n // hooks\n const {\n animatedScrollableType,\n animatedScrollableContentOffsetY: rootScrollableContentOffsetY,\n isContentHeightFixed,\n isScrollableRefreshable,\n setScrollableRef,\n removeScrollableRef,\n } = useBottomSheetInternal();\n\n // callbacks\n const handleSettingScrollable = useCallback(() => {\n // set current content offset\n rootScrollableContentOffsetY.value = contentOffsetY.value;\n animatedScrollableType.value = type;\n isScrollableRefreshable.value = refreshable;\n isContentHeightFixed.value = false;\n\n // set current scrollable ref\n const id = findNodeHandle(ref.current);\n if (id) {\n setScrollableRef({\n id: id,\n node: ref,\n });\n } else {\n console.warn(`Couldn't find the scrollable node handle id!`);\n }\n\n return () => {\n removeScrollableRef(ref);\n };\n }, [\n ref,\n type,\n refreshable,\n animatedScrollableType,\n rootScrollableContentOffsetY,\n contentOffsetY,\n isScrollableRefreshable,\n isContentHeightFixed,\n setScrollableRef,\n removeScrollableRef,\n ]);\n\n // effects\n useFocusHook(handleSettingScrollable);\n};\n","import { memo } from 'react';\nimport {\n DefaultSectionT,\n SectionList as RNSectionList,\n SectionListProps as RNSectionListProps,\n} from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { SCROLLABLE_TYPE } from '../../constants';\nimport { createBottomSheetScrollableComponent } from './createBottomSheetScrollableComponent';\nimport type {\n BottomSheetSectionListMethods,\n BottomSheetSectionListProps,\n} from './types';\n\nconst AnimatedSectionList =\n Animated.createAnimatedComponent>(RNSectionList);\n\nconst BottomSheetSectionListComponent = createBottomSheetScrollableComponent<\n BottomSheetSectionListMethods,\n BottomSheetSectionListProps