// Metro module 12325 (f12326). import { useState, useCallback, useEffect } from "react"; import { NOOP } from "../../../Constants"; import getMediaViewerStateForScreen from "./getMediaViewerStateForScreen"; import useStableCallback from "../../../hooks/useStableCallback"; import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport"; import { useAnimatedReaction } from "../../reanimated/ReanimatedRexport"; const __initData = { code: "function useMediaViewerClosePositionTsx1(){const{index}=this.__closure;return index.get();}" }; const __initData2 = { code: "function useMediaViewerClosePositionTsx2(index){const{runOnJS,setClosePosition}=this.__closure;runOnJS(setClosePosition)(index);}" }; export default function useMediaViewerClosePosition({ index, sources, onClose = NOOP, windowHeight, windowWidth }) { let setState, callback; setState = void 0; callback = void 0; const stableCallback = useStableCallback(onClose); let c19799_4 = stableCallback; let state; [state, setState] = useState(() => { const r10 = sources[index.get()]; return (windowHeight + (r10 != null ? getMediaViewerStateForScreen(windowWidth, windowHeight, r10) : { height: windowHeight }).height) / 2; }); callback = useCallback((a0) => { const r8 = sources[a0]; if (r8 == null) { c19799_4(); } setState((windowHeight + (r8 != null ? getMediaViewerStateForScreen(windowWidth, windowHeight, r8) : { height: windowHeight }).height) / 2); }, [stableCallback, sources, windowHeight, windowWidth]); const h = () => index.get(); h.__closure = { index }; h.__workletHash = 5031282724746; h.__initData = __initData; const f = function f(a0) { _ReanimatedRexport.runOnJS(callback)(a0); }; f.__closure = { runOnJS: _ReanimatedRexport.runOnJS, setClosePosition: callback }; f.__workletHash = 2709880768438; f.__initData = __initData2; useAnimatedReaction(h, f); useEffect(() => { callback(index.get()); }, [callback, index]); return state; };