807 lines
25 KiB
TypeScript
807 lines
25 KiB
TypeScript
// Metro module 1416 (f1417).
|
|
import { AVATAR_SIZE, Endpoints } from "../Constants";
|
|
import { AVATAR_DECORATION_SIZE } from "../modules/collectibles/avatar_decorations/AvatarDecorationConstants";
|
|
import * as _AvatarUtils from "./native/AvatarUtils";
|
|
import * as _PlatformUtils from "./PlatformUtils";
|
|
import { getBestMediaProxySize, getDevicePixelRatio } from "../modules/image_upload/ImageLoaderUtils";
|
|
import Module1464 from "../_bundle/Module1464";
|
|
import { getForceSdrEmojisStickersConfig } from "../modules/image_upload/ForceSdrEmojisStickersExperiment";
|
|
import { parseInteger } from "./NumberUtils";
|
|
import Integer from "../_bundle/Integer";
|
|
import { isAvatarDecorationExpired } from "../modules/collectibles/avatar_decorations/AvatarDecorationUtils";
|
|
import * as _CollectiblesAssetUtils from "../modules/collectibles/utils/CollectiblesAssetUtils";
|
|
import { getCollectiblesItemAssetUrl } from "../modules/collectibles/utils/CollectiblesAssetUtils";
|
|
import Module1855 from "../_bundle/Module1855";
|
|
import SnowflakeUtils from "./SnowflakeUtils";
|
|
import { parse } from "../_bundle/Url_1469";
|
|
let c1171_6, DEFAULT_AVATARS, DEFAULT_AVATARS_SMALL, DEFAULT_AVATARS_SMALL_MAX_SIZE, DEFAULT_PROVISIONAL_AVATARS, canUseWebp, isAndroid, getDefaultAvatarURL, getUserAvatarURL, getGuildMemberAvatarURLSimple, getGuildBannerURL, getApplicationIconURL, getChannelIconURL, _getAssetHash;
|
|
const getAvatarURL = function getAvatarURL(a0) {
|
|
let r45, r46;
|
|
const { endpoint: endpoint2, path, id, hash, size, lossless = false, canAnimate = false, keepAspectRatio } = a0;
|
|
let format = a0.format;
|
|
if (format === void 0) {
|
|
format = null;
|
|
}
|
|
let canWebP = a0.canWebP;
|
|
if (canWebP === void 0) {
|
|
canWebP = canUseWebp;
|
|
}
|
|
if (id != null && hash != null) {
|
|
if (format == null) {
|
|
format = canAnimate ? hash != null && hash.startsWith("a_") ? canWebP ? "webp" : "gif" : "jpg" : "jpg";
|
|
}
|
|
if (canAnimate ? hash != null && hash.startsWith("v_") : canAnimate) {
|
|
format = "mp4";
|
|
}
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
if (CDN_HOST != null) {
|
|
const r48 = format === "jpg" ? canWebP ? "webp" : "png" : format;
|
|
r45 = `https://${CDN_HOST}/${path}/${id}/${hash}.${r48}`;
|
|
r46 = r48;
|
|
} else {
|
|
r45 = location.protocol + window.GLOBAL_ENV.API_ENDPOINT + endpoint2(id, hash, format);
|
|
r46 = format;
|
|
}
|
|
if (r46 === "mp4") {
|
|
return r45;
|
|
}
|
|
const r54 = {};
|
|
if (size != null) {
|
|
r54.size = getBestMediaProxySize(size * getDevicePixelRatio());
|
|
}
|
|
if (keepAspectRatio != null) {
|
|
r54.keep_aspect_ratio = keepAspectRatio;
|
|
}
|
|
if (lossless) {
|
|
r54.quality = "lossless";
|
|
}
|
|
if (r46 === "webp" && canAnimate && (hash != null && hash.startsWith("a_"))) {
|
|
r54.animated = true;
|
|
}
|
|
return r45 + `?${Module1464.stringify(r54)}`;
|
|
}
|
|
};
|
|
getDefaultAvatarURL = function getDefaultAvatarURL(id, discriminator, r3 = false) {
|
|
let r11;
|
|
L10: {
|
|
if (r3) {
|
|
r11 = DEFAULT_PROVISIONAL_AVATARS;
|
|
} else {
|
|
if (!r3) {
|
|
const r4 = arguments[3];
|
|
if (r4 != null && r4 <= DEFAULT_AVATARS_SMALL_MAX_SIZE) {
|
|
r11 = DEFAULT_AVATARS_SMALL;
|
|
break L10;
|
|
}
|
|
}
|
|
r11 = DEFAULT_AVATARS;
|
|
}
|
|
}
|
|
if (id == null && discriminator == null) {
|
|
return r11[0];
|
|
}
|
|
const r16 = parseInteger(discriminator, 0);
|
|
return r16 > 0 ? r11[r16 % 5] : id != null ? r11[Integer(id).shiftRight(22).mod(r11.length).toJSNumber()] : r11[0];
|
|
};
|
|
getUserAvatarURL = function getUserAvatarURL(a0, canAnimate = false, r8 = AVATAR_SIZE, format = null, canWebP = canUseWebp) {
|
|
let r26;
|
|
const { id, avatar, discriminator, bot } = a0;
|
|
if (canAnimate === void 0) {
|
|
canAnimate = false;
|
|
}
|
|
let size = r8;
|
|
if (size === void 0) {
|
|
size = AVATAR_SIZE;
|
|
}
|
|
if (format === void 0) {
|
|
format = null;
|
|
}
|
|
if (canWebP === void 0) {
|
|
canWebP = canUseWebp;
|
|
}
|
|
L22: {
|
|
if (bot) {
|
|
r26 = _AvatarUtils.default.BOT_AVATARS[avatar];
|
|
if (r26) {
|
|
break L22;
|
|
}
|
|
r26 = avatar == null && discriminator === "0000" ? DEFAULT_AVATARS[0] : getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id,
|
|
hash: avatar,
|
|
size,
|
|
canAnimate,
|
|
format,
|
|
canWebP
|
|
});
|
|
} else {
|
|
r26 = getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id,
|
|
hash: avatar,
|
|
size,
|
|
canAnimate,
|
|
format,
|
|
canWebP
|
|
});
|
|
}
|
|
}
|
|
if (r26 == null) {
|
|
r26 = getDefaultAvatarURL(a0.id, a0.discriminator, a0.isProvisional, r8);
|
|
}
|
|
return r26;
|
|
};
|
|
getGuildMemberAvatarURLSimple = function getGuildMemberAvatarURLSimple({ guildId, userId: userId2, avatar, canAnimate = false, size = AVATAR_SIZE, canWebP = canUseWebp }) {
|
|
let r35, r36;
|
|
const r4 = canAnimate ? avatar != null && avatar.startsWith("a_") ? canWebP ? "webp" : "gif" : "jpg" : "jpg";
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
if (CDN_HOST != null) {
|
|
const r37 = r4 === "jpg" ? canWebP ? "webp" : "png" : r4;
|
|
r35 = `https://${CDN_HOST}${Endpoints.GUILD_MEMBER_AVATAR(guildId, userId2, avatar, r37)}`;
|
|
r36 = r37;
|
|
} else {
|
|
r35 = location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_MEMBER_AVATAR(guildId, userId2, avatar, r4);
|
|
r36 = r4;
|
|
}
|
|
const r61 = {
|
|
size: getBestMediaProxySize(size * getDevicePixelRatio())
|
|
};
|
|
if (r36 === "webp" && canAnimate && (avatar != null && avatar.startsWith("a_"))) {
|
|
r61.animated = true;
|
|
}
|
|
return r35 + `?${Module1464.stringify(r61)}`;
|
|
};
|
|
getGuildBannerURL = function getGuildBannerURL(a0) {
|
|
const { id, banner } = a0;
|
|
let r10 = arguments[1];
|
|
if (r10 === void 0) {
|
|
r10 = false;
|
|
}
|
|
if (banner == null) {
|
|
return null;
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(360 * getDevicePixelRatio());
|
|
const r36 = canUseWebp ? "webp" : "jpg";
|
|
const r11 = r10 ? banner != null && banner.startsWith("a_") ? canUseWebp ? "webp" : "gif" : r36 : r36;
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
const r51 = CDN_HOST != null ? `https://${CDN_HOST}/banners/${id}/${banner}.${r11}` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_BANNER(id, banner, r11);
|
|
const r53 = {
|
|
size: bestMediaProxySize
|
|
};
|
|
if (r11 === "jpg") {
|
|
r53.quality = "lossless";
|
|
}
|
|
if (r11 === "webp" && r10 && (banner != null && banner.startsWith("a_"))) {
|
|
r53.animated = true;
|
|
}
|
|
return r51 + `?${Module1464.stringify(r53)}`;
|
|
};
|
|
getApplicationIconURL = function getApplicationIconURL({ id, icon, size = AVATAR_SIZE, bot, botIconFirst, fallbackAvatar = true, keepAspectRatio, guildMember }) {
|
|
let r30, r49;
|
|
if (bot?.id != null && guildMember != null && guildMember.avatar != null) {
|
|
return getGuildMemberAvatarURLSimple({
|
|
userId: bot.id,
|
|
guildId: guildMember.guildId,
|
|
avatar: guildMember.avatar,
|
|
canAnimate: false,
|
|
size
|
|
});
|
|
}
|
|
if (bot != null && botIconFirst) {
|
|
const { id: id2, avatar, discriminator, bot: bot2 } = bot;
|
|
const size2 = size === void 0 ? AVATAR_SIZE : size;
|
|
L19: {
|
|
if (bot2) {
|
|
r30 = _AvatarUtils.default.BOT_AVATARS[avatar];
|
|
if (r30) {
|
|
break L19;
|
|
}
|
|
r30 = avatar == null && discriminator === "0000" ? DEFAULT_AVATARS[0] : getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id: id2,
|
|
hash: avatar,
|
|
size: size2,
|
|
canAnimate: false,
|
|
format: null,
|
|
canWebP: canUseWebp
|
|
});
|
|
} else {
|
|
r30 = getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id: id2,
|
|
hash: avatar,
|
|
size: size2,
|
|
canAnimate: false,
|
|
format: null,
|
|
canWebP: canUseWebp
|
|
});
|
|
}
|
|
}
|
|
if (r30 != null) {
|
|
return r30;
|
|
}
|
|
}
|
|
if (icon != null) {
|
|
return icon != null && c1171_6.test(icon) ? icon : getAvatarURL({
|
|
endpoint: Endpoints.APPLICATION_ICON,
|
|
path: "app-icons",
|
|
id,
|
|
hash: icon,
|
|
size,
|
|
canAnimate: false,
|
|
canWebP: false,
|
|
keepAspectRatio
|
|
});
|
|
}
|
|
if (bot != null) {
|
|
const { id: id3, avatar: avatar2, discriminator: discriminator2, bot: bot3 } = bot;
|
|
let size3 = size;
|
|
if (size3 === void 0) {
|
|
size3 = AVATAR_SIZE;
|
|
}
|
|
L30: {
|
|
if (bot3) {
|
|
r49 = _AvatarUtils.default.BOT_AVATARS[avatar2];
|
|
if (r49) {
|
|
break L30;
|
|
}
|
|
r49 = avatar2 == null && discriminator2 === "0000" ? DEFAULT_AVATARS[0] : getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id: id3,
|
|
hash: avatar2,
|
|
size: size3,
|
|
canAnimate: false,
|
|
format: null,
|
|
canWebP: canUseWebp
|
|
});
|
|
} else {
|
|
r49 = getAvatarURL({
|
|
endpoint: Endpoints.AVATAR,
|
|
path: "avatars",
|
|
id: id3,
|
|
hash: avatar2,
|
|
size: size3,
|
|
canAnimate: false,
|
|
format: null,
|
|
canWebP: canUseWebp
|
|
});
|
|
}
|
|
}
|
|
if (r49 != null) {
|
|
return r49;
|
|
}
|
|
}
|
|
return fallbackAvatar ? Module1855 : void 0;
|
|
};
|
|
getChannelIconURL = function getChannelIconURL({ id, icon, applicationId, size }) {
|
|
let r16;
|
|
if (applicationId != null) {
|
|
let r34 = getApplicationIconURL({
|
|
id: applicationId,
|
|
icon,
|
|
size
|
|
});
|
|
if (r34 == null) {
|
|
r34 = _AvatarUtils.default.DEFAULT_CHANNEL_ICON;
|
|
}
|
|
r16 = r34;
|
|
} else {
|
|
r16 = getAvatarURL({
|
|
endpoint: Endpoints.CHANNEL_ICON,
|
|
path: "channel-icons",
|
|
id,
|
|
hash: icon,
|
|
canAnimate: false,
|
|
size,
|
|
canWebP: false
|
|
});
|
|
if (r16 == null) {
|
|
r16 = _AvatarUtils.default.DEFAULT_GROUP_DM_AVATARS[SnowflakeUtils.extractTimestamp(id) % _AvatarUtils.default.DEFAULT_GROUP_DM_AVATARS.length];
|
|
}
|
|
}
|
|
return r16;
|
|
};
|
|
_getAssetHash = function _getAssetHash(a0) {
|
|
let r14;
|
|
try {
|
|
r14 = parse(a0).pathname.split("/").pop();
|
|
} catch ($e) {
|
|
return null;
|
|
}
|
|
return r14;
|
|
};
|
|
c1171_6 = /^data:/;
|
|
DEFAULT_AVATARS = _AvatarUtils.default.DEFAULT_AVATARS;
|
|
let DEFAULT_AVATARS_SMALL2 = _AvatarUtils.default.DEFAULT_AVATARS_SMALL;
|
|
if (DEFAULT_AVATARS_SMALL2 == null) {
|
|
DEFAULT_AVATARS_SMALL2 = DEFAULT_AVATARS;
|
|
}
|
|
DEFAULT_AVATARS_SMALL = DEFAULT_AVATARS_SMALL2;
|
|
let DEFAULT_AVATARS_SMALL_MAX_SIZE2 = _AvatarUtils.default.DEFAULT_AVATARS_SMALL_MAX_SIZE;
|
|
if (DEFAULT_AVATARS_SMALL_MAX_SIZE2 == null) {
|
|
DEFAULT_AVATARS_SMALL_MAX_SIZE2 = 0;
|
|
}
|
|
export function getEmojiURL({ id, animated, size, forcePNG = false }) {
|
|
let enabled;
|
|
let r3 = "png";
|
|
let r11 = "png";
|
|
if (!forcePNG) {
|
|
if (animated) {
|
|
r3 = canUseWebp ? "webp" : "gif";
|
|
} else if (canUseWebp) {
|
|
r3 = "webp";
|
|
}
|
|
r11 = r3;
|
|
}
|
|
const r9 = canUseWebp ? animated ? "&animated=true" : "" : "";
|
|
const r43 = `size=${getBestMediaProxySize(size * getDevicePixelRatio(), isAndroid)}`;
|
|
try {
|
|
enabled = (0, getForceSdrEmojisStickersConfig)({
|
|
location: "getEmojiURL"
|
|
}).enabled;
|
|
} catch ($e) {}
|
|
const r53 = enabled ? "&force_sdr=true" : "";
|
|
if (window.GLOBAL_ENV.CDN_HOST != null) {
|
|
return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${id}.${r11}?${r43}${r9}${r53}`;
|
|
}
|
|
const r67 = location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.EMOJI(id, r11);
|
|
return enabled ? `${r67}?force_sdr=true` : r67;
|
|
}
|
|
export function getGuildMemberAvatarURL(a0) {
|
|
const { userId: userId2, avatar, guildId } = a0;
|
|
let canAnimate = arguments[1];
|
|
if (canAnimate === void 0) {
|
|
canAnimate = false;
|
|
}
|
|
return avatar != null ? getGuildMemberAvatarURLSimple({
|
|
userId: userId2,
|
|
avatar,
|
|
guildId,
|
|
canAnimate
|
|
}) : null;
|
|
}
|
|
export function getGuildMemberAvatarSource(a0, a1, r7 = false) {
|
|
let r16;
|
|
const { userId: userId2, avatar, guildId } = a0;
|
|
let canAnimate = r7;
|
|
if (canAnimate === void 0) {
|
|
canAnimate = false;
|
|
}
|
|
const r5 = avatar == null ? null : getGuildMemberAvatarURLSimple({
|
|
userId: userId2,
|
|
avatar,
|
|
guildId,
|
|
canAnimate
|
|
});
|
|
if (r5 != null) {
|
|
let r17 = r5;
|
|
if (typeof r17 !== "number") {
|
|
r17 = {
|
|
uri: r5 == null ? void 0 : r5
|
|
};
|
|
}
|
|
r16 = r17;
|
|
} else {
|
|
r16 = a1.getAvatarSource(a0.guildId, r7);
|
|
}
|
|
return r16;
|
|
}
|
|
export function getUserBannerURL({ id, banner, canAnimate, size }) {
|
|
if (banner != null) {
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
const r9 = canAnimate ? banner != null && banner.startsWith("a_") ? canUseWebp ? "webp" : "gif" : "png" : "png";
|
|
const r38 = CDN_HOST != null ? `https://${CDN_HOST}/banners/${id}/${banner}.${r9}` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.USER_BANNER(id, banner, r9);
|
|
const r51 = {
|
|
size: getBestMediaProxySize(size * getDevicePixelRatio())
|
|
};
|
|
if (r9 === "webp" && canAnimate && (banner != null && banner.startsWith("a_"))) {
|
|
r51.animated = true;
|
|
}
|
|
return r38 + `?${Module1464.stringify(r51)}`;
|
|
}
|
|
}
|
|
export function getAvatarDecorationURL({ avatarDecoration, size = AVATAR_DECORATION_SIZE, canAnimate = false }) {
|
|
let r32;
|
|
if (avatarDecoration != null && !isAvatarDecorationExpired(avatarDecoration)) {
|
|
L16: {
|
|
try {
|
|
const CollectiblesItemAssetFormat = _CollectiblesAssetUtils.CollectiblesItemAssetFormat;
|
|
const collectiblesItemAssetUrl = getCollectiblesItemAssetUrl({
|
|
skuId: avatarDecoration.skuId,
|
|
assetFormat: canAnimate ? CollectiblesItemAssetFormat.ANIMATED : CollectiblesItemAssetFormat.STATIC
|
|
});
|
|
r32 = collectiblesItemAssetUrl;
|
|
if (collectiblesItemAssetUrl != null) {
|
|
break L16;
|
|
}
|
|
} catch ($e) {
|
|
return null;
|
|
}
|
|
const asset = avatarDecoration.asset;
|
|
if (asset == null) {
|
|
return null;
|
|
}
|
|
const GLOBAL_ENV = window.GLOBAL_ENV;
|
|
const { CDN_HOST, API_ENDPOINT } = GLOBAL_ENV;
|
|
const r10 = Endpoints.AVATAR_DECORATION_PRESETS(asset);
|
|
const r47 = CDN_HOST != null ? new URL(`https://${CDN_HOST}${r10}`) : new URL(`${location.protocol}${API_ENDPOINT}${r10}`);
|
|
r47.searchParams.set("size", `${getBestMediaProxySize(size * getDevicePixelRatio(), isAndroid)}`);
|
|
r47.searchParams.set("passthrough", `${canAnimate}`);
|
|
return r47.toString();
|
|
}
|
|
return r32;
|
|
}
|
|
return null;
|
|
}
|
|
export function getGuildMemberBannerURL({ id, guildId, banner, canAnimate, size }) {
|
|
if (banner != null && guildId != null) {
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
const r22 = canAnimate ? banner != null && banner.startsWith("a_") ? canUseWebp ? "webp" : "gif" : "png" : "png";
|
|
const r27 = Endpoints.GUILD_MEMBER_BANNER(guildId, id, banner, r22);
|
|
const r35 = CDN_HOST != null ? `https://${CDN_HOST}${r27}` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + r27;
|
|
const r51 = {
|
|
size: getBestMediaProxySize(size * getDevicePixelRatio())
|
|
};
|
|
if (r22 === "webp" && canAnimate && (banner != null && banner.startsWith("a_"))) {
|
|
r51.animated = true;
|
|
}
|
|
return r35 + `?${Module1464.stringify(r51)}`;
|
|
}
|
|
}
|
|
const getGuildSplashURL = function getGuildSplashURL(a0) {
|
|
const { id, splash } = a0;
|
|
let size = a0.size;
|
|
if (splash == null) {
|
|
return null;
|
|
}
|
|
if (size == null) {
|
|
size = window.screen.width * getDevicePixelRatio();
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(size);
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
return (CDN_HOST != null ? `https://${CDN_HOST}/splashes/${id}/${splash}.jpg` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_SPLASH(id, splash)) + `?size=${bestMediaProxySize}`;
|
|
};
|
|
const getGuildHomeHeaderURL = function getGuildHomeHeaderURL({ id, homeHeader }) {
|
|
if (homeHeader == null) {
|
|
return null;
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(1096 * getDevicePixelRatio());
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
return (CDN_HOST != null ? `https://${CDN_HOST}/home-headers/${id}/${homeHeader}.png` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_HOME_HEADER(id, homeHeader)) + `?size=${bestMediaProxySize}`;
|
|
};
|
|
export function getResourceChannelIconURL({ channelId, icon }) {
|
|
return icon != null ? getAvatarURL({
|
|
endpoint: Endpoints.GUILD_RESOURCE_CHANNELS_ICON,
|
|
path: "resource-channels",
|
|
id: channelId,
|
|
hash: icon,
|
|
size: AVATAR_SIZE,
|
|
canAnimate: true,
|
|
canWebP: false
|
|
}) : null;
|
|
}
|
|
export function getNewMemberActionIconURL({ channelId, icon }) {
|
|
return icon != null ? getAvatarURL({
|
|
endpoint: Endpoints.GUILD_NEW_MEMBER_ACTIONS_ICON,
|
|
path: "new-member-actions",
|
|
id: channelId,
|
|
hash: icon,
|
|
size: AVATAR_SIZE,
|
|
canAnimate: true,
|
|
canWebP: false
|
|
}) : null;
|
|
}
|
|
const getGuildDiscoverySplashURL = function getGuildDiscoverySplashURL(a0) {
|
|
const { id, splash } = a0;
|
|
let size = a0.size;
|
|
if (splash == null) {
|
|
return null;
|
|
}
|
|
if (size == null) {
|
|
size = window.screen.width * getDevicePixelRatio();
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(size);
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
return (CDN_HOST != null ? `https://${CDN_HOST}/discovery-splashes/${id}/${splash}.jpg` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_DISCOVERY_SPLASH(id, splash)) + `?size=${bestMediaProxySize}`;
|
|
};
|
|
const getGuildIconURL = function getGuildIconURL({ id, icon, size, canAnimate = false, lossless = false }) {
|
|
return getAvatarURL({
|
|
endpoint: Endpoints.GUILD_ICON,
|
|
path: "icons",
|
|
id,
|
|
hash: icon,
|
|
size,
|
|
canAnimate,
|
|
lossless,
|
|
canWebP: canUseWebp
|
|
});
|
|
};
|
|
export function getGuildTemplateIconURL({ id, icon, size = AVATAR_SIZE, canAnimate = false }) {
|
|
return getAvatarURL({
|
|
endpoint: Endpoints.GUILD_TEMPLATE_ICON,
|
|
path: "guild-templates",
|
|
id,
|
|
hash: icon,
|
|
size,
|
|
canAnimate,
|
|
canWebP: false
|
|
});
|
|
}
|
|
const getGameAssetURL = function getGameAssetURL(a0) {
|
|
const { id, hash, size = AVATAR_SIZE, keepAspectRatio = false } = a0;
|
|
return getAvatarURL({
|
|
endpoint: Endpoints.APPLICATION_ICON,
|
|
path: "app-icons",
|
|
id,
|
|
hash,
|
|
size,
|
|
canAnimate: false,
|
|
keepAspectRatio,
|
|
format: a0.format,
|
|
canWebP: false
|
|
});
|
|
};
|
|
export function getVideoFilterAssetURL({ userId, assetId, assetHash, size, canAnimate = true }) {
|
|
return getAvatarURL({
|
|
endpoint: (a0, a1, a2) => Endpoints.VIDEO_FILTER_ASSET_STORAGE(userId, assetId, assetHash, a2),
|
|
path: `video-filter-assets/${userId}`,
|
|
id: assetId,
|
|
hash: assetHash,
|
|
size,
|
|
canAnimate,
|
|
canWebP: false
|
|
});
|
|
}
|
|
export function hasAnimatedGuildIcon(a0) {
|
|
const icon = a0?.icon;
|
|
return icon != null && icon.startsWith("a_");
|
|
}
|
|
export function isAnimatedIconHash(a0) {
|
|
return a0 != null && a0.startsWith("a_");
|
|
}
|
|
export function isVideoAssetHash(a0) {
|
|
return a0 != null && a0.startsWith("v_");
|
|
}
|
|
export function makeSource(a0) {
|
|
return typeof a0 !== "number" ? {
|
|
uri: a0 == null ? void 0 : a0
|
|
} : a0;
|
|
}
|
|
export function isDataUri(a0) {
|
|
return a0 != null && c1171_6.test(a0);
|
|
}
|
|
DEFAULT_AVATARS_SMALL_MAX_SIZE = DEFAULT_AVATARS_SMALL_MAX_SIZE2;
|
|
DEFAULT_PROVISIONAL_AVATARS = _AvatarUtils.default.DEFAULT_PROVISIONAL_AVATARS;
|
|
export const DEFAULT_GROUP_DM_AVATARS = _AvatarUtils.default.DEFAULT_GROUP_DM_AVATARS;
|
|
canUseWebp = _AvatarUtils.default.canUseWebp();
|
|
isAndroid = _PlatformUtils.isAndroid();
|
|
const r80 = {
|
|
getUserAvatarURL,
|
|
getDefaultAvatarURL,
|
|
getGuildMemberAvatarURL,
|
|
getGuildMemberAvatarURLSimple,
|
|
getGuildMemberAvatarSource,
|
|
getGuildMemberBannerURL,
|
|
getUserBannerURL,
|
|
getAvatarDecorationURL,
|
|
hasAnimatedGuildIcon,
|
|
isAnimatedIconHash,
|
|
getUserAvatarSource: (a0, a1, a2) => {
|
|
const userAvatarURL = getUserAvatarURL(a0, a1, a2);
|
|
let r8 = userAvatarURL;
|
|
if (typeof r8 !== "number") {
|
|
r8 = {
|
|
uri: userAvatarURL == null ? void 0 : userAvatarURL
|
|
};
|
|
}
|
|
return r8;
|
|
},
|
|
getGuildIconURL,
|
|
getGuildSplashURL,
|
|
getGuildSplashSource: function getGuildSplashSource(a0) {
|
|
const { id, splash } = a0;
|
|
let size = a0.size;
|
|
const r0 = splash == null;
|
|
let r3 = null;
|
|
if (!r0) {
|
|
if (size == null) {
|
|
size = window.screen.width * getDevicePixelRatio();
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(size);
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
r3 = (CDN_HOST != null ? `https://${CDN_HOST}/splashes/${id}/${splash}.jpg` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_SPLASH(id, splash)) + `?size=${bestMediaProxySize}`;
|
|
}
|
|
let r55 = r3;
|
|
if (typeof r55 !== "number") {
|
|
r55 = {
|
|
uri: r3 == null ? void 0 : r3
|
|
};
|
|
}
|
|
return r55;
|
|
},
|
|
getGuildDiscoverySplashURL,
|
|
getGuildDiscoverySplashSource: function getGuildDiscoverySplashSource(a0) {
|
|
const { id, splash } = a0;
|
|
let size = a0.size;
|
|
const r0 = splash == null;
|
|
let r3 = null;
|
|
if (!r0) {
|
|
if (size == null) {
|
|
size = window.screen.width * getDevicePixelRatio();
|
|
}
|
|
const bestMediaProxySize = getBestMediaProxySize(size);
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
r3 = (CDN_HOST != null ? `https://${CDN_HOST}/discovery-splashes/${id}/${splash}.jpg` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_DISCOVERY_SPLASH(id, splash)) + `?size=${bestMediaProxySize}`;
|
|
}
|
|
let r55 = r3;
|
|
if (typeof r55 !== "number") {
|
|
r55 = {
|
|
uri: r3 == null ? void 0 : r3
|
|
};
|
|
}
|
|
return r55;
|
|
},
|
|
getGuildBannerURL,
|
|
getGuildHomeHeaderURL,
|
|
getResourceChannelIconURL,
|
|
getNewMemberActionIconURL,
|
|
getGuildTemplateIconURL,
|
|
getChannelIconURL,
|
|
getEmojiURL,
|
|
getApplicationIconURL,
|
|
getGameAssetURL,
|
|
getVideoFilterAssetURL,
|
|
getGameAssetSource: (a0) => {
|
|
const { id, hash, size = AVATAR_SIZE, keepAspectRatio = false } = a0;
|
|
const avatarURL = getAvatarURL({
|
|
endpoint: Endpoints.APPLICATION_ICON,
|
|
path: "app-icons",
|
|
id,
|
|
hash,
|
|
size,
|
|
canAnimate: false,
|
|
keepAspectRatio,
|
|
format: a0.format,
|
|
canWebP: false
|
|
});
|
|
let r15 = avatarURL;
|
|
if (typeof r15 !== "number") {
|
|
r15 = {
|
|
uri: avatarURL == null ? void 0 : avatarURL
|
|
};
|
|
}
|
|
return r15;
|
|
},
|
|
getGuildIconSource: ({ id, icon, size, canAnimate = false, lossless = false }) => {
|
|
const avatarURL = getAvatarURL({
|
|
endpoint: Endpoints.GUILD_ICON,
|
|
path: "icons",
|
|
id,
|
|
hash: icon,
|
|
size,
|
|
canAnimate,
|
|
lossless,
|
|
canWebP: canUseWebp
|
|
});
|
|
let r16 = avatarURL;
|
|
if (typeof r16 !== "number") {
|
|
r16 = {
|
|
uri: avatarURL == null ? void 0 : avatarURL
|
|
};
|
|
}
|
|
return r16;
|
|
},
|
|
getGuildTemplateIconSource: ({ id, icon, size = AVATAR_SIZE, canAnimate = false }) => {
|
|
const avatarURL = getAvatarURL({
|
|
endpoint: Endpoints.GUILD_TEMPLATE_ICON,
|
|
path: "guild-templates",
|
|
id,
|
|
hash: icon,
|
|
size,
|
|
canAnimate,
|
|
canWebP: false
|
|
});
|
|
let r14 = avatarURL;
|
|
if (typeof r14 !== "number") {
|
|
r14 = {
|
|
uri: avatarURL == null ? void 0 : avatarURL
|
|
};
|
|
}
|
|
return r14;
|
|
},
|
|
getGuildBannerSource: function getGuildBannerSource(a0, r4 = false) {
|
|
const guildBannerURL = getGuildBannerURL(a0, r4);
|
|
let r7 = guildBannerURL;
|
|
if (typeof r7 !== "number") {
|
|
r7 = {
|
|
uri: guildBannerURL == null ? void 0 : guildBannerURL
|
|
};
|
|
}
|
|
return r7;
|
|
},
|
|
getGuildHomeHeaderSource: ({ id, homeHeader }) => {
|
|
const r1 = homeHeader == null;
|
|
let r4 = null;
|
|
if (!r1) {
|
|
const bestMediaProxySize = getBestMediaProxySize(1096 * getDevicePixelRatio());
|
|
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
|
|
r4 = (CDN_HOST != null ? `https://${CDN_HOST}/home-headers/${id}/${homeHeader}.png` : location.protocol + window.GLOBAL_ENV.API_ENDPOINT + Endpoints.GUILD_HOME_HEADER(id, homeHeader)) + `?size=${bestMediaProxySize}`;
|
|
}
|
|
let r49 = r4;
|
|
if (typeof r49 !== "number") {
|
|
r49 = {
|
|
uri: r4 == null ? void 0 : r4
|
|
};
|
|
}
|
|
return r49;
|
|
},
|
|
getChannelIconSource: (a0) => {
|
|
const channelIconURL = getChannelIconURL(a0);
|
|
let r7 = channelIconURL;
|
|
if (typeof r7 !== "number") {
|
|
r7 = {
|
|
uri: channelIconURL == null ? void 0 : channelIconURL
|
|
};
|
|
}
|
|
return r7;
|
|
},
|
|
getApplicationIconSource: (a0) => {
|
|
const applicationIconURL = getApplicationIconURL(a0);
|
|
let r7 = applicationIconURL;
|
|
if (typeof r7 !== "number") {
|
|
r7 = {
|
|
uri: applicationIconURL == null ? void 0 : applicationIconURL
|
|
};
|
|
}
|
|
return r7;
|
|
},
|
|
makeSource,
|
|
getAnimatableSourceWithFallback: (a0, a1) => {
|
|
const r4 = a1(a0);
|
|
if (_PlatformUtils.isAndroid() && a0 && typeof r4 !== "number") {
|
|
const r14 = a1(false);
|
|
return typeof r14 !== "number" ? r14.uri !== r4.uri ? [r4, {
|
|
...r14,
|
|
isForceCached: true
|
|
}] : r14 : [r4, {
|
|
...r14,
|
|
isForceCached: true
|
|
}];
|
|
}
|
|
return r4;
|
|
}
|
|
};
|
|
export default r80;
|
|
export { c1171_6 as DATA_IMAGE_PREFIX };
|
|
export { DEFAULT_AVATARS };
|
|
export { DEFAULT_AVATARS_SMALL };
|
|
export { DEFAULT_AVATARS_SMALL_MAX_SIZE };
|
|
export { DEFAULT_PROVISIONAL_AVATARS };
|
|
export { canUseWebp as SUPPORTS_WEBP };
|
|
export const LEGACY_DEFAULT_AVATAR_COUNT = 5;
|
|
export const DEFAULT_AVATAR_COUNT = 6;
|
|
export { getDefaultAvatarURL };
|
|
export { getUserAvatarURL };
|
|
export { getGuildMemberAvatarURLSimple };
|
|
export function isAnimatedImageURL(a0) {
|
|
let r2 = a0 != null;
|
|
if (r2) {
|
|
const r6 = _getAssetHash(a0);
|
|
r2 = r6 != null && r6.startsWith("a_");
|
|
}
|
|
return r2;
|
|
}
|
|
export function isVideoURL(a0) {
|
|
let r2 = a0 != null;
|
|
if (r2) {
|
|
const r6 = _getAssetHash(a0);
|
|
r2 = r6 != null && r6.startsWith("v_");
|
|
}
|
|
return r2;
|
|
}
|