// Metro module 15897 (f15898). import { memo, useCallback, useEffect } from "react"; import { View } from "react-native"; import UserStore from "../../../stores/UserStore"; import { SOUND_BUTTON_HEIGHT } from "./SoundboardStyleConstants"; import { jsx } from "react/jsx-runtime"; import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport"; import ReanimatedRexport, { useAnimatedStyle, useSharedValue } from "../../reanimated/ReanimatedRexport"; import { createStyles } from "../../../design/components/Styles/native/createStyles"; import Module712 from "../../../_bundle/Module712"; import { isIOS } from "../../../utils/PlatformUtils"; import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables"; import * as _spring from "../../../design/animation/reanimated/spring/spring"; import Emoji from "../../emojis/native/Emoji"; import getSoundboardEmojiUrl from "./utils/getSoundboardEmojiUrl"; import { useSoundButtonStyleConfig } from "./SoundboardHooks"; import { useStateFromStores } from "../../../_bundle/Module589"; import useSoundboardSoundPlayer_native from "../useSoundboardSoundPlayer.native"; import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations"; import AnalyticsLocation from "../../app_analytics/AnalyticsLocation"; import * as _SoundboardUtils from "../SoundboardUtils"; import PremiumUtils from "../../../utils/PremiumUtils"; import openPremiumUpsellActionSheet from "../../premium/roadblocks/native/utils/openPremiumUpsellActionSheet"; import { EntitlementFeatureNames } from "../../../_bundle/Module6201"; import ToastActionCreators from "../../toast/native/ToastActionCreators"; import Module10861 from "../../../_bundle/Module10861"; import * as _index_native from "../../../intl/index.native"; import { intl } from "../../../intl/index.native"; import openSoundboardSoundPreviewActionSheet from "./utils/openSoundboardSoundPreviewActionSheet"; import { Text } from "../../../design/components/Text/native/Text"; import { LockIcon } from "../../../design/components/Icon/native/redesign/generated/LockIcon"; function $mk98093($env) { return function t() { const r19 = $env[0]; const r10 = r19.sharedValues.pressed.get(); const r2 = r19.sharedValues.playing.get() > 0; const r12 = $env.$parent; const r7 = r12[0]; const r25 = r12[2]; const r11 = r7(r25[5]); let playingAnimationDelay = r19.playingAnimationDelay; if (playingAnimationDelay == null) { playingAnimationDelay = 0; } const r14 = r7(r25[10]); const r35 = r7(r25[5]).interpolate(r19.sharedValues.playing.get(), [0, 1], [1, r19.scaleFactors.playing]); const r36 = r12[9]; const r38 = r11.withDelay(playingAnimationDelay, r14.withSpring(r35, r36)); const r54 = r7(r25[10]).withSpring(r7(r25[5]).interpolate(r19.sharedValues.pressed.get(), [0, 1], [1, r19.scaleFactors.pressed]), r36); const transform = [{ scale: r10 === 0 ? r2 ? r38 : r54 : r54 }, ,]; const r59 = r7(r25[5]); const r64 = r19.sharedValues.pressed.get(); let pressedRotationDegrees = r19.pressedRotationDegrees; if (pressedRotationDegrees == null) { pressedRotationDegrees = 0; } transform[1] = { rotate: `${r59.interpolate(r64, [0, 1], [0, pressedRotationDegrees])}deg` }; return { transform }; }; } let Component, c11383_9, useStyles, Component2, c11383_12; let env11383 = {}; const SoundButtonEmoji = function SoundButtonEmoji(props) { let env22580; let env22581; const { sound: sound2, sharedValues } = props; const styles = useStyles(); const animationConfig = { sharedValues, scaleFactors: { pressed: 0.8, playing: 1.2 } }; const r18 = env22580 = { $parent: env11383 }; env22580[0] = animationConfig; const r20 = $mk98093(r18); const SPRING_CONFIG = c11383_9; r20.__closure = { animationConfig, withDelay: _ReanimatedRexport.withDelay, withSpring: _spring.withSpring, interpolate: _ReanimatedRexport.interpolate, SPRING_CONFIG }; r20.__workletHash = 13932429225740; const __initData = c11383_12; r20.__initData = __initData; const animatedStyle = useAnimatedStyle(r20); const animationConfig2 = { sharedValues, scaleFactors: { pressed: 0.7200000000000001, playing: 1.08 }, playingAnimationDelay: 100, pressedRotationDegrees: -15 }; const r33 = env22581 = { $parent: env11383 }; env22581[0] = animationConfig2; const r37 = $mk98093(r33); r37.__closure = { animationConfig: animationConfig2, withDelay: _ReanimatedRexport.withDelay, withSpring: _spring.withSpring, interpolate: _ReanimatedRexport.interpolate, SPRING_CONFIG }; r37.__workletHash = 13932429225740; r37.__initData = __initData; const animatedStyle2 = useAnimatedStyle(r37); const props2 = { fastImageStyle: styles.emoji, textEmojiStyle: styles.emoji, src: getSoundboardEmojiUrl(sound2, 24), name: null }; let emojiName = sound2.emojiName; if (emojiName == null) { emojiName = ""; } props2.name = emojiName; return ; }; Component = ReanimatedRexport.createAnimatedComponent(View); c11383_9 = { damping: 10, stiffness: 300, mass: 1 }; useStyles = createStyles({ button: { marginTop: 4, height: SOUND_BUTTON_HEIGHT, backgroundColor: Module712.colors.CARD_BACKGROUND_DEFAULT, display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", borderRadius: Module712.radii.lg, borderWidth: 1, borderColor: Module712.colors.BORDER_MUTED, ...Module712.shadows.SHADOW_LOW }, buttonPressed: { backgroundColor: Module712.colors.CARD_PRIMARY_PRESSED_BG }, buttonDisabled: { opacity: 0.5 }, buttonPlaying: { borderStyle: "solid", borderWidth: 2, borderColor: Module712.colors.STATUS_SPEAKING, backgroundColor: Module712.colors.CARD_SECONDARY_BG }, emoji: { height: 24, width: 24, fontSize: isIOS() ? 24 : void 0, lineHeight: 28 }, emojiWrapper: { display: "flex", alignItems: "center", justifyContent: "center", height: 40, width: 40, backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED, backgroundSize: 32, borderRadius: Module712.radii.round, marginBottom: 8 }, text: { marginHorizontal: 8 }, textPlaying: { marginHorizontal: 6 }, lock: { position: "absolute", top: Module712.space.PX_12, end: Module712.space.PX_12, width: 12, height: 12, tintColor: Module712.colors.WHITE } }); Component2 = ReanimatedRexport.createAnimatedComponent(PressableOpacity); c11383_12 = { code: "function SoundButtonTsx1(){const{animationConfig,withDelay,withSpring,interpolate,SPRING_CONFIG}=this.__closure;var _animationConfig$play,_animationConfig$pres,_animationConfig;const isNotPressed=animationConfig.sharedValues.pressed.get()===0;const isPlaying=animationConfig.sharedValues.playing.get()>0;const shouldDoPlayingAnimation=isNotPressed&&isPlaying;const playingAnimationScaleValue=withDelay((_animationConfig$play=animationConfig.playingAnimationDelay)!==null&&_animationConfig$play!==void 0?_animationConfig$play:0,withSpring(interpolate(animationConfig.sharedValues.playing.get(),[0,1],[1,animationConfig.scaleFactors.playing]),SPRING_CONFIG));const pressedAnimationScaleValue=withSpring(interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[1,animationConfig.scaleFactors.pressed]),SPRING_CONFIG);const rotationScaleValue=interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[0,(_animationConfig$pres=(_animationConfig=animationConfig)===null||_animationConfig===void 0?void 0:_animationConfig.pressedRotationDegrees)!==null&&_animationConfig$pres!==void 0?_animationConfig$pres:0]);return{transform:[{scale:shouldDoPlayingAnimation?playingAnimationScaleValue:pressedAnimationScaleValue},{rotate:rotationScaleValue+\"deg\"}]};}" }; const r114 = memo(function SoundButtonComponent(props) { let playSoundboardSound, analyticsLocations, c22582_5; const { sound, channel, style, isSectionLocked = false } = props; playSoundboardSound = void 0; analyticsLocations = void 0; c22582_5 = void 0; const buttonWidth = useSoundButtonStyleConfig().buttonWidth; let r17 = sound.emojiId != null || sound.emojiName != null; let isPlayingSound, sharedValue, sharedValue2; let env22584; const styles = useStyles(); const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser()); const soundboardSoundPlayer_native = useSoundboardSoundPlayer_native(sound, channel.id); playSoundboardSound = soundboardSoundPlayer_native.playSoundboardSound; const isPlayingSound2 = soundboardSoundPlayer_native.isPlayingSound; analyticsLocations = useAnalyticsLocations(AnalyticsLocation.SOUNDBOARD_BUTTON).analyticsLocations; const canUseSoundboardSound = _SoundboardUtils.canUseSoundboardSound(stateFromStores, sound, channel); let r55 = !canUseSoundboardSound; c22582_5 = r55; const callback = useCallback(() => { L7: { if (c22582_5) { if (!PremiumUtils.canUseSoundboardEverywhere(stateFromStores) && sound.guildId !== channel.guild_id) { openPremiumUpsellActionSheet(EntitlementFeatureNames.SOUNDBOARD_EVERYWHERE); break L7; } if (!sound.available) { ToastActionCreators.open({ key: "DISABLED_SOUND_PRESSED", icon: Module10861, content: intl.string(_index_native.t.MDOXJR), toastDurationMs: 3000 }); } } else { playSoundboardSound(analyticsLocations); } } }, [analyticsLocations, channel.guild_id, stateFromStores, playSoundboardSound, sound, r55]); isPlayingSound = isPlayingSound2; sharedValue = void 0; sharedValue2 = void 0; sharedValue = useSharedValue(0); sharedValue2 = useSharedValue(0); const callback2 = useCallback(() => { sharedValue.set(1); }, [sharedValue]); const callback3 = useCallback(() => { sharedValue.set(0); }, [sharedValue]); useEffect(() => { sharedValue2.set(isPlayingSound ? 1 : 0); }, [isPlayingSound, sharedValue2, sharedValue]); const sharedValues = { pressed: sharedValue, playing: sharedValue2 }; const animationConfig = { sharedValues, scaleFactors: { pressed: 0.95, playing: 1.05 } }; const r80 = env22584 = { $parent: env11383 }; env22584[0] = animationConfig; const r84 = $mk98093(r80); r84.__closure = { animationConfig, withDelay: _ReanimatedRexport.withDelay, withSpring: _spring.withSpring, interpolate: _ReanimatedRexport.interpolate, SPRING_CONFIG: c11383_9 }; r84.__workletHash = 13932429225740; r84.__initData = c11383_12; const animatedStyle = useAnimatedStyle(r84); const r3 = sharedValues.pressed.get() > 0; const callback4 = useCallback(() => { openSoundboardSoundPreviewActionSheet(channel.id, sound); }, [channel.id, sound]); const style2 = [styles.button, { width: buttonWidth }, r3 ? styles.buttonPressed : null, animatedStyle, isPlayingSound ? styles.buttonPlaying : null, canUseSoundboardSound ? null : isSectionLocked ? null : styles.buttonDisabled, style]; if (r17) { r17 = (0, jsx)(SoundButtonEmoji, { sharedValues, sound }); } const r132 = [ {r17} {sound.name} , ,]; if (!canUseSoundboardSound) { r55 = !isSectionLocked; } if (r55) { r55 = ; } r132[1] = r55; return {r132}; }); export { r114 as SoundButton };