Files
discord-decomp/sources/modules/premium/native/GuildBoostSlotsInventory.tsx
T
2026-07-28 01:06:53 +03:00

520 lines
26 KiB
TypeScript

/* Metro module 12228; source: modules/premium/native/GuildBoostSlotsInventory.tsx; dependencies: [31, 27, 1310, 1867, 7020, 3808, 661, 33, 4501, 697, 6597, 7054, 4573, 1244, 21, 5278, 6522, 1305, 6819, 12229, 566, 1423, 12230, 12234, 4223, 8251, 22, 2] */
import ThemeStore from '../../user_settings/ThemeStore.tsx'; /* Metro dependency 1310 */
import GuildStore from '../../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import SubscriptionStore from '../../../stores/billing/SubscriptionStore.tsx'; /* Metro dependency 3808 */
import TextStyles from '../../rebrand/native/TextStyles.tsx'; /* Metro dependency 6597 */
import GuildBoostSlotStore from '../../../stores/billing/GuildBoostSlotStore.tsx'; /* Metro dependency 7020 */
import UseCountdown from '../../../hooks/useCountdown.tsx'; /* Metro dependency 7054 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as BillingActionCreatorsModule from '../../billing/actions/BillingActionCreators.tsx'; /* Metro dependency 4223 */
import * as TextModule from '../../../design/components/Text/native/Text.tsx'; /* Metro dependency 4573 */
import * as BoostingActionCreatorsModule from '../../../actions/native/BoostingActionCreators.tsx'; /* Metro dependency 6522 */
import * as BoostingActionCreatorsModule2 from '../../../actions/BoostingActionCreators.tsx'; /* Metro dependency 8251 */
function _fun93627(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#93627, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:6, offset: 0x020bcc27, size: 995 bytes, params: 8, frame: 29
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactNativeModule;
const env0_5 = value.View;
const env0_6 = value.Image;
const Fonts = (ConstantsModule).Fonts;
value = require(33) /* metro dependency 33 */;
const env0_11 = value.jsx;
const env0_12 = value.jsxs;
const env0_13 = value.Fragment;
value = require(4501) /* metro dependency 4501: createStyles */;
const createStyles = value.createStyles;
object = {};
object.inventory = {marginBottom: 32};
object.header = {'marginHorizontal': 16, 'marginBottom': 16};
const object3 = {};
object3.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.xs;
object3.marginBottom = 16;
object.boostedGuild = object3;
const BACKGROUND_BASE_LOWEST = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWEST;
object.subscriptionBody = {backgroundColor: BACKGROUND_BASE_LOWEST};
const BACKGROUND_MOD_NORMAL = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_MOD_NORMAL;
object.subscriptionImageView = {'backgroundColor': null, 'width': '100%', 'height': 112, 'overflow': 'hidden',
'alignItems': 'center', 'justifyContent': 'center', backgroundColor: BACKGROUND_MOD_NORMAL};
object.subscriptionImage = {'position': 'absolute', 'width': '100%', 'height': '100%'};
object.subscriptionImageFallback = {opacity: 0.4};
const BLACK = (importDefault(697) /* metro dependency 697: native */).colors.BLACK;
object.subscriptionImageOverlay = {'position': 'absolute', 'width': '100%', 'height': '100%',
'backgroundColor': null, 'opacity': 0.4, backgroundColor: BLACK};
object.guildInfo = {'flexDirection': 'row', 'padding': 16};
object.guildInfoIcon = {marginRight: 8};
const object6 = {};
const DISPLAY_EXTRABOLD = Fonts.DISPLAY_EXTRABOLD;
const INTERACTIVE_TEXT_ACTIVE = (importDefault(697) /* metro dependency 697: native */).colors.INTERACTIVE_TEXT_ACTIVE;
copyDataProperties(object6, TextStyles(DISPLAY_EXTRABOLD, INTERACTIVE_TEXT_ACTIVE, 20), undefined);
object6['marginBottom'] = 4;
object.guildInfoName = object6;
object.guildInfoRowBottom = {'flexDirection': 'row', 'alignItems': 'center'};
object.guildInfoRowIcon = {'height': 12, 'width': 8, 'marginLeft': 2, 'marginRight': 8};
object.guildInfoSubscriptionCount = {lineHeight: 16};
const BACKGROUND_SURFACE_HIGH = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_SURFACE_HIGH;
object.subscriptionSlot = {backgroundColor: BACKGROUND_SURFACE_HIGH, paddingLeft: 16};
object.subscriptionSlotInner = {'alignItems': 'center', 'flexDirection': 'row', 'paddingRight': 16,
'paddingVertical': 12};
const BORDER_SUBTLE = (importDefault(697) /* metro dependency 697: native */).colors.BORDER_SUBTLE;
object.subscriptionSlotBorder = {backgroundColor: BORDER_SUBTLE, height: 1};
object.subscriptionSlotInfo = {'flexShrink': 1, 'flexGrow': 1};
object.subscriptionSlotInfoTitle = {lineHeight: 24};
object.subscriptionSlotInfoCooldown = {lineHeight: 16};
const CONTROL_BRAND_FOREGROUND = (importDefault(697) /* metro dependency 697: native */).colors.CONTROL_BRAND_FOREGROUND;
object.subscriptionSlotInfoTransferText = {'color': null, 'fontSize': 16, 'fontWeight': '500', 'lineHeight': 20,
color: CONTROL_BRAND_FOREGROUND};
object.unusedSlots = {marginBottom: 32};
const TEXT_LINK = (importDefault(697) /* metro dependency 697: native */).colors.TEXT_LINK;
object.subscribeButtonText = {'color': null, 'fontSize': 16, 'fontWeight': '500', 'lineHeight': 20,
color: TEXT_LINK};
const env0_14 = Reflect.apply(createStyles, value, [object]);
(FileImportTrackerModule).fileFinishedImporting('modules/premium/native/GuildBoostSlotsInventory.tsx');
exports.default = GuildBoostSlotsInventory;
function GuildBoostSlotCooldown({cooldownEndsAt}) { // fn#93628, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:1868, offset: 0x020bd00a, size: 280 bytes, params: 2, frame: 22
var r0;
var Text;
var intl;
const styles = useStyles();
const value2 = ReactModule.useMemo(_fun93629, [cooldownEndsAt]);
const {days, hours, minutes} = (UseCountdown)(value2, 15000);
const value4 = value2.valueOf();
const Date = global.Date;
if (value4 <= Date.now()) {
r0 = null;
} else {
Text = (require(4573) /* metro dependency 4573: Text */).Text;
var textProps = {'style': null, 'variant': 'text-xs/medium', 'color': 'text-muted',
style: styles.subscriptionSlotInfoCooldown};
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
r0 = (
<Text {...textProps}>
{intl.format((require(1244) /* metro dependency 1244: indexNative */).t.NffSH8, {days: days,
hours: hours,
minutes: minutes})}
</Text>
);
}
return r0;
function _fun93629() { // fn#93629, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:1943, offset: 0x020bd122, size: 37 bytes, params: 1, frame: 11
const Date = global.Date;
const cooldownEndsAtBinding = cooldownEndsAt;
const value = Object.create(Date.prototype, {constructor: {value: Date}});
const date = new Date(cooldownEndsAtBinding);
return date instanceof Object ? date : value;
}
}
function GuildBoostSlotsInventoryRow({title, subtitle, action, isLast}) { // fn#93630, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:2228, offset: 0x020bd147, size: 262 bytes, params: 2, frame: 29
const styles = useStyles();
const Text = (TextModule).Text;
return (
<View style={styles.subscriptionSlot}>
<View style={styles.subscriptionSlotInner}>
<View style={styles.subscriptionSlotInfo}>
<Text
style={styles.subscriptionSlotInfoTitle}
lineClamp={1}
variant="text-md/semibold"
color="interactive-text-active"
>
{title}
</Text>
{subtitle}
</View>
{action}
</View>
{
isLast
? null
: (
<View style={styles.subscriptionSlotBorder} />
)
}
</View>
);
}
function GuildBoostSlot({guild, guildBoostSlot, isLast}) { // fn#93631, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:2644, offset: 0x020bd24d, size: 469 bytes, params: 2, frame: 27
var r6;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
var formatToPlainString;
var property;
var Date;
var value4;
var date;
const styles = useStyles();
if (guild == null) {
return null;
}
const id = guildBoostSlot.premiumGuildSubscription != null ? guildBoostSlot.premiumGuildSubscription.id : null;
const r17 = id != null ? (importDefault(21) /* metro dependency 21: SnowflakeUtils */).extractTimestamp(id) : null;
if (r17 != null) {
formatToPlainString = intl.formatToPlainString;
property = (require(1244) /* metro dependency 1244: indexNative */).t['ePe+Xh'];
Date = global.Date;
value4 = Object.create(Date.prototype, {constructor: {value: Date}});
date = new Date(r17);
r6 = Reflect.apply(formatToPlainString, intl, [property, {date: date instanceof Object ? date : value4}]);
} else {
r6 = null;
}
return (
<GuildBoostSlotsInventoryRow
title={r6}
subtitle={guildBoostSlot.cooldownEndsAt != null
? (
<GuildBoostSlotCooldown cooldownEndsAt={guildBoostSlot.cooldownEndsAt} />
)
: null}
action={guildBoostSlot.isOnCooldown()
? null
: ((PressableOpacity) => <PressableOpacity accessibilityRole="button" onPress={onPress_93632}>{((LegacyText) => <LegacyText style={styles.subscriptionSlotInfoTransferText}>{intl.string((require(1244) /* metro dependency 1244: indexNative */).t.jqqLb6)}</LegacyText>)((require(1305) /* metro dependency 1305: native */).LegacyText)}</PressableOpacity>)((require(5278) /* metro dependency 5278: Pressables */).PressableOpacity)}
isLast={isLast}
/>
);
function GuildBoostSlotOnPress() { // fn#93632, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:3179, owner: GuildBoostSlot.onPress, offset: 0x020bd422, size: 60 bytes, params: 1, frame: 13
const value = environment.__proto__;
return (BoostingActionCreatorsModule).openTransferModal({guildBoostSlots: [guildBoostSlot]});
}
}
function UnusedGuildBoostSlots({unusedSlots}) { // fn#93633, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:3370, offset: 0x020bd45e, size: 393 bytes, params: 2, frame: 31
var r6;
var object2;
const intl = (IndexNativeModule).intl;
var formatToPlainString;
const t = (IndexNativeModule).t;
var ewI23O;
const styles = useStyles();
let value2 = unusedSlots.filter(function({cooldownEndsAt}) {
var r0;
var value2;
var value = cooldownEndsAt != null;
if (value) {
value2 = new global.Date(cooldownEndsAt);
value2 = value2.valueOf();
cooldownEndsAt = global.Date;
value2 = value2 > cooldownEndsAt.now();
r0 = value2;
} else {
r0 = value;
}
return r0;
});
const value3 = unusedSlots.filter(function({cooldownEndsAt}) {
var r0;
var value2;
var value = cooldownEndsAt == null;
if (value) {
r0 = value;
} else {
value2 = new global.Date(cooldownEndsAt);
value2 = value2.valueOf();
cooldownEndsAt = global.Date;
value2 = value2 <= cooldownEndsAt.now();
r0 = value2;
}
return r0;
});
unusedSlots = styles.unusedSlots;
let length = value3.length;
if (length > 0) {
object2 = {};
formatToPlainString = intl.formatToPlainString;
ewI23O = t.ewI23O;
length = value3.length;
object2.title = Reflect.apply(formatToPlainString, intl, [ewI23O, {numSubscriptions: length}]);
object2.action = ((PressableOpacity) => <PressableOpacity accessibilityRole="button" onPress={onPress_93636}>{((LegacyText) => <LegacyText style={styles.subscribeButtonText}>{intl.string(t['7KyPor'])}</LegacyText>)((require(1305) /* metro dependency 1305: native */).LegacyText)}</PressableOpacity>)((require(5278) /* metro dependency 5278: Pressables */).PressableOpacity);
length = value2.length;
object2.isLast = length === 0;
r6 = <GuildBoostSlotsInventoryRow {...object2} />;
} else {
r6 = null;
}
return (
<View style={unusedSlots}>
{[r6, value2.map(_fun93637)]}
</View>
);
function UnusedGuildBoostSlotsOnPress() { // fn#93636, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:3827, owner: UnusedGuildBoostSlots.onPress, offset: 0x020bd685, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__;
return (BoostingActionCreatorsModule).openApplyBoostModal();
}
function _fun93637(a0, a1) { // fn#93637, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:4012, offset: 0x020bd6aa, size: 177 bytes, params: 3, frame: 22
const value = environment.__proto__;
const intl = (IndexNativeModule).intl;
const formatToPlainString = intl.formatToPlainString;
const gDsyB9 = (IndexNativeModule).t.gDsyB9;
const cooldownEndsAt = a0.cooldownEndsAt;
const value2 = null;
return (
<GuildBoostSlotsInventoryRow
title={Reflect.apply(formatToPlainString, intl, [gDsyB9, {numSubscriptions: 1}])}
subtitle={value2 != cooldownEndsAt
? (
<GuildBoostSlotCooldown cooldownEndsAt={a0.cooldownEndsAt} />
)
: value2}
isLast={a1 === env0_0.length - 1}
key={a0.id}
/>
);
}
}
function BoostedGuildInfo({guild, numGuildBoostSlots}) { // fn#93638, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:4261, offset: 0x020bd75b, size: 474 bytes, params: 2, frame: 33
var r0;
var items4;
const Text = (TextModule).Text;
var items2;
var items3;
var intl;
const styles = useStyles();
if (guild == null) {
r0 = null;
} else {
var viewBindingProps = {style: styles.guildInfo};
items4 = [
<View style={styles.guildInfoIcon}>
{((Component) => <Component guild={guild} size={(require(6819) /* metro dependency 6819: GuildIcon */).GuildIconSizes.NORMAL} selected={false} />)(importDefault(6819) /* metro dependency 6819: GuildIcon */)}
</View>,
];
items2 = [
<Text
style={styles.guildInfoName}
variant="heading-lg/extrabold"
color="interactive-text-active"
>
{guild.name}
</Text>,
];
var viewBinding4Props = {style: styles.guildInfoRowBottom};
items3 = [
<Image source={importDefault(12229) /* metro dependency 12229 */} style={styles.guildInfoRowIcon} />,
];
var textProps = {'style': null, 'variant': 'text-xs/semibold', 'color': 'interactive-text-active',
style: styles.guildInfoSubscriptionCount};
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
items3[1] = (
<Text {...textProps}>
{intl.format((require(1244) /* metro dependency 1244: indexNative */).t.bexfNy,
{numSubscriptions: numGuildBoostSlots})}
</Text>
);
items2[1] = (
<View {...viewBinding4Props}>
{items3}
</View>
);
items4[1] = (
<View>
{items2}
</View>
);
r0 = (
<View {...viewBindingProps}>
{items4}
</View>
);
}
return r0;
}
function BoostedGuild({guildId, guildBoostSlots}) { // fn#93639, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:4909, offset: 0x020bd935, size: 556 bytes, params: 2, frame: 33
const styles = useStyles();
const guild = (require(566) /* metro dependency 566: flux */).useStateFromStores([GuildStore], function() {
return GuildStore.getGuild(guildId);
});
const theme = (require(566) /* metro dependency 566: flux */).useStateFromStores([ThemeStore], function() {
return ThemeStore.theme;
});
const r16 = guild != null && guild.banner != null ? (importDefault(1423) /* metro dependency 1423: AvatarUtils */).getGuildBannerSource(guild) : null;
return (
<View style={styles.boostedGuild}>
<View style={styles.subscriptionBody}>
<View style={styles.subscriptionImageView}>
<Image
source={r16 ?? (require(12230) /* metro dependency 12230: SubscriptionPlaceholderPattern */).useSubscriptionPlaceholderPatternSource()}
style={[styles.subscriptionImage, r16 == null ? styles.subscriptionImageFallback : null]}
/>
{
r16 != null
? (
<View style={styles.subscriptionImageOverlay} />
)
: null
}
{((Component) => <Component guild={guild} theme={theme} />)(importDefault(12234) /* metro dependency 12234: BoostedGuildTierProgressCircle */)}
</View>
<BoostedGuildInfo guild={guild} numGuildBoostSlots={guildBoostSlots.length} />
</View>
<View>
{guildBoostSlots.map(_fun93642)}
</View>
</View>
);
function _fun93642(a0, a1) { // fn#93642, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:5590, offset: 0x020bdb61, size: 76 bytes, params: 3, frame: 16
return (
<GuildBoostSlot
guild={guild}
guildBoostSlot={a0}
isLast={a1 === guildBoostSlots.length - 1}
key={a0.id}
/>
);
}
}
function GuildBoostSlotsInventory() { // fn#93643, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:5772, offset: 0x020bdbad, size: 525 bytes, params: 1, frame: 29
var r6;
var r0;
var value8;
var value9;
var items2;
var jsxRuntimeEnv0_13Binding;
const Text = (TextModule).Text;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
var value;
const styles = useStyles();
ReactModule.useEffect(_fun93644, []);
let useStateFromStores = FluxModule.useStateFromStores;
const premiumTypeSubscription = Reflect.apply(useStateFromStores, FluxModule, [[SubscriptionStore], function() {
return SubscriptionStore.getPremiumTypeSubscription();
}]);
useStateFromStores = FluxModule.useStateFromStores;
const value5 = (importDefault(22) /* metro dependency 22 */)(Reflect.apply(useStateFromStores, FluxModule,
[[GuildBoostSlotStore], function() {
return GuildBoostSlotStore.boostSlots;
}])).groupBy(function({premiumGuildSubscription}) {
return premiumGuildSubscription != null ? premiumGuildSubscription.guildId : '0';
}).value();
const property = value5[0];
const Object = global.Object;
const value7 = Object.keys(value5).filter(function(a0) {
return a0 !== '0';
});
if (value7.length !== 0) {
value9 = null;
if (value9 == premiumTypeSubscription) {
r0 = value9;
} else {
var viewBindingProps = {style: styles.inventory};
items2 = [
value9 != property && property.length > 0
? (
<UnusedGuildBoostSlots unusedSlots={property} />
)
: value9,
];
if (value7.length > 0) {
jsxRuntimeEnv0_13Binding = jsxRuntimeEnv0_13;
value = (
<Text
style={styles.header}
variant="eyebrow"
color="text-default"
>
{intl.string((require(1244) /* metro dependency 1244: indexNative */).t.gB9oQ7)}
</Text>
);
value = (
<>
{[value, value7.map(_fun93649)]}
</>
);
r6 = value;
} else {
r6 = value9;
}
items2[1] = r6;
value = (
<View {...viewBindingProps}>
{items2}
</View>
);
r0 = value;
}
} else {
value8 = null;
if (value8 == property) {
r0 = value8;
} else {
value9 = null;
if (value9 == premiumTypeSubscription) {
r0 = value9;
} else {
var viewBindingProps = {style: styles.inventory};
items2 = [
value9 != property && property.length > 0
? (
<UnusedGuildBoostSlots unusedSlots={property} />
)
: value9,
];
if (value7.length > 0) {
jsxRuntimeEnv0_13Binding = jsxRuntimeEnv0_13;
value = (
<Text
style={styles.header}
variant="eyebrow"
color="text-default"
>
{intl.string((require(1244) /* metro dependency 1244: indexNative */).t.gB9oQ7)}
</Text>
);
value = (
<>
{[value, value7.map(_fun93649)]}
</>
);
r6 = value;
} else {
r6 = value9;
}
items2[1] = r6;
value = (
<View {...viewBindingProps}>
{items2}
</View>
);
r0 = value;
}
}
}
return r0;
function _fun93644() { // fn#93644, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:5831, offset: 0x020bddba, size: 63 bytes, params: 1, frame: 13
const value = environment.__proto__;
(BillingActionCreatorsModule).fetchSubscriptions();
(BoostingActionCreatorsModule2).fetchGuildBoostSlots();
}
function _fun93649(a0) { // fn#93649, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12414:6464, offset: 0x020bde36, size: 47 bytes, params: 2, frame: 15
return (
<BoostedGuild
guildId={a0}
guildBoostSlots={env0_0[a0]}
key={a0}
/>
);
}
}
}
global.__d(_fun93627, 12228, [31, 27, 1310, 1867, 7020, 3808, 661, 33, 4501, 697, 6597, 7054, 4573, 1244, 21, 5278,
6522, 1305, 6819, 12229, 566, 1423, 12230, 12234, 4223, 8251, 22,
2]) /* metro module 12228, dependencies: [31, 27, 1310, 1867, 7020, 3808, 661, 33, 4501, 697, 6597, 7054, 4573, 1244, 21, 5278, 6522, 1305, 6819, 12229, 566, 1423, 12230, 12234, 4223, 8251, 22, 2] */;