decord/alpha/source/modules/recent_avatars/RecentAvatarUtils.tsx
github-actions c6aa9eb120 chore: update source for alpha 349.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5030.js (118.4 MB)
2026-10-01 06:55:13 +00:00

228 lines
6.5 KiB
TypeScript

// Module ID: 7796
// Function ID: 7797
// Name: RecentAvatarUtils
// Dependencies: [1074, 1397, 1432, 1473, 1115, 6596, 1370, 2]
// Exports: generateAvatarDescription, generateRecentAvatarFileDetails, getImageFormat, getPendingAvatarSrc
// Module 7796 (RecentAvatarUtils)
import Constants from "Constants" /* 1074 */;
import AvatarUtils from "AvatarUtils" /* 1397 */;
import ImageLoaderUtils from "ImageLoaderUtils" /* 1432 */;
import _modDef1473 from "module_1473" /* 1473 */;
import ProfilePendingImageTypes from "ProfilePendingImageTypes" /* 6596 */;
import size from "module_2" /* 2 */;
function getArchivedAvatarURL(allowWebp) {
({ userId, avatarId, storageHash, canAnimate } = allowWebp);
if (canAnimate === undefined) {
canAnimate = false;
}
let flag = allowWebp.allowWebp;
if (flag === undefined) {
flag = true;
}
if (null != CDN_HOST) {
const _HermesInternal = HermesInternal;
let combined = "https://" + CDN_HOST;
} else {
const _location = location;
const _window = window;
combined = location.protocol + window.GLOBAL_ENV.API_ENDPOINT;
}
let flag2 = canAnimate;
if (canAnimate === undefined) {
flag2 = false;
}
if (flag === undefined) {
flag = true;
}
if (flag2) {
if (obj.isAnimatedIconHash(storageHash)) {
let str6 = "gif";
if (flag) {
str6 = "gif";
if (tmp2(1397).SUPPORTS_WEBP) {
str6 = "webp";
}
}
let str2 = str6;
}
const obj2 = { size: null };
obj = AvatarUtils;
tmp2 = require;
const tmp6 = require;
const obj3 = ImageLoaderUtils;
obj2.size = obj3.getBestMediaProxySize(allowWebp.size * ImageLoaderUtils.getDevicePixelRatio());
let isAnimatedIconHashResult = "webp" === str2 && canAnimate;
if (isAnimatedIconHashResult) {
isAnimatedIconHashResult = tmp6(1397).isAnimatedIconHash(storageHash);
const tmp6Result = tmp6(1397);
}
if (isAnimatedIconHashResult) {
obj2.animated = true;
}
const ARCHIVED_AVATARResult = Endpoints.ARCHIVED_AVATAR(userId, avatarId, storageHash, str2);
const _HermesInternal2 = HermesInternal;
return "" + combined + ARCHIVED_AVATARResult + "?" + _modDef1473.stringify(obj2);
}
str2 = "jpg";
if (null != window.GLOBAL_ENV.CDN_HOST) {
let str4 = "png";
if (flag) {
str4 = "png";
if (AvatarUtils.SUPPORTS_WEBP) {
str4 = "webp";
}
}
str2 = str4;
}
}
const Endpoints = Constants.Endpoints;
const result = size.fileFinishedImporting("modules/recent_avatars/RecentAvatarUtils.tsx");
export const getImageFormat = function getImageFormat(canAnimate) {
let flag = canAnimate.canAnimate;
if (flag === undefined) {
flag = false;
}
let flag2 = canAnimate.allowWebp;
if (flag2 === undefined) {
flag2 = true;
}
if (flag) {
if (obj.isAnimatedIconHash(canAnimate.storageHash)) {
let str5 = "gif";
if (flag2) {
str5 = "gif";
if (AvatarUtils.SUPPORTS_WEBP) {
str5 = "webp";
}
}
let str = str5;
}
return str;
}
str = "jpg";
if (null != window.GLOBAL_ENV.CDN_HOST) {
let str3 = "png";
if (flag2) {
str3 = "png";
if (AvatarUtils.SUPPORTS_WEBP) {
str3 = "webp";
}
}
str = str3;
}
};
export { getArchivedAvatarURL };
export const generateAvatarDescription = function generateAvatarDescription(arg0) {
let obj = arg0;
if (arg0 == null) {
obj = {};
}
({ filename, assetOrigin } = obj);
if (undefined === assetOrigin) {
assetOrigin = ProfilePendingImageTypes.AssetOriginTypes.NEW_ASSET;
}
if (assetOrigin !== ProfilePendingImageTypes.AssetOriginTypes.ARCHIVED_ASSET) {
if (filename == null) {
const intl = tmp3(1115).intl;
filename = intl.string(tmp3(1115).t.lqaIxI);
}
const _Date = Date;
const date = new Date();
const intl2 = tmp3(1115).intl;
if (assetOrigin === tmp3(6596).AssetOriginTypes.EDITED_ARCHIVED_ASSET) {
let DYil93 = tmp3(1115).t.eC2sZi;
} else {
DYil93 = tmp3(1115).t.DYil93;
}
const obj2 = { name: filename, dateTime: date.toLocaleString(tmp3(1115).intl.currentLocale, { year: "numeric", day: "numeric", month: "long", hour: "numeric", minute: "numeric" }) };
return intl2.formatToPlainString(DYil93, obj2);
}
};
export const generateRecentAvatarFileDetails = function generateRecentAvatarFileDetails(storageHash, arg1) {
let flag = AvatarUtils.SUPPORTS_WEBP;
if (flag === undefined) {
flag = true;
}
if (tmpResult.isAnimatedIconHash(storageHash)) {
let str5 = "gif";
if (flag) {
str5 = "gif";
if (tmp(1397).SUPPORTS_WEBP) {
str5 = "webp";
}
}
let str = str5;
} else {
const _window = window;
str = "jpg";
if (null != window.GLOBAL_ENV.CDN_HOST) {
let str3 = "png";
if (flag) {
str3 = "png";
if (tmp(1397).SUPPORTS_WEBP) {
str3 = "webp";
}
}
str = str3;
}
}
if (null == arg1) {
const intl = tmp(1115).intl;
let stringResult = intl.string(tmp(1115).t.lqaIxI);
} else {
stringResult = arg1.split(",")[0];
}
const obj = { filename: "" + stringResult + "." + str, type: null };
if ("gif" === str) {
let str9 = "image/gif";
} else if ("png" === str) {
str9 = "image/png";
} else if ("jpg" === str) {
str9 = "image/jpeg";
} else {
str9 = "image/webp";
if ("webp" !== str) {
tmp(1370).assertNever(str);
const tmpResult2 = tmp(1370);
}
}
obj.type = str9;
return obj;
};
export const getPendingAvatarSrc = function getPendingAvatarSrc(canAnimate) {
({ userId, image, size } = canAnimate);
if (size === undefined) {
size = 80;
}
let flag = canAnimate.canAnimate;
if (flag === undefined) {
flag = true;
}
let tmp = image;
if (null != image) {
tmp = image;
if (typeof image !== "string") {
if (image.assetOrigin === ProfilePendingImageTypes.AssetOriginTypes.ARCHIVED_ASSET) {
const obj = { userId, avatarId: null, storageHash: null, size: null, canAnimate: null };
userId = image.originalAsset.id;
obj.avatarId = userId;
image = image.originalAsset.storageHash;
obj.storageHash = image;
obj.size = size;
obj.canAnimate = flag;
let imageUri = getArchivedAvatarURL(obj);
} else if (flag) {
imageUri = image.imageUri;
} else {
imageUri = image.staticImageUri;
if (imageUri == null) {
imageUri = image.imageUri;
}
}
}
}
return tmp;
};