// Metro module 4533 (f4534). import _slicedToArray from "../../../../_bundle/_slicedToArray"; import _toArray from "../../../../_bundle/_toArray"; import { useContext, useRef, useEffect, useLayoutEffect, useState, createContext, memo, useCallback, Suspense } from "react"; import { ScrollView, View, StyleSheet } from "react-native"; import { NOOP } from "../../../../_bundle/Module505"; import { jsx } from "react/jsx-runtime"; import { createStyles } from "../../Styles/native/createStyles"; import Module712 from "../../../../_bundle/Module712"; import * as _TransitionGroup from "../../TransitionGroup/TransitionGroup"; import { TransitionGroup } from "../../TransitionGroup/TransitionGroup"; import { useAlertStore, dismissAlert, openAlert } from "./useAlertStore.native"; import * as _ReanimatedRexport from "../../../../modules/reanimated/ReanimatedRexport"; import ReanimatedRexport, { useAnimatedStyle, useSharedValue, useAnimatedReaction } from "../../../../modules/reanimated/ReanimatedRexport"; import { dismissGlobalKeyboard } from "../../../../utils/native/KeyboardManagerUtils"; import OverlayView from "../../../void/OverlayView/native/OverlayView"; import { Dialog } from "../../Dialog/native/Dialog.native"; import { batchUpdates } from "../../../../_bundle/Module705"; import { Backdrop } from "../../Backdrop/native/Backdrop.native"; import * as _index_native from "../../../../intl/index.native"; import { intl } from "../../../../intl/index.native"; import { AccessibilityPreferencesContext } from "../../../../_bundle/Module3908"; import useSafeAreaInsets_native from "../../../../modules/safe_area/useSafeAreaInsets.native"; import { setAccessibilityFocus } from "../../../../modules/a11y/native/setAccessibilityFocus.android"; import useWindowDimensions_native from "../../../../modules/screen/useWindowDimensions.native"; import useBackPressHandler from "../../../../modules/routing/native/useBackPressHandler"; import { Stack } from "../../Stack/native/Stack.native"; import { Text } from "../../Text/native/Text"; import * as _spring from "../../../animation/reanimated/spring/spring"; import { Button } from "../../Button/native/Button.native"; function $mk74745($env) { return () => { const r1 = $env.$parent; return (0, r1[0])(r1[2][10]).useAlertStore.setState({ alerts: $env[0] }); }; } let dismissTopAlert, AlertModalBackdrop, AlertModal, useSharedAnimationState, AlertActions, AlertActionButton, useStyles, c2739_14, c2739_15, c2739_16, c2739_17, c2739_18, c2739_19, c2739_22, c2739_24, withAlertModalSpring, c2739_27, c2739_28; let env2739 = {}; const getAlertModalItemKey = function getAlertModalItemKey(a0) { return a0.key; }; dismissTopAlert = function dismissTopAlert() { let env14309; const r5 = env14309 = { $parent: env2739 }; const r17 = _toArray(useAlertStore.getState().alerts); const r11 = r17[0]; env14309[0] = r17.slice(1); if (!(r11 != null && r11.dismissable === false)) { dismissAlert(r11?.key); batchUpdates($mk74745(r5)); } }; AlertModalBackdrop = function AlertModalBackdrop() { const context = useContext(c2739_16); const [sharedTransitionState, sharedVisible] = useSharedAnimationState(); let c14310_1 = sharedTransitionState; let c14310_2 = sharedVisible; const alertStore = useAlertStore((a0) => a0.alerts[0]?.dismissable !== false); const r26 = function t() { return { opacity: _spring.withSpring(c14310_2.get(), c2739_14, "animate-always", (a0) => { if (a0 === true && c14310_2.get() === 0 && c14310_1.get() === _TransitionGroup.TransitionStates.YEETED) { _ReanimatedRexport.runOnJS(context)(); } }) }; }; r26.__closure = { withAlertModalSpring, sharedVisible, sharedTransitionState, TransitionStates: _TransitionGroup.TransitionStates, runOnJS: _ReanimatedRexport.runOnJS, cleanUp: context }; r26.__workletHash = 4470729133936; r26.__initData = c2739_22; return ; }; AlertModal = function AlertModal(props) { let height; const { header, title, content, actions, extraContent } = props; height = void 0; const context2 = useContext(c2739_16); const context3 = useContext(c2739_17); const styles = useStyles(); const context4 = useContext(c2739_19); const enabled = useContext(AccessibilityPreferencesContext).reducedMotion.enabled; const ref = useRef(null); const sharedValue = useSharedValue(context3); const [sharedTransitionState, sharedVisible] = useSharedAnimationState(); let c14311_6 = sharedTransitionState; let c14311_7 = sharedVisible; const safeAreaInsets_native = useSafeAreaInsets_native(); const { top, bottom } = safeAreaInsets_native; useEffect(() => { if (context3 === 0) { setAccessibilityFocus({ ref, delay: 300 }); } }, [context3]); height = useWindowDimensions_native().height; const B = function B() { let r75, transform; const r0 = height - 32; const r26 = 2 * Math.max(top, bottom); const r16 = c14311_7.get(); const r17 = function(a0) { if (a0 === true && c14311_7.get() === 0 && c14311_6.get() === _TransitionGroup.TransitionStates.YEETED) { _ReanimatedRexport.runOnJS(context2)(); } }; const r36 = { position: "absolute", opacity: _spring.withSpring(r16, c2739_14, "animate-always", r17), zIndex: 10 - sharedValue.get(), height: null, maxHeight: null, transform: null }; const height2 = sharedValue.get() > 0 ? context4.get() : "auto"; const maxHeight = r0 - r26; r36.height = height2; r36.maxHeight = maxHeight; if (enabled) { transform = []; } else { transform = [{ scale: _spring.withSpring(c14311_7.get() === 1 ? 1 - 0.1 * sharedValue.get() : 0.7, c2739_14, "animate-always", void 0) }, ,]; if (c14311_7.get() === 1) { let r79 = [0, -20, -34][sharedValue.get()]; if (r79 == null) { r79 = -12 * c14311_7.get(); } r75 = r79; } else { r75 = 50 - 50 * sharedValue.get(); } transform[1] = { translateY: _spring.withSpring(r75, c2739_14, "animate-always", void 0) }; } r36.transform = transform; return r36; }; B.__closure = { sharedVisible, sharedTransitionState, TransitionStates: _TransitionGroup.TransitionStates, runOnJS: _ReanimatedRexport.runOnJS, cleanUp: context2, windowHeight: height, ALERT_MODAL_MARGIN: 16, safeAreaTop: top, safeAreaBottom: bottom, withAlertModalSpring, sharedIndex: sharedValue, sharedTopHeight: context4, useReducedMotion: enabled }; B.__workletHash = 655123755546; B.__initData = c2739_24; const animatedStyle = useAnimatedStyle(B); useLayoutEffect(() => { sharedValue.set(context3); }, [context3, sharedValue]); useBackPressHandler(() => { let env25243; const r5 = env25243 = { $parent: env2739 }; const r17 = _toArray(useAlertStore.getState().alerts); const r11 = r17[0]; env25243[0] = r17.slice(1); if (!(r11 != null && r11.dismissable === false)) { dismissAlert(r11?.key); batchUpdates($mk74745(r5)); } return true; }); return { context4.set(event.nativeEvent.layout.height); }}> {header} {title} {content != null ? content !== "" ? {content} : null : null} {extraContent} {actions != null ? {actions} : null} ; }; useSharedAnimationState = function useSharedAnimationState() { const context5 = useContext(c2739_15); const context6 = useContext(c2739_16); const sharedValue2 = useSharedValue(context5 === _TransitionGroup.TransitionStates.MOUNTED ? 1 : 0); const sharedValue3 = useSharedValue(context5); useLayoutEffect(() => { sharedValue3.set(context5); }, [sharedValue2, context5, sharedValue3]); const n = () => sharedValue3.get(); n.__closure = { sharedTransitionState: sharedValue3 }; n.__workletHash = 14603144870585; n.__initData = c2739_27; const r38 = function t(a0) { if (a0 === _TransitionGroup.TransitionStates.YEETED) { if (sharedValue2.get() === 1) { sharedValue2.set(0); } else { _ReanimatedRexport.runOnJS(context6)(); } } else { sharedValue2.set(1); } }; r38.__closure = { TransitionStates: _TransitionGroup.TransitionStates, sharedVisible: sharedValue2, runOnJS: _ReanimatedRexport.runOnJS, cleanUp: context6 }; r38.__workletHash = 9486923983340; r38.__initData = c2739_28; useAnimatedReaction(n, r38); return [sharedValue3, sharedValue2]; }; AlertActions = function AlertActions(a0) { return (0, jsx)(Stack, { spacing: 12, children: a0.children }); }; AlertActionButton = function AlertActionButton(props) { let env14313 = { $parent: env2739 }; env14313[0] = props.onPress; const { onPress, loading: _loading, ...props2 } = props; let loading = props.loading; env14313[1] = void 0; env14313[2] = void 0; const r18 = _slicedToArray(useState(false), 2); const r10 = r18[0]; env14313[1] = r18[1]; env14313[2] = useContext(c2739_18); if (loading == null) { loading = r10; } let c14314_0 = async (c29409_0) => { let c29409_3 = 0; L16: { L15: { try { const r27 = env14313[0]; const r28 = r27 == null ? void 0 : r27(c29409_0); if (r28 != null && r28 instanceof Promise) { (0, env14313[1])(true); c29409_3 = 1; await r28; c29409_3 = 0; dismissAlert(env14313[2]); break L15; } dismissAlert(env14313[2]); break L16; } catch ($e) { let r26 = $e; if (c29409_3 !== 0) { while (true) { try { c29409_3 = 0; (0, env14313[1])(false); } catch ($e) { r26 = $e; if (c29409_3 === 0) { break; } continue; } return void 0; } } throw r26; } } return void 0; } }; return