// Metro module 15896 (f15897). import * as Module19 from "react"; import { useMemo, useCallback } from "react"; import { View } from "react-native"; import UserStore from "../../../stores/UserStore"; import * as _SoundboardStyleConstants from "./SoundboardStyleConstants"; import { SOUNDS_PER_ROW } from "./SoundboardStyleConstants"; import { createStyles } from "../../../design/components/Styles/native/createStyles"; import Module712 from "../../../_bundle/Module712"; import { SoundboardSoundGridSectionType, SoundboardSoundItemType } from "../SoundboardTypes"; import { intl, t } from "../../../intl/index.native"; import chunk from "../../../_bundle/chunk"; import { useStateFromStores } from "../../../_bundle/Module589"; import PremiumUtils from "../../../utils/PremiumUtils"; import * as _PremiumFeatureUpsellUtils from "../../premium/roadblocks/native/utils/PremiumFeatureUpsellUtils"; import { PremiumUpsellGradientBackground } from "../../premium/roadblocks/native/views/PremiumUpsellGradientBackground"; import { SoundButton } from "./SoundButton"; import { useFontScale } from "../../screen/native/useFontScale"; import { debounce } from "../../../_bundle/Module12"; import GuildIcon, { GuildIconSizes } from "../../guild/native/GuildIcon"; import { Icon } from "../../../design/void/native"; import Module15903 from "../../../_bundle/Module15903"; import Module9624 from "../../../_bundle/Module9624"; import { ClockIcon } from "../../../design/components/Icon/native/redesign/generated/ClockIcon"; import PremiumUpsellSectionDivider, { PremiumUpsellSectionDividerPosition, PREMIUM_UPSELL_SECTION_DIVIDER_HEIGHT, PREMIUM_UPSELL_SECTION_DIVIDER_MARGIN } from "../../premium/roadblocks/native/views/PremiumUpsellSectionDivider"; import FastList from "../../../lib/native/FastList"; import { Text } from "../../../design/components/Text/native/Text"; let c11382_9, useStyles, SoundPickerButtonRow; const getSectionLabel = function getSectionLabel(a0) { const type = a0.category.categoryInfo.type; if (SoundboardSoundGridSectionType.GUILD === type) { return a0.category.categoryInfo.guild.name; } if (SoundboardSoundGridSectionType.DEFAULTS === type) { return intl.string(t.Rtvk9X); } if (SoundboardSoundGridSectionType.FAVORITES === type) { return intl.string(t.y3LQCG); } if (SoundboardSoundGridSectionType.FREQUENTLY_USED === type) { return intl.string(t["+cGVV6"]); } if (SoundboardSoundGridSectionType.SEARCH === type) { return null; } }; SoundPickerButtonRow = function SoundPickerButtonRow(props) { let isSoundboardSectionNitroLocked; const { row, section, channel } = props; isSoundboardSectionNitroLocked = void 0; const styles = useStyles(); const stateFromStores2 = useStateFromStores([UserStore], () => PremiumUtils.canUseSoundboardEverywhere(UserStore.getCurrentUser())); if (section == null) { return null; } let r19 = stateFromStores2 ? !stateFromStores2 : _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel.guild_id, section.category.categoryInfo); isSoundboardSectionNitroLocked = r19; if (isSoundboardSectionNitroLocked) { r19 = ; } return {r19} {section.soundsByRow[row].map((item, index) => { const type = item.type; if (SoundboardSoundItemType.SOUND === type) { const sound = item.sound; return 0 ? styles.soundButtonNotFirst : null} isSectionLocked={isSoundboardSectionNitroLocked} />; } if (SoundboardSoundItemType.ADD_SOUND === type) { throw new Error("ADD_SOUND Not implemented"); } })} ; }; const { SOUND_BUTTON_HEIGHT, SOUND_ROW_HORIZONTAL_PADDING, SOUND_ROW_SPACING } = _SoundboardStyleConstants; c11382_9 = SOUND_BUTTON_HEIGHT + 8; useStyles = createStyles({ row: { height: c11382_9, display: "flex", flexDirection: "row", paddingHorizontal: SOUND_ROW_HORIZONTAL_PADDING }, sectionHeader: { flex: 1, display: "flex", flexDirection: "row", alignItems: "center", paddingTop: 16, paddingBottom: 8, backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND, paddingHorizontal: SOUND_ROW_HORIZONTAL_PADDING }, sectionIcon: { height: 16, width: 16, borderRadius: 8, marginRight: 4 }, soundButtonNotFirst: { marginLeft: SOUND_ROW_SPACING } }); const r49 = Module19.memo(function SoundboardSoundPickerListComponent(props) { let styles2, fastListSectionsFromCategories, memo, c22579_8, c22579_9, stateFromStores; const { channel: channel2, insetBottom = 0, listRef, scrollPosition, onScroll: onScroll2, setCategoryIndex, shouldShowPremiumUpsell, categories } = props; styles2 = void 0; fastListSectionsFromCategories = void 0; memo = void 0; c22579_8 = void 0; c22579_9 = void 0; stateFromStores = void 0; const getSectionPosition2 = function getSectionPosition(a0) { const r0 = a0 - 1; const r3 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r0].category.categoryInfo); const r23 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[a0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[a0].category.categoryInfo); const r39 = a0 + 1; const r40 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r39] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r39].category.categoryInfo); return !r23 && (r40 && !r3) ? PremiumUpsellSectionDividerPosition.START : r23 ? r40 ? null : PremiumUpsellSectionDividerPosition.END : null; }; styles2 = useStyles(); const fontScale = useFontScale(); const sections = (function calculateRowsPerSection(a0, a1) { const r0 = []; for (const item of a0) { r0.push(Math.ceil(item.items.length / a1)); } return r0; })(categories, SOUNDS_PER_ROW); fastListSectionsFromCategories = (function getFastListSectionsFromCategories(a0, a1, a2) { const r0 = []; for (const item of a0) { const soundsByRow = chunk(item.items, a1); r0.push({ category: item, height: soundsByRow.length * c11382_9 + (18 * a2 + 8), soundsByRow }); } return r0; })(categories, SOUNDS_PER_ROW, fontScale); memo = useMemo(() => fastListSectionsFromCategories.map((fastListSectionsFromCategory) => fastListSectionsFromCategory.height), [fastListSectionsFromCategories]); const callback = useCallback((a0, a1) => , [fastListSectionsFromCategories, channel2]); c22579_8 = debounce((a0) => { const r14 = Math.round(a0); const r6 = 0 < memo.length; let r4 = 0; if (r6) { let r18 = 0 + memo[0]; const r19 = r14 >= r18; let r1 = 0; let r0 = 0; r4 = 0; if (r19) { do { const r20 = r0 + 1; const r3 = r1 + 1; const length = memo.length; const r11 = r18; r4 = r20; if (!(r3 < length)) { break; } r18 = r11 + memo[r3]; r1 = r3; r0 = r20; r4 = r0; } while (r14 >= r18); } } setCategoryIndex(r4); }); c22579_9 = debounce((a0, a1) => { const r16 = -a1 / 2; const r18 = Math.round(a0); const r6 = 0 < memo.length; let r4 = 0; if (r6) { let r22 = r16 + memo[0]; const r23 = r18 >= r22; let r1 = 0; let r24 = 0; r4 = 0; if (r23) { do { const r26 = r24 + 1; const r3 = r1 + 1; const length = memo.length; const r14 = r22; r4 = r26; if (!(r3 < length)) { break; } r22 = r14 + memo[r3]; r1 = r3; r24 = r26; r4 = r24; } while (r18 >= r22); } } const r38 = Math.min(r4, memo.length - 1); shouldShowPremiumUpsell.set((stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r38] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r38].category.categoryInfo)); }); stateFromStores = useStateFromStores([UserStore], () => PremiumUtils.canUseSoundboardEverywhere(UserStore.getCurrentUser())); return c22579_9(0, event.nativeEvent.layout.height)} sections={sections} sectionSize={function sectionSize(a0) { const r6 = fastListSectionsFromCategories[a0]; return r6 != null ? getSectionLabel(r6) == null ? 0 : 42 : 0; }} itemSize={function itemSize(a0) { return fastListSectionsFromCategories[a0] == null ? 0 : c11382_9; }} sectionFooterSize={function sectionFooterSize(a0) { return getSectionPosition2(a0) == null ? 0 : PREMIUM_UPSELL_SECTION_DIVIDER_HEIGHT + PREMIUM_UPSELL_SECTION_DIVIDER_MARGIN; }} ref={listRef} renderItem={callback} renderSection={function renderSection(a0) { const r3 = fastListSectionsFromCategories[a0]; const r39 = [(stateFromStores ? !stateFromStores : fastListSectionsFromCategories[a0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[a0].category.categoryInfo) && , , ,]; const type = r3.category.categoryInfo.type; r39[1] = SoundboardSoundGridSectionType.GUILD === type ? : SoundboardSoundGridSectionType.DEFAULTS === type ? : SoundboardSoundGridSectionType.FAVORITES === type ? : SoundboardSoundGridSectionType.FREQUENTLY_USED === type ? : SoundboardSoundGridSectionType.SEARCH === type ? null : void 0; r39[2] = {getSectionLabel(r3)} ; return {r39} ; }} renderSectionFooter={function renderSectionFooter(a0) { const sectionPosition2 = getSectionPosition2(a0); return sectionPosition2 != null ? : null; }} insetEnd={insetBottom} onScroll={function onScroll(event) { const nativeEvent = event.nativeEvent; const r7 = nativeEvent.contentOffset.y; c22579_8(r7); c22579_9(r7, nativeEvent.layoutMeasurement.height); if (!(nativeEvent.layoutMeasurement.height + nativeEvent.contentOffset.y >= nativeEvent.contentSize.height - 20)) { if (scrollPosition != null) { scrollPosition.set(r7); } if (onScroll2 != null) { onScroll2(event); } } }} keyboardShouldPersistTaps="handled" optimizeListItemRender inActionSheet />; }); export { r49 as SoundboardSoundPickerList };