// Metro module 10276 (f10277). import { useMemo, useState, useCallback, useRef, useEffect } from "react"; import { Keyboard, StyleSheet, View } from "react-native"; import NativeMenuStore from "../../native_menu/native/NativeMenuStore"; import ReadStateStore from "../../../stores/ReadStateStore"; import { DEFAULT_ANIMATION_TIMING, EXPANDABLE_MIN_WINDOW_HEIGHT, MIN_SWIPE_DISTANCE, MIN_SWIPE_VELOCITY, NOTIFICATION_BOB_RANGE, PAN_INPUT_RANGE, extrapolateConfig, NOTIFICATION_CONTAINER_MARGIN } from "./InAppNotificationConstants"; import { AnalyticEvents, AnalyticsObjectTypes, AnalyticsObjects, AnalyticsSections, InAppNotificationTypes } from "../../../Constants"; import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport"; import ReanimatedRexport, { Easing, useSharedValue, cancelAnimation, useAnimatedStyle } from "../../reanimated/ReanimatedRexport"; import { createStyles } from "../../../design/components/Styles/native/createStyles"; import { useCanExpandInAppNotification } from "./InAppNotificationExpandExperiment"; import { canReactToMessage } from "../../reactions/canReactToMessage"; import { canReplyToMessage } from "../../replies/canReplyToMessage"; import MessageNotification from "./MessageNotification"; import MessageFailedToSendNotification from "./MessageFailedToSendNotification"; import ForumThreadCreatedNotification from "./ForumThreadCreatedNotification"; import { BugReporterNotification } from "../../bug_reporter/native/BugReporterNotification"; import AlertNotification from "./AlertNotification"; import ReactionNotification from "./ReactionNotification"; import ReminderNotification from "./ReminderNotification"; import RestrictedHoursWarningNotification from "./RestrictedHoursWarningNotification"; import MessageRequestNotification from "./MessageRequestNotification"; import { MessageNotificationDetachedContent } from "./MessageNotificationDetachedContent"; import { extractMetadataFromNotification, trackDismissed } from "./InAppNotificationUtils"; import useStateFromSharedValue from "../../reanimated/native/useStateFromSharedValue"; import { useStateFromStores } from "../../../_bundle/Module589"; import { UNSAFE_markDismissibleContentAsDismissed } from "../../dismissible_content/DismissibleContentUnsafeUtils"; import { DismissibleContent } from "../../../_bundle/Module1358"; import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators"; import AppAnalyticsUtils from "../../app_analytics/AppAnalyticsUtils"; import useBackPressHandler from "../../routing/native/useBackPressHandler"; import useWindowDimensions_native from "../../screen/useWindowDimensions.native"; import SnowflakeUtils from "../../../utils/SnowflakeUtils"; import { ack } from "../../../actions/ReadStateActionCreators"; import * as _timing from "../../../design/animation/reanimated/timing/timing"; import useMountEffect, { useUnmountEffect } from "../../../hooks/useMountEffect"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; import { Gesture, GestureDetector } from "../../../_bundle/Module5273"; import * as _spring from "../../../design/animation/reanimated/spring/spring"; import { OverlayView } from "../../../design/void/native"; import { Backdrop } from "../../../design/components/Backdrop/native/Backdrop.native"; import * as _index_native from "../../../intl/index.native"; import { intl } from "../../../intl/index.native"; import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView"; import { InAppNotificationContext } from "./InAppNotificationContext"; let c6860_24, useStyles, DetachedNotificationContent, __initData, __initData2, __initData3, __initData4, __initData5, __initData6, __initData7, __initData8, __initData9; const NotificationWrapper = function NotificationWrapper(props) { const notification2 = props.notification; const type = notification2.type; if (InAppNotificationTypes.MESSAGE === type) { return ; } if (InAppNotificationTypes.MESSAGE_FAILED_TO_SEND === type) { return ; } if (InAppNotificationTypes.FORUM_THREAD_CREATED === type) { return ; } if (InAppNotificationTypes.BUG_REPORTER === type) { return ; } if (InAppNotificationTypes.ALERT === type) { return ; } if (InAppNotificationTypes.REACTION === type) { return ; } if (InAppNotificationTypes.MESSAGE_REMINDER === type) { return ; } if (InAppNotificationTypes.RESTRICTED_HOURS_WARNING !== type && InAppNotificationTypes.RESTRICTED_SCHEDULE_UPDATED !== type) { if (InAppNotificationTypes.MESSAGE_REQUEST === type) { return ; } return null; } return ; }; DetachedNotificationContent = function DetachedNotificationContent(props) { const notification2 = props.notification; return notification2.type === InAppNotificationTypes.MESSAGE ? : null; }; c6860_24 = { duration: 200, easing: Easing.in(Easing.ease) }; useStyles = createStyles({ safeAreaContainer: { position: "absolute", left: 0, right: 0, backgroundColor: "transparent", marginTop: 8, top: 0, bottom: 0 }, backdrop: { position: "absolute", zIndex: 0 }, animatedContainer: { marginLeft: NOTIFICATION_CONTAINER_MARGIN, marginRight: NOTIFICATION_CONTAINER_MARGIN } }); __initData = { code: "function InAppNotificationContainerTsx1(finished){const{runOnJS,handleDismissNotification}=this.__closure;if(finished){runOnJS(handleDismissNotification)('autodismissed');}}" }; __initData2 = { code: "function InAppNotificationContainerTsx2(){const{runOnJS,setInitialized}=this.__closure;return runOnJS(setInitialized)(true);}" }; __initData3 = { code: "function InAppNotificationContainerTsx3(){const{withTiming,expandedSV,DEFAULT_ANIMATION_TIMING}=this.__closure;return{opacity:withTiming(expandedSV.get()?1:0,DEFAULT_ANIMATION_TIMING)};}" }; __initData4 = { code: "function InAppNotificationContainerTsx4(){const{runOnJS,setPanning}=this.__closure;runOnJS(setPanning)(false);}" }; __initData5 = { code: "function InAppNotificationContainerTsx5(event){const{velocityY,MIN_SWIPE_VELOCITY,MIN_SWIPE_DISTANCE,isExpandableNotification,notificationGestureY,expandedSV,runOnJS,setExpanded,withTiming,PAN_INPUT_RANGE,DEFAULT_ANIMATION_TIMING,handleDismissNotification,setPanning,withSpring}=this.__closure;const shouldDismiss=Math.abs(velocityY.get())>=MIN_SWIPE_VELOCITY||Math.abs(event.translationY)>=MIN_SWIPE_DISTANCE;if(isExpandableNotification&&event.translationY>MIN_SWIPE_DISTANCE){notificationGestureY.set(0);expandedSV.set(true);runOnJS(setExpanded)(true,'swipe');}else if(shouldDismiss&&event.translationY<=0){notificationGestureY.set(withTiming(event.translationY>0?PAN_INPUT_RANGE[2]:PAN_INPUT_RANGE[0],DEFAULT_ANIMATION_TIMING,'animate-always',function(finished){if(finished){runOnJS(handleDismissNotification)('swipe');}}));}else{runOnJS(setPanning)(false);notificationGestureY.set(withSpring(0,{damping:10,mass:1,stiffness:100,velocity:velocityY.get()},'animate-always'));}}" }; __initData6 = { code: "function InAppNotificationContainerTsx6(event){const{startY,isExpandableNotification,notificationGestureY,velocityY}=this.__closure;const rawY=startY.get()+event.translationY;const newY=isExpandableNotification&&rawY>0?rawY:Math.min(rawY,startY.get());notificationGestureY.set(newY);velocityY.set(event.velocityY);}" }; __initData7 = { code: "function InAppNotificationContainerTsx7(){const{startY,notificationGestureY,velocityY,runOnJS,setPanning}=this.__closure;startY.set(notificationGestureY.get());velocityY.set(0);runOnJS(setPanning)(true);}" }; __initData8 = { code: "function InAppNotificationContainerTsx8(finished){const{runOnJS,handleDismissNotification}=this.__closure;if(finished){runOnJS(handleDismissNotification)('swipe');}}" }; __initData9 = { code: "function InAppNotificationContainerTsx9(){const{notificationGestureY,scale,isExpandableNotification,interpolate,MIN_SWIPE_DISTANCE,PAN_INPUT_RANGE,NOTIFICATION_BOB_RANGE,extrapolateConfig,initialized}=this.__closure;const gestureY=notificationGestureY.get();const scaleValue=scale.get();if(isExpandableNotification&&gestureY>0){return{transform:[{translateY:interpolate(gestureY,[0,MIN_SWIPE_DISTANCE,PAN_INPUT_RANGE[2]],[0,0,NOTIFICATION_BOB_RANGE],extrapolateConfig)},{scale:initialized?1:scaleValue}],opacity:initialized?1:scaleValue};}const scaleTransform=initialized?interpolate(gestureY,PAN_INPUT_RANGE,[0.3,1,0.3],extrapolateConfig):scaleValue;const opacityTransform=initialized?interpolate(gestureY,PAN_INPUT_RANGE,[0,1,0],extrapolateConfig):scaleValue;return{transform:[{translateY:gestureY},{scale:scaleTransform}],opacity:opacityTransform};}" }; export default function InAppNotificationContainer(props) { let r122; let guildId, channelId, messageId, channelType, sharedValue, sharedValue2, sharedValue3, sharedValue4, state, setState, state2, setState2, state3, setState3, sharedValue5, isExpanded, state4, setState4, state5, setState5, callback, callback2, showReactionBar, showReplyInput, isExpandableNotification, callback3, ref; const notification = props.notification; guildId = void 0; channelId = void 0; messageId = void 0; channelType = void 0; sharedValue = void 0; sharedValue2 = void 0; sharedValue3 = void 0; sharedValue4 = void 0; state = void 0; setState = void 0; state2 = void 0; setState2 = void 0; state3 = void 0; setState3 = void 0; sharedValue5 = void 0; isExpanded = void 0; state4 = void 0; setState4 = void 0; state5 = void 0; setState5 = void 0; callback = void 0; callback2 = void 0; showReactionBar = void 0; showReplyInput = void 0; isExpandableNotification = void 0; callback3 = void 0; ref = void 0; const styles = useStyles(); const memo = useMemo(() => extractMetadataFromNotification(notification), [notification]); guildId = memo.guildId; channelId = memo.channelId; messageId = memo.messageId; channelType = memo.channelType; sharedValue = useSharedValue(0); sharedValue2 = useSharedValue(0); sharedValue3 = useSharedValue(0); sharedValue4 = useSharedValue(0); [state, setState] = useState(null); [state2, setState2] = useState(false); [state3, setState3] = useState(false); sharedValue5 = useSharedValue(false); isExpanded = useStateFromSharedValue(sharedValue5); [state4, setState4] = useState(false); [state5, setState5] = useState(false); const stateFromStores = useStateFromStores([NativeMenuStore], () => NativeMenuStore.isOpen()); callback = useCallback(() => { UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.IN_APP_NOTIFICATION_EXPAND_NUX); }, []); callback2 = useCallback((a0, a1) => { sharedValue5.set(a0); if (a0) { let expand_source = a1; ActionSheetActionCreators.hideAllActionSheets(); callback(); const IN_APP_NOTIFICATION_EXPANDED = AnalyticEvents.IN_APP_NOTIFICATION_EXPANDED; if (a1 == null) { expand_source = "unknown"; } AppAnalyticsUtils.trackWithMetadata(IN_APP_NOTIFICATION_EXPANDED, { type: notification.type, notif_guild_id: guildId, notif_channel_id: channelId, in_app_notification_id: notification.inAppNotificationId, message_id: messageId, expand_source }); } ActionSheetActionCreators.setActionSheetZIndex(a0 ? 1 : void 0); }, [sharedValue5, notification, guildId, channelId, messageId, callback]); useBackPressHandler(useCallback(() => { let r5 = !!isExpanded; if (r5) { callback2(false); r5 = true; } return r5; }, [isExpanded, callback2]), isExpanded); const windowDimensions_native = useWindowDimensions_native({ ignoreKeyboard: true }); const { width, height } = windowDimensions_native; const canExpandInAppNotification = useCanExpandInAppNotification("InAppNotificationContainer"); let canExpand = canExpandInAppNotification.canExpand; const canReact = canExpandInAppNotification.canReact; if (notification.type !== InAppNotificationTypes.MESSAGE) { r122 = { showReactionBar: false, showReplyInput: false, isExpandableNotification: false }; } else { const { message, channel } = notification; if (canExpand) { canExpand = height > EXPANDABLE_MIN_WINDOW_HEIGHT; } const canReactToMessage2 = canReactToMessage(message, channel); const canReplyToMessage2 = canReplyToMessage(channel, message); let showReactionBar2 = (canExpand ? canReact : canExpand) && canReactToMessage2; if (canExpand) { canExpand = canReplyToMessage2; } r122 = { showReactionBar: showReactionBar2, showReplyInput: canExpand, isExpandableNotification: null }; if (!showReactionBar2) { showReactionBar2 = canExpand; } r122.isExpandableNotification = showReactionBar2; } showReactionBar = r122.showReactionBar; showReplyInput = r122.showReplyInput; isExpandableNotification = r122.isExpandableNotification; callback3 = useCallback((a0) => { if (a0 != null) { trackDismissed({ type: notification.type, guildId, channelId, dismissReason: a0, inAppNotificationId: notification.inAppNotificationId, messageId }); } if (state4 && notification.type === InAppNotificationTypes.MESSAGE) { const r11 = ReadStateStore.ackMessageId(notification.channel.id); if ((r11 == null || SnowflakeUtils.compare(r11, notification.message.id) < 0) && notification.mentionCount >= ReadStateStore.getMentionCount(notification.channel.id)) { ack(notification.channel.id, { section: AnalyticsSections.IN_APP_NOTIFICATION, object: AnalyticsObjects.ACK_IN_APP_NOTIFICATION_ACTION, objectType: AnalyticsObjectTypes.ACK_SEMI_AUTOMATIC }, true, true, notification.message.id); } } const onDismiss2 = notification.onDismiss; if (onDismiss2 != null) { onDismiss2.call(notification); } }, [state4, notification, guildId, channelId, messageId]); ref = useRef(null); useEffect(() => { let r3 = state3; if (state3) { r3 = ref.current == null; } if (r3) { ref.current = setTimeout(() => { const r7 = PAN_INPUT_RANGE[0]; const r20 = function t(a0) { if (a0) { _ReanimatedRexport.runOnJS(callback3)("autodismissed"); } }; r20.__closure = { runOnJS: _ReanimatedRexport.runOnJS, handleDismissNotification: callback3 }; r20.__workletHash = 1150739008183; r20.__initData = __initData; sharedValue.set(_timing.withTiming(r7, DEFAULT_ANIMATION_TIMING, "respect-motion-settings", r20)); }, 2000); } }, [state3, sharedValue, callback3]); useUnmountEffect(() => { ActionSheetActionCreators.setActionSheetZIndex(void 0); if (ref.current != null) { clearTimeout(ref.current); cancelAnimation(sharedValue); } }); useMountEffect(() => { const r18 = () => _ReanimatedRexport.runOnJS(setState2)(true); r18.__closure = { runOnJS: _ReanimatedRexport.runOnJS, setInitialized: setState2 }; r18.__workletHash = 11548697745556; r18.__initData = __initData2; sharedValue4.set(_timing.withTiming(1, c6860_24, "respect-motion-settings", r18)); return () => cancelAnimation(sharedValue4); }); useEffect(() => { if (state2) { AnalyticsUtils.track(AnalyticEvents.IN_APP_NOTIFICATION_SHOWN, { type: notification.type, guild_id: guildId, channel_id: channelId, in_app_notification_id: notification.inAppNotificationId, message_id: messageId, channel_type: channelType }); } }, [state2, notification.type, guildId, channelId, notification.inAppNotificationId, messageId, channelType]); const xt = () => ({ opacity: _timing.withTiming(sharedValue5.get() ? 1 : 0, DEFAULT_ANIMATION_TIMING) }); xt.__closure = { withTiming: _timing.withTiming, expandedSV: sharedValue5, DEFAULT_ANIMATION_TIMING }; xt.__workletHash = 2841593511002; xt.__initData = __initData3; const animatedStyle = useAnimatedStyle(xt); const r170 = Gesture.Pan().enabled(isExpanded ? !isExpanded : !state3); const Rt = function Rt() { sharedValue3.set(sharedValue.get()); sharedValue2.set(0); _ReanimatedRexport.runOnJS(setState5)(true); }; Rt.__closure = { startY: sharedValue3, notificationGestureY: sharedValue, velocityY: sharedValue2, runOnJS: _ReanimatedRexport.runOnJS, setPanning: setState5 }; Rt.__workletHash = 11316955045022; Rt.__initData = __initData7; const r179 = r170.onBegin(Rt); const Gt = function Gt(a0) { let r6; const r8 = sharedValue3.get() + a0.translationY; if (isExpandableNotification) { r6 = r8; if (!(r6 > 0)) { r6 = Math.min(r8, sharedValue3.get()); } } else { r6 = Math.min(r8, sharedValue3.get()); } sharedValue.set(r6); sharedValue2.set(a0.velocityY); }; Gt.__closure = { startY: sharedValue3, isExpandableNotification, notificationGestureY: sharedValue, velocityY: sharedValue2 }; Gt.__workletHash = 16677375054247; Gt.__initData = __initData6; const r185 = r179.onUpdate(Gt); const vt = function vt(a0) { const r2 = Math.abs(sharedValue2.get()) >= MIN_SWIPE_VELOCITY || Math.abs(a0.translationY) >= MIN_SWIPE_DISTANCE; if (isExpandableNotification && a0.translationY > MIN_SWIPE_DISTANCE) { sharedValue.set(0); sharedValue5.set(true); _ReanimatedRexport.runOnJS(callback2)(true, "swipe"); } else if (r2 && a0.translationY <= 0) { const r59 = a0.translationY > 0 ? PAN_INPUT_RANGE[2] : PAN_INPUT_RANGE[0]; const n = function n(a0) { if (a0) { _ReanimatedRexport.runOnJS(callback3)("swipe"); } }; n.__closure = { runOnJS: _ReanimatedRexport.runOnJS, handleDismissNotification: callback3 }; n.__workletHash = 1684596854482; n.__initData = __initData8; sharedValue.set(_timing.withTiming(r59, DEFAULT_ANIMATION_TIMING, "animate-always", n)); } else { _ReanimatedRexport.runOnJS(setState5)(false); sharedValue.set(_spring.withSpring(0, { damping: 10, mass: 1, stiffness: 100, velocity: sharedValue2.get() }, "animate-always")); } }; vt.__closure = { velocityY: sharedValue2, MIN_SWIPE_VELOCITY, MIN_SWIPE_DISTANCE, isExpandableNotification, notificationGestureY: sharedValue, expandedSV: sharedValue5, runOnJS: _ReanimatedRexport.runOnJS, setExpanded: callback2, withTiming: _timing.withTiming, PAN_INPUT_RANGE, DEFAULT_ANIMATION_TIMING, handleDismissNotification: callback3, setPanning: setState5, withSpring: _spring.withSpring }; vt.__workletHash = 5165226193044; vt.__initData = __initData5; const r203 = r185.onEnd(vt); const Mt = function Mt() { _ReanimatedRexport.runOnJS(setState5)(false); }; Mt.__closure = { runOnJS: _ReanimatedRexport.runOnJS, setPanning: setState5 }; Mt.__workletHash = 2178187669683; Mt.__initData = __initData4; const gesture = r203.onFinalize(Mt); const bt = function bt() { let r26; const translateY = sharedValue.get(); const r5 = sharedValue4.get(); if (isExpandableNotification && translateY > 0) { const transform = [{ translateY: _ReanimatedRexport.interpolate(translateY, [0, MIN_SWIPE_DISTANCE, PAN_INPUT_RANGE[2]], [0, 0, NOTIFICATION_BOB_RANGE], extrapolateConfig) }, ,]; let opacity = 1; transform[1] = { scale: state2 ? 1 : r5 }; if (!state2) { opacity = r5; } r26 = { transform, opacity }; } else { r26 = { transform: [{ translateY }, { scale: state2 ? _ReanimatedRexport.interpolate(translateY, PAN_INPUT_RANGE, [0.3, 1, 0.3], extrapolateConfig) : r5 }], opacity: state2 ? _ReanimatedRexport.interpolate(translateY, PAN_INPUT_RANGE, [0, 1, 0], extrapolateConfig) : r5 }; } return r26; }; bt.__closure = { notificationGestureY: sharedValue, scale: sharedValue4, isExpandableNotification, interpolate: _ReanimatedRexport.interpolate, MIN_SWIPE_DISTANCE, PAN_INPUT_RANGE, NOTIFICATION_BOB_RANGE, extrapolateConfig, initialized: state2 }; bt.__workletHash = 14122965198084; bt.__initData = __initData9; const animatedStyle2 = useAnimatedStyle(bt); const memo2 = useMemo(() => ({ notificationGestureY: sharedValue, velocityY: sharedValue2, containerScale: sharedValue4, initialized: state2, autoDismissing: state3, setAutoDismissing: setState3, setActionTaken: setState4, isExpanded, expandedSV: sharedValue5, setExpanded: callback2, handleDismissNotification: callback3, panning: state5, isExpandableNotification, showReactionBar, showReplyInput, confirmation: state, setConfirmation: setState }), [state3, sharedValue5, callback3, state2, isExpanded, sharedValue, sharedValue4, callback2, sharedValue2, state5, isExpandableNotification, showReactionBar, showReplyInput, state, setState]); return { Keyboard.dismiss(); callback2(false); }} accessibilityLabel={intl.string(_index_native.t["9sewOj"])} /> ; };