Files
discord-decomp/modules/skus/utils/transformSKUTenantMetadata.tsx
T
2026-11-01 12:12:55 +02:00

151 lines
5.3 KiB
TypeScript

// Metro module 4231 (f4232).
import { CollectiblesItemType } from "../../../_bundle/Module1901";
const transformProfileEffectKeyFrameFromServer = function transformProfileEffectKeyFrameFromServer(a0) {
let duration = a0.duration;
if (duration == null) {
duration = 0;
}
let start = a0.start;
if (start == null) {
start = 0;
}
const randomizedSources = a0.randomizedSources;
return {
src: a0.src,
loop: a0.loop,
height: a0.height,
width: a0.width,
duration,
start,
loopDelay: a0.loopDelay,
position: a0.position,
zIndex: a0.zIndex,
randomizedSources: randomizedSources == null ? void 0 : randomizedSources.map((randomizedSource) => ({
src: randomizedSource.src
}))
};
};
export default function transformSKUTenantMetadata(a0) {
if (a0 != null) {
const social_layer = a0.social_layer;
const r3 = social_layer != null;
let socialLayer = void 0;
if (r3) {
const carousel_items = social_layer.carousel_items;
let carouselItems = carousel_items == null ? void 0 : carousel_items.map((carousel_item) => ({
thumbnailAssetId: carousel_item.thumbnail_asset_id,
assetId: carousel_item.asset_id,
backgroundAssetId: carousel_item.background_asset_id,
youtubeVideoId: carousel_item.youtube_video_id,
label: carousel_item.label,
labelIconAssetId: carousel_item.label_icon_asset_id,
title: carousel_item.title,
description: carousel_item.description
}));
if (carouselItems == null) {
carouselItems = [];
}
socialLayer = {
carouselItems,
expiresAt: social_layer.expires_at != null ? new Date(social_layer.expires_at) : void 0,
cardImageAssetId: social_layer.card_image_asset_id,
cardBackgroundImageAssetId: social_layer.card_background_image_asset_id
};
}
const collectibles = a0.collectibles;
const r31 = collectibles != null;
let collectibles2 = void 0;
if (r31) {
const item = collectibles.item;
const r36 = item != null;
let item2 = void 0;
if (r36) {
const type = item.type;
if (CollectiblesItemType.AVATAR_DECORATION === type) {
const assets2 = item.assets;
item2 = {
id: item.id,
type: item.type,
asset: item.asset,
assets: assets2 != null ? {
staticImagePath: assets2.static_image_path,
animatedImagePath: assets2.animated_image_path,
videoPath: assets2.video_path
} : void 0,
label: item.label
};
} else if (CollectiblesItemType.NAMEPLATE === type) {
const assets = item.assets;
item2 = {
id: item.id,
type: item.type,
asset: item.asset,
assets: assets != null ? {
staticImagePath: assets.static_image_path,
animatedImagePath: assets.animated_image_path,
videoPath: assets.video_path
} : void 0,
label: item.label,
palette: item.palette
};
} else if (CollectiblesItemType.PROFILE_EFFECT === type) {
const effects = item.effects;
item2 = {
id: item.id,
type: item.type,
title: item.title,
description: item.description,
accessibilityLabel: item.accessibilityLabel,
animationType: item.animationType,
staticFrameSrc: item.staticFrameSrc,
thumbnailPreviewSrc: item.thumbnailPreviewSrc,
reducedMotionSrc: item.reducedMotionSrc,
effects: effects == null ? void 0 : effects.map(transformProfileEffectKeyFrameFromServer)
};
} else {
item2 = CollectiblesItemType.PROFILE_FRAME === type ? {
id: item.id,
type: item.type,
label: item.label,
layers: item.layers,
innerWidth: item.inner_width,
overflowTop: item.overflow_top,
overflowBottom: item.overflow_bottom,
overflowHorizontal: item.overflow_horizontal
} : void 0;
}
}
const expiresAt = collectibles.expires_at != null ? new Date(1000 * collectibles.expires_at) : void 0;
const variant = collectibles.variant;
collectibles2 = {
type: collectibles.type,
item: item2,
categorySkuId: collectibles.category_sku_id,
premiumType: collectibles.premium_type,
expiresSecondsAfterClaim: collectibles.expires_seconds_after_claim,
expiresAt,
variant: variant != null ? {
role: variant.role,
baseVariantSkuId: variant.base_variant_sku_id,
baseVariantName: variant.base_variant_name,
value: variant.value,
label: variant.label,
collapseUnder: variant.collapse_under
} : void 0,
optionSelectorDisplayValue: collectibles.option_selector_display_value,
sourceType: collectibles.source_type,
isFirstParty: collectibles.is_first_party
};
}
const plan_features = a0.plan_features;
return {
socialLayer,
collectibles: collectibles2,
gameServerPlanFeatures: plan_features == null ? void 0 : plan_features.map((plan_feature) => ({
title: plan_feature.title,
description: plan_feature.description
}))
};
}
};