Files
discord-decomp/sources/components_native/premium/EntitlementGiftGroupCard.tsx
T
2026-07-27 16:20:00 +03:00

420 lines
21 KiB
TypeScript

/* Metro module 12287; source: components_native/premium/EntitlementGiftGroupCard.tsx; dependencies: [6, 7, 15, 17, 18, 31, 27, 4234, 1226, 8450, 3807, 4279, 661, 1880, 33, 4501, 697, 8451, 4573, 1244, 4578, 6829, 8467, 1305, 6780, 8708, 6818, 12288, 12289, 10519, 10521, 10522, 10520, 10523, 10524, 10525, 10526, 10527, 10530, 10533, 10534, 12290, 3868, 566, 8457, 2] */
function _fun93864(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#93864, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:6, offset: 0x020c76a7, size: 1064 bytes, params: 8, frame: 33
var object4;
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(6) /* metro dependency 6 */;
const env0_4 = importDefault(7) /* metro dependency 7 */;
const env0_5 = importDefault(15) /* metro dependency 15 */;
const env0_6 = importDefault(17) /* metro dependency 17 */;
const env0_7 = importDefault(18) /* metro dependency 18 */;
let value = importAll(31) /* metro dependency 31 */;
const value2 = require(27) /* metro dependency 27 */;
const env0_9 = value2.View;
const env0_10 = value2.ActivityIndicator;
const env0_11 = value2.TouchableWithoutFeedback;
const applicationStore = importDefault(4234) /* metro dependency 4234: ApplicationStore */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const giftCodeStore = importDefault(8450) /* metro dependency 8450: GiftCodeStore */;
const subscriptionPlanStore = importDefault(3807) /* metro dependency 3807: SubscriptionPlanStore */;
const skuStore = importDefault(4279) /* metro dependency 4279: SKUStore */;
const Fonts = (require(661) /* metro dependency 661: Constants */).Fonts;
const premiumConstantsModule = require(1880) /* metro dependency 1880: PremiumConstants */;
const env0_16 = premiumConstantsModule.SubscriptionIntervalTypes;
const env0_17 = premiumConstantsModule.PremiumSubscriptionSKUs;
const env0_18 = premiumConstantsModule.PremiumGiftStyles;
const value9 = require(33) /* metro dependency 33 */;
const env0_19 = value9.jsx;
const env0_20 = value9.jsxs;
const createStylesModule = require(4501) /* metro dependency 4501: createStyles */;
const createLegacyClassComponentStyles = createStylesModule.createLegacyClassComponentStyles;
object4 = {giftGroupCard: {'overflow': 'hidden', 'marginTop': 8}};
const object5 = {borderWidth: 1};
const CARD_BORDER_DEFAULT = (importDefault(697) /* metro dependency 697: native */).colors.CARD_BORDER_DEFAULT;
object5.borderColor = CARD_BORDER_DEFAULT;
object5.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.md;
const TABLEROW_BACKGROUND_DEFAULT = (importDefault(697) /* metro dependency 697: native */).colors.TABLEROW_BACKGROUND_DEFAULT;
object5.backgroundColor = TABLEROW_BACKGROUND_DEFAULT;
object4.giftGroupCardRefresh = object5;
const object7 = {'fontSize': 16, 'lineHeight': 20};
const PRIMARY_SEMIBOLD = Fonts.PRIMARY_SEMIBOLD;
object7.fontFamily = PRIMARY_SEMIBOLD;
const MOBILE_TEXT_HEADING_PRIMARY = (importDefault(697) /* metro dependency 697: native */).colors.MOBILE_TEXT_HEADING_PRIMARY;
object7.color = MOBILE_TEXT_HEADING_PRIMARY;
object4.title = object7;
const ICON_SUBTLE = (importDefault(697) /* metro dependency 697: native */).colors.ICON_SUBTLE;
object4.arrow = {color: ICON_SUBTLE};
object4.subtitle = {'fontSize': 14, 'lineHeight': 18};
object4.titleContainer = {'marginLeft': 8, 'flex': 1};
object4.groupCardHeader = {'flexDirection': 'row', 'alignItems': 'center', 'justifyContent': 'space-between',
'padding': 16};
let BACKGROUND_SURFACE_HIGH = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_SURFACE_HIGH;
object4.groupCardHeaderLegacy = {backgroundColor: BACKGROUND_SURFACE_HIGH};
object4.rowArrow = {'height': 8, 'width': 12, 'marginRight': 8};
const object8 = {};
object8.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.xs;
object4.giftIcon = object8;
object4.generateGiftRow = {'padding': 8, 'flexDirection': 'row', 'alignItems': 'center',
'justifyContent': 'space-between'};
BACKGROUND_SURFACE_HIGH = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_SURFACE_HIGH;
object4.generateGiftRowLegacy = {backgroundColor: BACKGROUND_SURFACE_HIGH};
object4.generateGiftRowText = {flexShrink: 1};
object4.generateGiftButton = {marginLeft: 12};
object4.loading = {marginTop: 8};
object4.generateButtonContainer = {'flexGrow': 1, 'flexShrink': 0};
const BACKGROUND_BASE_LOWEST = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWEST;
object4.groupCardHeaderOpen = {backgroundColor: BACKGROUND_BASE_LOWEST};
const BACKGROUND_MOD_MUTED = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_MOD_MUTED;
object4.groupCardHeaderOpenRefresh = {backgroundColor: BACKGROUND_MOD_MUTED};
object4.subtitleContainer = {'flexDirection': 'row', 'alignItems': 'center', 'gap': 4};
object4.socialLayerSubtitleContainer = {marginTop: 2};
const env0_21 = Reflect.apply(createLegacyClassComponentStyles, createStylesModule, [object4]);
const Component = value.Component;
value = _fun93868(Component);
const ThemeContext = (require(3868) /* metro dependency 3868: native */).ThemeContext;
value.contextType = ThemeContext;
const flux = importDefault(566) /* metro dependency 566: flux */;
value = flux.connectStores([authenticationStore, skuStore, applicationStore, giftCodeStore, subscriptionPlanStore],
_fun93879)(value);
(require(2) /* metro dependency 2 */).fileFinishedImporting('components_native/premium/EntitlementGiftGroupCard.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_93865() { // fn#93865, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:416, offset: 0x020c7acf, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_93865_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun93868(a0) { // fn#93868, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:1968, offset: 0x020c7b31, size: 203 bytes, params: 2, frame: 16
const closure = EntitlementGiftGroupCard;
env0_7(closure, a0);
return env0_4(closure, [{key: 'componentDidMount', value: function() {
var Date = global.Date;
this._mountedAt = Date.now();
}}, {key: 'renderGenerateGiftCodeRow', value: value_93873}, {key: 'renderHeader', value: value_93874},
{key: 'getCardHeaderThumbnail', value: value_93875}, {key: 'renderCardHeader', value: value_93876},
{key: 'render', value: value_93877}]);
}
function _fun93879({skuId, subscriptionPlanId, giftStyle}) { // fn#93879, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:6222, offset: 0x020c87cb, size: 282 bytes, params: 2, frame: 19
const value2 = SKUStore.get(skuId);
if (value2 == null) {
throw new global.Error('SKU was unavailable while rendering gift.');
}
const object2 = {sku: value2};
object2.isFetching = GiftCodeStore.getUserGiftCodesFetchingForSKUAndPlan(skuId, subscriptionPlanId);
object2.loadedAt = GiftCodeStore.getUserGiftCodesLoadedAtForSKUAndPlan(skuId, subscriptionPlanId);
object2.application = ApplicationStore.getApplication(value2.applicationId);
object2.subscriptionPlan = subscriptionPlanId != null ? (require(8457) /* metro dependency 8457: SubscriptionUtils */).getOrFetchSubscriptionPlan(subscriptionPlanId) : null;
const getForGifterSKUAndPlan = GiftCodeStore.getForGifterSKUAndPlan;
const getId = AuthenticationStore.getId;
let value = Reflect.apply(getForGifterSKUAndPlan, GiftCodeStore, [Reflect.apply(getId, AuthenticationStore, []),
skuId, subscriptionPlanId]);
value = value.filter(function(a0) {
return !a0.isClaimed;
});
object2.giftCodes = value.filter(function({giftStyle}) {
return giftStyle === giftStyle;
});
return object2;
}
function EntitlementGiftGroupCard(a0) { // fn#93869, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:1980, offset: 0x020c7bfc, size: 181 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_3;
binding(this, EntitlementGiftGroupCard);
const items = [];
arraySpread(items, value, 0, items);
value = env1_6(EntitlementGiftGroupCard);
binding = env1_5;
if (_isNativeReflectConstruct_93865()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items);
r0 = value;
}
value = binding(this, r0);
value._mountedAt = null;
value.state = {isOpen: false};
value.handleToggleOpen = handleToggleOpen;
value.handleGenerateGiftCode = handleGenerateGiftCode;
return value;
}
function value_93873() { // fn#93873, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:2774, offset: 0x020c7d9e, size: 349 bytes, params: 1, frame: 26
const value2 = env1_21(this.context);
const isRefreshEnabled = this.props.isRefreshEnabled;
const items2 = [value2.generateGiftRow];
items2[1] = isRefreshEnabled ? null : value2.generateGiftRowLegacy;
const Text = (require(4573) /* metro dependency 4573: Text */).Text;
const generateGiftRowText = value2.generateGiftRowText;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const text = <Text variant="text-xs/medium" color="text-subtle" style={generateGiftRowText}>{intl.string((require(1244) /* metro dependency 1244: indexNative */).t.lELyPj)}</Text>;
const generateButtonContainer = value2.generateButtonContainer;
const generateGiftButton = value2.generateGiftButton;
const Button = (require(4578) /* metro dependency 4578: ButtonNative */).Button;
return (
<View style={items2}>
{text}
<View style={generateButtonContainer}>
<View style={generateGiftButton}>
<Button
text={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['w4+/BA'])}
size="sm"
onPress={this.handleGenerateGiftCode}
/>
</View>
</View>
</View>
);
}
function value_93874(a0, a1) { // fn#93874, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:3294, offset: 0x020c7efb, size: 1044 bytes, params: 3, frame: 39
var r10;
var r8;
const Icon = require(dependencyMap[23]).Icon;
var defaultImport;
var object;
var moduleValue2;
const value = environment.__proto__;
const value2 = env1_21(this.context);
const state = this.state;
const props = this.props;
const isOpen = state.isOpen;
const entitlements = props.entitlements;
const application = props.application;
const sku = props.sku;
const isRefreshEnabled = props.isRefreshEnabled;
let r21 = require(dependencyMap[21]).isGameItemSKU(sku) && application != null;
const r12 = isRefreshEnabled ? value2.groupCardHeaderOpenRefresh : value2.groupCardHeaderOpen;
const handleToggleOpen = this.handleToggleOpen;
const items3 = [value2.groupCardHeader];
const value4 = null;
items3[1] = isRefreshEnabled ? value4 : value2.groupCardHeaderLegacy;
items3[2] = isOpen ? r12 : value4;
if (r21) {
defaultImport = importDefault(dependencyMap[22]);
object = {sku: sku};
moduleValue2 = require(dependencyMap[23]);
object.size = moduleValue2.getIconSize(require(dependencyMap[23]).Icon.Sizes.LARGE);
object.containerStyle = value2.giftIcon;
r10 = ((Component) => <Component {...object} />)(defaultImport);
} else {
r10 = value4 != a0 ? <Icon resizeMode="contain" source={a0} disableColor size={require(dependencyMap[23]).Icon.Sizes.LARGE} style={value2.giftIcon} /> : value4;
}
const items2 = [r10];
const titleContainer = value2.titleContainer;
const Text = require(dependencyMap[18]).Text;
const text = <Text variant="heading-sm/semibold" color="mobile-text-heading-primary" accessibilityRole="header">{a1}</Text>;
const items4 = [r21 && value2.socialLayerSubtitleContainer];
items4[1] = value2.subtitleContainer;
const r18 = r21 && ((Component) => <Component game={application} size={importDefault(dependencyMap[24]).Sizes.SIZE_24} skuId={sku.id} />)(importDefault(dependencyMap[24]));
const subtitle = value2.subtitle;
const intl = require(dependencyMap[19]).intl;
const format = intl.format;
const t = require(dependencyMap[19]).t;
r21 = r21 ? Reflect.apply(format, intl, [t['6plpZi'], {applicationName: application.name,
copies: entitlements.length}]) : Reflect.apply(format, intl, [t.zMcvcA, {copies: entitlements.length}]);
items2[1] = <View style={titleContainer}>{text}<View style={items4}>{r18}<Text variant="text-md/normal" color="text-subtle" style={subtitle}>{r21}</Text></View></View>;
if (isRefreshEnabled) {
r8 = ((Component) => <Component />)(isOpen ? require(dependencyMap[25]).ChevronSmallDownIcon : require(dependencyMap[26]).ChevronSmallRightIcon);
} else {
r8 = <Icon style={value2.rowArrow} size={require(dependencyMap[23]).Icon.Sizes.LARGE} source={importDefault(isOpen ? dependencyMap[27] : dependencyMap[28])} color={value2.arrow.color} />;
}
items2[2] = r8;
return (
<TouchableWithoutFeedback accessibilityRole="button" onPress={handleToggleOpen}>
<View style={items3}>
{items2}
</View>
</TouchableWithoutFeedback>
);
}
function value_93875(a0, a1) { // fn#93875, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:4673, offset: 0x020c830f, size: 516 bytes, params: 3, frame: 13
var object2;
const STANDARD_BOX = PremiumGiftStyles.STANDARD_BOX;
if (STANDARD_BOX === a1) {
return importDefault(10519) /* metro dependency 10519 */;
}
const CAKE = PremiumGiftStyles.CAKE;
if (CAKE === a1) {
return importDefault(10521) /* metro dependency 10521 */;
}
const CHEST = PremiumGiftStyles.CHEST;
if (CHEST === a1) {
return importDefault(10522) /* metro dependency 10522 */;
}
const COFFEE = PremiumGiftStyles.COFFEE;
if (COFFEE === a1) {
return importDefault(10520) /* metro dependency 10520 */;
}
const SEASONAL_STANDARD_BOX = PremiumGiftStyles.SEASONAL_STANDARD_BOX;
if (SEASONAL_STANDARD_BOX === a1) {
return importDefault(10523) /* metro dependency 10523 */;
}
const SEASONAL_CAKE = PremiumGiftStyles.SEASONAL_CAKE;
if (SEASONAL_CAKE === a1) {
return importDefault(10524) /* metro dependency 10524 */;
}
const SEASONAL_CHEST = PremiumGiftStyles.SEASONAL_CHEST;
if (SEASONAL_CHEST === a1) {
return importDefault(10525) /* metro dependency 10525 */;
}
const SEASONAL_COFFEE = PremiumGiftStyles.SEASONAL_COFFEE;
if (SEASONAL_COFFEE === a1) {
return importDefault(10526) /* metro dependency 10526 */;
}
const NITROWEEN_STANDARD = PremiumGiftStyles.NITROWEEN_STANDARD;
if (NITROWEEN_STANDARD === a1) {
object2 = {};
object2.uri = importDefault(10527) /* metro dependency 10527: halloweenCardSmallPng */;
return object2;
}
const TIER_0 = PremiumSubscriptionSKUs.TIER_0;
if (TIER_0 === a0) {
return importDefault(10530) /* metro dependency 10530 */;
}
const TIER_1 = PremiumSubscriptionSKUs.TIER_1;
if (TIER_1 === a0) {
return importDefault(10533) /* metro dependency 10533 */;
}
const TIER_2 = PremiumSubscriptionSKUs.TIER_2;
if (TIER_2 === a0) {
return importDefault(10534) /* metro dependency 10534 */;
}
const LEGACY = PremiumSubscriptionSKUs.LEGACY;
if (LEGACY === a0) {
return importDefault(10534) /* metro dependency 10534 */;
}
return null;
}
function value_93876(a0) { // fn#93876, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:5202, offset: 0x020c8513, size: 305 bytes, params: 2, frame: 21
var r2;
var renderHeader;
var iconSource;
var intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
const {application, subscriptionPlan, giftStyle} = this.props;
const id = a0.id;
const name = a0.name;
let value = this.getCardHeaderThumbnail(id, giftStyle);
const Object = global.Object;
const value4 = Object.values(PremiumSubscriptionSKUs).includes(id);
const value5 = null;
if (value4) {
if (value5 == subscriptionPlan) {
return value5;
}
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
return this.renderHeader(value,
intl.formatToPlainString(subscriptionPlan.interval === SubscriptionIntervalTypes.MONTH ? t.rCJvqo : t.Vd3Iu8,
{skuName: a0.name, intervalCount: subscriptionPlan.intervalCount}));
}
if (value5 == application) {
r2 = value5;
} else {
renderHeader = this.renderHeader;
iconSource = application.getIconSource(32);
value = Reflect.apply(renderHeader, this, [value5 == iconSource ? value : iconSource, name]);
r2 = value;
}
return r2;
}
function value_93877() { // fn#93877, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:5663, offset: 0x020c8644, size: 303 bytes, params: 1, frame: 29
var environment;
var r9;
var r5;
var Fragment;
var items3;
const value = environment.__proto__;
const value2 = env1_21(this.context);
const {entitlements, giftCodes, sku, isFetching, isRefreshEnabled} = this.props;
const isOpen = this.state.isOpen;
const items2 = [value2.giftGroupCard];
const value3 = null;
items2[1] = isRefreshEnabled ? value2.giftGroupCardRefresh : value3;
const value4 = this.renderCardHeader(sku);
if (isOpen) {
if (isFetching) {
r9 = <ActivityIndicator style={value2.loading} />;
} else {
Fragment = env1_8.Fragment;
items3 = [giftCodes.length < entitlements.length ? this.renderGenerateGiftCodeRow() : value3];
items3[1] = giftCodes.map(_fun93878);
r9 = <Fragment>{items3}</Fragment>;
}
r5 = <View>{r9}</View>;
} else {
r5 = value3;
}
return (
<View style={items2}>
{value4}
{r5}
</View>
);
}
function handleToggleOpen() { // fn#93870, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:2295, owner: EntitlementGiftGroupCard.handleToggleOpen, offset: 0x020c7cb1, size: 138 bytes, params: 1, frame: 16
var value6;
let binding = env0_0;
const {skuId, subscriptionPlanId, loadedAt} = binding.props;
const value2 = !binding.state.isOpen;
let r1 = loadedAt != null && env0_0._mountedAt != null;
r1 = !r1 ? !value2 : r1;
if (!r1) {
value6 = environment.__proto__.__proto__;
(importDefault(8451) /* metro dependency 8451: GiftCodeActionCreators */).fetchUserGiftCodesForSKU(skuId,
subscriptionPlanId);
}
binding = env0_0;
binding.setState({isOpen: value2});
}
function handleGenerateGiftCode() { // fn#93871, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:2499, owner: EntitlementGiftGroupCard.handleGenerateGiftCode, offset: 0x020c7d3b, size: 69 bytes, params: 1, frame: 16
const {skuId, subscriptionPlanId, giftStyle} = env0_0.props;
const value = environment.__proto__.__proto__;
(importDefault(8451) /* metro dependency 8451: GiftCodeActionCreators */).createGiftCode(skuId, subscriptionPlanId,
giftStyle);
}
function _fun93878(a0, a1) { // fn#93878, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12473:6033, offset: 0x020c8773, size: 88 bytes, params: 3, frame: 18
const value = environment.__proto__.__proto__;
return ((Component) => <Component giftCode={a0} sku={sku} isFirst={a1 === 0} isRefreshEnabled={isRefreshEnabled} key={a0.code} />)(importDefault(12290) /* metro dependency 12290: GiftCodeRow */);
}