decord/source/modules/calls/native/VideoBackground.tsx

266 lines
8.1 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 8452
// Function ID: 8453
2026-07-20 16:05:17 +00:00
// Name: useDominantRGBFromImage
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 19, 17, 676, 21, 4668, 12, 8453, 8454, 4227, 712, 1367, 8455, 8460, 8456, 1297, 4761, 2]
2026-07-29 08:29:29 +00:00
// Exports: useDominantColorFromImage
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 8452 (useDominantRGBFromImage)
import closure_3 from "_slicedToArray" /* 32 */;
import importAllResult from "noop" /* 19 */;
import get_ActivityIndicator from "get ActivityIndicator" /* 17 */;
import ME from "ME" /* 676 */;
import jsxProd from "jsxProd" /* 21 */;
import createCacheKey from "createCacheKey" /* 4668 */;
import importDefaultResult from "apply" /* 12 */;
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
function useDominantRGBFromImage(arg0, arg1) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
let first = arg1;
2026-07-20 16:05:17 +00:00
let tmp = arg1;
if (Array.isArray(arg1)) {
2026-07-23 10:11:24 +00:00
first = arg1[0];
2026-07-20 16:05:17 +00:00
tmp = first;
}
2026-08-24 06:08:38 +00:00
let tmp5 = first(8453)();
dependencyMap = tmp5;
2026-07-20 16:05:17 +00:00
let hexToRgbResult;
if (null != arg0) {
2026-08-24 06:08:38 +00:00
hexToRgbResult = tmp3(8454).cachedDominantColors[arg0];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (hexToRgbResult == null) {
2026-08-24 06:08:38 +00:00
hexToRgbResult = _require(4227).hexToRgb(tmp3(712).unsafe_rawColors.PRIMARY_800);
const obj2 = _require(4227);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const tmp8 = callback(importAllResult.useState(hexToRgbResult), 2);
callback = tmp8[1];
const items = [tmp, arg0, tmp5];
2026-07-20 16:05:17 +00:00
const effect = importAllResult.useEffect(() => {
2026-07-29 08:29:29 +00:00
let tmp2 = null != first;
if (tmp2) {
tmp2 = null != closure_0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-08-24 06:08:38 +00:00
if (null == first(table[8]).cachedDominantColors[closure_0]) {
2026-08-04 21:03:28 +00:00
if (typeof tmp === "number") {
2026-08-24 06:08:38 +00:00
const ImageManager = closure_1_6.ImageManager;
let dominantColorsLocalAsset = ImageManager.getDominantColorsLocalAsset(closure_1_7.resolveAssetSource(tmp));
2026-07-29 08:29:29 +00:00
} else {
2026-08-24 06:08:38 +00:00
const ImageManager2 = closure_1_6.ImageManager;
dominantColorsLocalAsset = ImageManager2.getDominantColors(closure_1_7.resolveAssetSource(tmp));
2026-07-20 16:05:17 +00:00
}
dominantColorsLocalAsset.then((arg0) => {
2026-07-29 08:29:29 +00:00
if (callback()) {
const obj = { r: null, g: null, b: null };
2026-08-24 06:08:38 +00:00
[obj[0], obj[1], obj[2]] = closure_1_3(arg0[0], 3);
2026-07-29 08:29:29 +00:00
callback2(obj);
2026-08-24 06:08:38 +00:00
closure_1_1(closure_1_2[8]).cachedDominantColors[closure_0] = obj;
const tmp3 = closure_1_3(arg0[0], 3);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
}).catch(closure_1_9);
2026-07-20 16:05:17 +00:00
const nextPromise = dominantColorsLocalAsset.then((arg0) => {
2026-07-29 08:29:29 +00:00
if (callback()) {
const obj = { r: null, g: null, b: null };
2026-08-24 06:08:38 +00:00
[obj[0], obj[1], obj[2]] = closure_1_3(arg0[0], 3);
2026-07-29 08:29:29 +00:00
callback2(obj);
2026-08-24 06:08:38 +00:00
closure_1_1(closure_1_2[8]).cachedDominantColors[closure_0] = obj;
const tmp3 = closure_1_3(arg0[0], 3);
2026-07-20 16:05:17 +00:00
}
});
} else {
2026-07-29 08:29:29 +00:00
callback(tmp4(tmp5[8]).cachedDominantColors[tmp6]);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp4 = first;
2026-08-24 06:08:38 +00:00
tmp5 = table;
2026-07-20 16:05:17 +00:00
}
}, items);
2026-07-29 08:29:29 +00:00
return tmp8[0];
2026-07-20 16:05:17 +00:00
}
class VideoBackground {
constructor(arg0) {
({ url, isStageCall } = global);
if (isStageCall === undefined) {
isStageCall = false;
}
({ user, guildId } = global);
renderVideoDetails = global.renderVideoDetails;
2026-07-29 08:29:29 +00:00
merged = Object.assign(global, Object.create(null));
2026-08-24 06:08:38 +00:00
closure_1 = undefined;
closure_2 = undefined;
tmp2 = closure_12();
tmp3 = closure_13(url);
2026-07-29 08:29:29 +00:00
tmp4 = useDominantRGBFromImage(url, tmp3);
combined = "rgb(" + tmp4.r + ", " + tmp4.g + ", " + tmp4.b + ")";
2026-08-24 06:08:38 +00:00
tmp6 = closure_1;
tmp7 = closure_2;
2026-07-29 08:29:29 +00:00
tmp8 = require("useIsMobileVisualRefreshExperimentEnabled")("VideoBackground-native");
2026-08-24 06:08:38 +00:00
closure_1 = tmp8;
2026-07-20 16:05:17 +00:00
id = undefined;
2026-07-29 08:29:29 +00:00
if (user != null) {
2026-07-20 16:05:17 +00:00
id = user.id;
}
2026-07-29 08:29:29 +00:00
if (id == null) {
2026-07-20 16:05:17 +00:00
id = EMPTY_STRING_SNOWFLAKE_ID;
}
2026-08-24 06:08:38 +00:00
closure_2 = id;
2026-07-29 08:29:29 +00:00
tmp10 = require("useDisplayProfile")(id, guildId);
2026-07-20 16:05:17 +00:00
first = undefined;
2026-07-29 08:29:29 +00:00
if (tmp10 != null) {
themeColors = tmp10.themeColors;
if (themeColors != null) {
2026-07-20 16:05:17 +00:00
first = themeColors[0];
}
}
2026-07-29 08:29:29 +00:00
if (first == null) {
first = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp12 = undefined;
if (tmp10 != null) {
themeColors2 = tmp10.themeColors;
if (themeColors2 != null) {
tmp12 = themeColors2[1];
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (tmp12 == null) {
tmp12 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp13 = tmp8;
if (tmp8) {
tmp13 = null != first;
2026-07-20 16:05:17 +00:00
}
if (tmp13) {
tmp13 = null != tmp12;
}
2026-07-29 08:29:29 +00:00
tmp14 = guildId;
obj = require("rgbToHex");
tmp15 = null;
2026-07-20 16:05:17 +00:00
if (tmp13) {
2026-07-29 08:29:29 +00:00
tmp15 = first;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp16 = null;
2026-07-20 16:05:17 +00:00
if (tmp13) {
2026-07-29 08:29:29 +00:00
tmp16 = tmp12;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
videoTileGradientColors = obj.useVideoTileGradientColors(tmp15, tmp16);
2026-07-20 16:05:17 +00:00
items = [, , ];
2026-07-29 08:29:29 +00:00
items[0] = tmp8;
2026-07-20 16:05:17 +00:00
items[1] = id;
items[2] = guildId;
2026-08-24 06:08:38 +00:00
effect = closure_4.useEffect(() => {
let tmp2 = id !== closure_1_8;
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-08-24 06:08:38 +00:00
tmp2 = callback;
2026-07-29 08:29:29 +00:00
}
if (tmp2) {
const obj = { guildId: null, dispatchWait: true };
obj[0] = guildId;
2026-08-24 06:08:38 +00:00
callback(id[14])(id, undefined, obj);
2026-07-20 16:05:17 +00:00
}
}, items);
2026-07-29 08:29:29 +00:00
if (null == tmp3) {
2026-07-20 16:05:17 +00:00
return null;
} else {
renderVideoDetailsResult = undefined;
2026-07-29 08:29:29 +00:00
if (renderVideoDetails != null) {
2026-07-20 16:05:17 +00:00
renderVideoDetailsResult = renderVideoDetails();
}
2026-07-29 08:29:29 +00:00
if (renderVideoDetailsResult == null) {
renderVideoDetailsResult = null;
2026-07-20 16:05:17 +00:00
}
items1 = [, , , ];
items1[0] = global.style;
2026-07-29 08:29:29 +00:00
items1[1] = tmp2.videoBackground;
2026-07-20 16:05:17 +00:00
tmp20 = null;
if (!tmp13) {
2026-07-29 08:29:29 +00:00
obj = { backgroundColor: null };
obj[0] = combined;
2026-07-20 16:05:17 +00:00
tmp20 = obj;
}
items1[2] = tmp20;
videoDetailsSpacer = null;
2026-07-29 08:29:29 +00:00
if (null != renderVideoDetailsResult) {
videoDetailsSpacer = tmp2.videoDetailsSpacer;
2026-07-20 16:05:17 +00:00
}
items1[3] = videoDetailsSpacer;
tmp22 = null;
if (isStageCall) {
tmp22 = null;
if (!tmp13) {
2026-07-29 08:29:29 +00:00
obj1 = { backgroundColor: null };
obj1[0] = combined;
2026-07-20 16:05:17 +00:00
tmp22 = obj1;
}
}
tmp23 = jsx;
2026-07-29 08:29:29 +00:00
obj2 = { source: null };
obj2[0] = tmp3;
tmp24 = obj2;
tmp25 = merged;
2026-07-20 16:05:17 +00:00
merged1 = Object.assign(merged);
items2 = [, ];
items2[0] = global.avatarStyle;
items2[1] = tmp22;
2026-07-29 08:29:29 +00:00
obj2.avatarStyle = items2;
obj2.isStageCall = isStageCall;
tmp27 = jsx(require("Button").Avatar, obj2);
2026-07-20 16:05:17 +00:00
if (null != videoTileGradientColors) {
2026-07-29 08:29:29 +00:00
tmp31 = jsxs;
obj3 = { colors: null, start: null, end: null, style: null, children: null };
obj3[0] = videoTileGradientColors;
obj3[1] = { x: 0, y: 0 };
obj3[2] = { x: 0, y: 1 };
obj3[3] = items1;
2026-07-20 16:05:17 +00:00
items3 = [, ];
2026-07-29 08:29:29 +00:00
items3[0] = tmp27;
items3[1] = renderVideoDetailsResult;
obj3[4] = items3;
tmp30 = jsxs(require("LinearGradient"), obj3);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
tmp28 = jsxs;
tmp29 = View;
obj4 = { style: null, children: null };
obj4[0] = items1;
2026-07-20 16:05:17 +00:00
items4 = [, ];
2026-07-29 08:29:29 +00:00
items4[0] = tmp27;
items4[1] = renderVideoDetailsResult;
obj4[1] = items4;
tmp30 = jsxs(View, obj4);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp30;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
let c4 = importAllResult;
({ View: c5, NativeModules: closure_6, Image: error } = get_ActivityIndicator);
2026-08-24 06:08:38 +00:00
({ EMPTY_STRING_SNOWFLAKE_ID: closure_8, NOOP: c9 } = ME);
2026-07-29 08:29:29 +00:00
({ jsx: c10, jsxs: unpackModuleId } = jsxProd);
let closure_12 = createCacheKey.createStyles({ videoBackground: { alignItems: "center" }, videoDetailsSpacer: { paddingTop: 12 } });
2026-08-24 06:08:38 +00:00
const memoizeResult = importDefaultResult.memoize((num) => {
2026-07-20 16:05:17 +00:00
let tmp = null;
2026-08-04 21:03:28 +00:00
if (null != num) {
2026-07-20 16:05:17 +00:00
tmp = null;
2026-08-04 21:03:28 +00:00
if ("" !== num) {
let tmp2 = num;
if (typeof num !== "number") {
2026-07-29 08:29:29 +00:00
const obj = { uri: null };
2026-08-04 21:03:28 +00:00
obj[0] = num;
2026-07-20 16:05:17 +00:00
tmp2 = obj;
}
tmp = tmp2;
}
}
return tmp;
});
2026-07-23 10:11:24 +00:00
VideoBackground.AvatarSizes = require("Button").AvatarSizes;
const memoResult = importAllResult.memo(VideoBackground);
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/calls/native/VideoBackground.tsx");
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
export default memoResult;
export const AvatarSizes = require("Button").AvatarSizes;
2026-07-20 16:05:17 +00:00
export const memoizedImageSource = memoizeResult;
export { useDominantRGBFromImage };
2026-07-29 08:29:29 +00:00
export const useDominantColorFromImage = function useDominantColorFromImage(arg0, arg1) {
const tmp = useDominantRGBFromImage(arg0, arg1);
return "rgb(" + tmp.r + ", " + tmp.g + ", " + tmp.b + ")";
};