This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,59 @@
// Metro module 4767 (f4768).
export async function getDetectedFileSize(c25293_0) {
let promise, size;
let c25293_3;
let c25293_4 = 0;
L12: {
try {
let c29437_0 = c25293_0;
if (c25293_0.size > 0) {
size = c25293_0.size;
break L12;
}
c25293_4 = 1;
promise = await new Promise((c31357_0, c31357_1) => {
const fileReader = new FileReader();
let c31357_2 = setTimeout(() => {
c31357_1(new Error("File read timeout"));
}, 10000);
fileReader.onload = (a0) => {
clearTimeout(c31357_2);
const result = a0.target?.result;
if (result instanceof ArrayBuffer) {
c31357_0(result.byteLength);
} else {
c31357_1(new Error("Unexpected FileReader result type"));
}
};
fileReader.onerror = () => {
clearTimeout(c31357_2);
c31357_1(new Error("Could not read file"));
};
fileReader.readAsArrayBuffer(c29437_0);
});
c25293_4 = 0;
} catch ($e) {
const r23 = $e;
let r8 = r23;
c25293_3 = r23;
if (c25293_4 !== 0) {
while (true) {
try {
c25293_4 = 0;
} catch (r49) {
r8 = r49;
c25293_3 = r49;
if (c25293_4 === 0) {
break;
}
continue;
}
return 0;
}
}
throw r8;
}
return promise;
}
return size;
}
@@ -0,0 +1,113 @@
// Metro module 4756 (f4757).
import { CompressionQuality } from "../../Constants";
let c2909_1, c2909_2;
const getAdaptiveImageCompressionQuality = function getAdaptiveImageCompressionQuality(a0, a1) {
let r17;
if (a1.useAdaptiveCompression) {
if (a0.width != null && a0.height != null) {
const r12 = a0.width * a0.height;
if (r12 <= c2909_1.SMALL) {
let veryHighQuality = a1.veryHighQuality;
if (veryHighQuality == null) {
veryHighQuality = CompressionQuality.HIGH;
}
r17 = veryHighQuality;
} else if (r12 <= c2909_1.MEDIUM) {
let highQuality = a1.highQuality;
if (highQuality == null) {
highQuality = CompressionQuality.HIGH;
}
r17 = highQuality;
} else if (r12 <= c2909_1.LARGE) {
let mediumQuality = a1.mediumQuality;
if (mediumQuality == null) {
mediumQuality = CompressionQuality.HIGH;
}
r17 = mediumQuality;
} else if (r12 <= c2909_1.VERY_LARGE) {
let lowQuality = a1.lowQuality;
if (lowQuality == null) {
lowQuality = CompressionQuality.HIGH;
}
r17 = lowQuality;
} else {
r17 = a1.veryLowQuality;
if (r17 == null) {
r17 = CompressionQuality.HIGH;
}
}
return r17;
}
return CompressionQuality.HIGH;
}
return CompressionQuality.HIGH;
};
c2909_1 = {
SMALL: 921600,
MEDIUM: 2073600,
LARGE: 3686400,
VERY_LARGE: 8294400
};
c2909_2 = {
useAdaptiveCompression: true,
veryHighQuality: 0.8,
highQuality: 0.7,
mediumQuality: 0.6,
lowQuality: 0.5,
veryLowQuality: 0.4,
useOriginalIfSmaller: true
};
class ImageEncodingLadder {
constructor() {
return {
__proto__: new.target.prototype
};
}
static selectEncodingConfig(a0) {
let r21;
const r4 = ImageEncodingLadder.clampDimensions(a0.width, a0.height, 3840, 2160);
const { targetWidth, targetHeight } = r4;
if (a0.width === targetWidth && a0.height === targetHeight) {
r21 = {
compressionQuality: 100 * getAdaptiveImageCompressionQuality({
width: targetWidth,
height: targetHeight
}, c2909_2),
targetWidth,
targetHeight
};
} else {
let lowQuality = c2909_2.lowQuality;
if (lowQuality == null) {
lowQuality = 0.5;
}
r21 = {
compressionQuality: 100 * lowQuality,
targetWidth,
targetHeight
};
}
return r21;
}
static clampDimensions(a0, a1, a2, a3) {
const r9 = Math.max(a0, a1);
const r8 = Math.min(a0, a1);
const r15 = Math.max(a2, a3);
const r17 = Math.min(a2, a3);
if (r9 <= r15 && r8 <= r17) {
return {
targetWidth: a0,
targetHeight: a1
};
}
const r22 = Math.min(r15 / r9, r17 / r8);
return {
targetWidth: Math.max(1, Math.round(a0 * r22)),
targetHeight: Math.max(1, Math.round(a1 * r22))
};
}
}
export { c2909_1 as IMAGE_COMPRESSION_THRESHOLDS };
export { c2909_2 as ADAPTIVE_COMPRESSION_CONFIG };
export { getAdaptiveImageCompressionQuality };
export { ImageEncodingLadder };
@@ -0,0 +1,21 @@
// Metro module 6189 (f6190).
export function buildFileSizeLimitEventProperties(a0) {
const { guildId, channelId, userIndividualFileSizeLimit, numAttachments, preCompressionFileSizes, preCompressionAggregateSize } = a0;
return {
...channelId !== void 0 ? {
channel_id: channelId
} : {},
...guildId !== void 0 ? {
guild_id: guildId
} : {},
user_individual_file_size_limit: userIndividualFileSizeLimit,
num_attachments: numAttachments,
pre_compression_file_sizes: preCompressionFileSizes,
pre_compression_aggregate_file_size: preCompressionAggregateSize,
post_compression_file_sizes: a0.postCompressionFileSizes,
post_compression_aggregate_file_size: a0.postCompressionAggregateSize,
attachment_mimetypes: a0.attachmentMimeTypes,
error_type: a0.errorType,
kestrel_variant: a0.kestrelVariant
};
}
@@ -0,0 +1,21 @@
// Metro module 7995 (f7996).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-02-android-exoplayer-http-engine",
kind: "user",
defaultConfig: {
httpEngine: "default"
},
variations: {
0: {
httpEngine: "default"
},
1: {
httpEngine: "okhttp"
},
2: {
httpEngine: "cronet"
}
}
});
export { apexExperiment as AndroidExoPlayerHttpEngineExperiment };
@@ -0,0 +1,21 @@
// Metro module 4758 (f4759).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-04-attachment-quality-metrics",
kind: "user",
defaultConfig: {
enableQualityMetrics: false,
enableOriginDetection: false
},
variations: {
0: {
enableQualityMetrics: false,
enableOriginDetection: false
},
1: {
enableQualityMetrics: true,
enableOriginDetection: true
}
}
});
export { apexExperiment as AttachmentQualityMetricsExperiment };
@@ -0,0 +1,27 @@
// Metro module 4769 (f4770).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2025-09-image-attachment-mezzanine-v2",
kind: "user",
defaultConfig: {
enabled: false
},
variations: {
0: {
enabled: false
},
1: {
enabled: true,
maxFileSizeBytes: 524288
},
2: {
enabled: true,
maxFileSizeBytes: 262144
}
}
});
export function getImageAttachmentMezzanineV2Config(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,22 @@
// Metro module 4759 (f4760).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2025-11-enhanced-jpeg-encoding-on-ios",
kind: "user",
defaultConfig: {
useJpegliEncoder: false
},
variations: {
0: {
useJpegliEncoder: false
},
1: {
useJpegliEncoder: true
}
}
});
export function getIosJpegliConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,39 @@
// Metro module 4768 (f4769).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-04-kestrel",
kind: "user",
defaultConfig: {
enabled: false,
threshold: 0
},
variations: {
0: {
enabled: false,
threshold: 0
},
1: {
enabled: true,
threshold: 15
},
2: {
enabled: true,
threshold: 20
},
3: {
enabled: true,
threshold: 25
}
}
});
export function getKestrelConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
export function getEffectiveKestrelLimit(a0, a1) {
return a0.enabled ? Math.max(1048576 * a0.threshold, a1) : a1;
}
export function getKestrelVariantName(a0) {
return a0.enabled ? a0.threshold !== 15 ? a0.threshold !== 20 ? a0.threshold === 25 ? "kestrel_c" : "unknown" : "kestrel_b" : "kestrel_a" : "control";
}
@@ -0,0 +1,22 @@
// Metro module 4760 (f4761).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-01-image-optimized-encoding-ladder",
kind: "user",
defaultConfig: {
useImageEncodingLadder: false
},
variations: {
0: {
useImageEncodingLadder: false
},
1: {
useImageEncodingLadder: true
}
}
});
export function getMobileImageEncodingLadderConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,22 @@
// Metro module 4755 (f4756).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2025-10-video-frame-rate-validation",
kind: "user",
defaultConfig: {
enableFrameRateValidation: false
},
variations: {
0: {
enableFrameRateValidation: false
},
1: {
enableFrameRateValidation: true
}
}
});
export function getVideoFrameRateValidationExperimentConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,28 @@
// Metro module 12608 (f12609).
import { AbortCodes } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import { MAX_TOTAL_ATTACHMENT_SIZE_MB } from "../../utils/UploadUtils";
export function getAttachmentUploadAbortAlertContent(a0) {
const title = intl.string(t.B3vFdU);
if (AbortCodes.TOTAL_ATTACHMENT_SIZE_TOO_LARGE === a0) {
return {
title,
body: intl.formatToPlainString(t.DYFPg2, {
maxSizeMb: MAX_TOTAL_ATTACHMENT_SIZE_MB
})
};
}
if (AbortCodes.CLOUD_UPLOAD_NOT_FOUND === a0) {
return {
title,
body: intl.string(t.bQldfH)
};
}
if (AbortCodes.INVALID_PERMISSIONS === a0) {
return {
title,
body: intl.string(t.zl4Weq)
};
}
return null;
}
@@ -0,0 +1,33 @@
// Metro module 6190 (f6191).
function $mk77968() {
return (a0, a1) => a0 + a1;
}
const sum = (a0) => {};
export function getUploaderChannelId({ items }) {
let r5 = items == null ? void 0 : items[0]?.channelId;
if (r5 == null) {
r5 = null;
}
return r5;
}
export function getUploaderFileSizeMetrics(a0) {
let items = a0.items;
if (items == null) {
items = [];
}
const preCompressionFileSizes = items.map((item) => item.preCompressionSize);
const postCompressionFileSizes = items.map((item) => {
let postCompressionSize = item.postCompressionSize;
if (postCompressionSize == null) {
postCompressionSize = item.preCompressionSize;
}
return postCompressionSize;
});
return {
preCompressionFileSizes,
postCompressionFileSizes,
preCompressionAggregateSize: a0.totalPreCompressionSize > 0 ? a0.totalPreCompressionSize : preCompressionFileSizes.reduce($mk77968(), 0),
postCompressionAggregateSize: a0.totalPostCompressionSize != null && a0.totalPostCompressionSize > 0 ? a0.totalPostCompressionSize : postCompressionFileSizes.reduce($mk77968(), 0),
numAttachments: a0.attachmentsCount > 0 ? a0.attachmentsCount : items.length
};
}
@@ -0,0 +1,58 @@
// Metro module 6187 (f6188).
import { AbortCodes, MAX_UPLOAD_COUNT } from "../../Constants";
import { getKestrelConfig, getEffectiveKestrelLimit } from "./experiments/KestrelExperiment";
import { maxFileSize } from "../../utils/FileUtils";
import showUploadFileSizeError from "./native/showUploadFileSizeError";
import AlertActionCreators from "../../actions/AlertActionCreators";
import { intl, t } from "../../intl/index.native";
import { getAttachmentUploadAbortAlertContent } from "./getAttachmentUploadAbortAlert";
export function handleUploadMessageAttachmentsErrors({ file, guildId, analyticsLocations, code, reason }) {
if (code === void 0) {
return false;
}
if (code === AbortCodes.ENTITY_TOO_LARGE) {
const kestrelConfig = getKestrelConfig({
location: "native.handleUploadMessageAttachmentsErrors"
});
const baseMaxSize = maxFileSize(guildId);
showUploadFileSizeError({
file,
maxSize: getEffectiveKestrelLimit(kestrelConfig, baseMaxSize),
baseMaxSize,
guildId,
analyticsLocations,
errorReason: reason?.type
});
return true;
}
if (code === AbortCodes.TOO_MANY_ATTACHMENTS) {
AlertActionCreators.show({
title: intl.string(t.wOr6hB),
body: intl.formatToPlainString(t["qqyp/e"], {
limit: MAX_UPLOAD_COUNT
})
});
return true;
}
if (code === AbortCodes.ENTITY_EMPTY) {
AlertActionCreators.show({
title: intl.string(t.B3vFdU),
body: intl.string(t["9ZpT2C"])
});
return true;
}
if (code === AbortCodes.INVALID_FILE_ASSET) {
AlertActionCreators.show({
title: intl.string(t.B3vFdU),
body: intl.string(t.zMEjJg)
});
return true;
}
const attachmentUploadAbortAlertContent = getAttachmentUploadAbortAlertContent(code);
let r25 = attachmentUploadAbortAlertContent != null;
if (r25) {
AlertActionCreators.show(attachmentUploadAbortAlertContent);
r25 = true;
}
return r25;
}
@@ -0,0 +1,64 @@
// Metro module 4752 (f4753).
import { isIOS } from "../../../utils/PlatformUtils";
import IosImageTypesManager from "../../media/native/IosImageTypesManager";
export function isPhotoKitAsset(a0, a1) {
return a0.match(/^ph:\/\//i) != null && a1 != null;
}
export function isHeicUTI(a0) {
if (a0 == null) {
return false;
}
const r4 = a0.toLowerCase();
return r4.includes("heic") || r4.includes("heif");
}
export function shouldForceConvertToJPG(a0, a1, a2) {
let r16 = !!isIOS();
if (r16) {
const r1 = a2 == null;
let r17 = false;
if (!r1) {
const r10 = a2.toLowerCase();
r17 = r10.includes("heic") || r10.includes("heif");
}
r16 = !!r17 || (a0.match(/^ph:\/\//i) != null && a1 != null ? (a1 == null ? void 0 : a1.match(/\.HEI[CF]$/i)) != null : a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)(HEI[CF])$/i) != null);
}
return r16;
}
export function shouldConvertToJPG(a0, a1, a2, a3, r8 = true) {
if (isIOS()) {
let r12 = a1 == null ? void 0 : a1.lastIndexOf(".");
if (r12 == null) {
r12 = -1;
}
const r21 = r12 !== -1 ? a1.substring(r12 + 1).toLowerCase() : void 0;
const match = a0.match;
if (r8) {
if (match.call(a0, /^ph:\/\//i) != null && a1 != null) {
if (r21 == null) {
return false;
}
if (r21 === "png") {
if (a3) {
return true;
}
if (a2) {
return true;
}
} else {
if (IosImageTypesManager.isExtensionAnimated(r21)) {
return false;
}
const supportedExtensions = IosImageTypesManager.getSupportedExtensions();
if (supportedExtensions !== null && supportedExtensions.has(r21)) {
return true;
}
}
return false;
}
return a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)(hei[cf]|jpe?g|dng)$/i) != null || !(a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)png$/i) == null || (a2 ? !a2 : !a3));
}
const r3 = match.call(a0, /(&ext=|\.)(hei[cf])$/i) != null;
return r21 === "heic" || r21 === "heif" || r3;
}
return false;
}
@@ -0,0 +1,214 @@
// Metro module 9671 (f9672).
import { useMemo, useCallback, useState } from "react";
import { Image as Image2, View } from "react-native";
import { DraftType } from "../../../stores/DraftStore";
import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import Module38 from "../../../_bundle/Module38";
import { UploadPlatform } from "../../../lib/uploader/Upload";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import useMountEffect from "../../../hooks/useMountEffect";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import ImagePicker from "../../image/native/ImagePicker";
import { cropResultToUploadItem } from "../../media_keyboard/native/MediaKeyboardUtils";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { CircleErrorIcon } from "../../../design/components/Icon/native/redesign/generated/CircleErrorIcon";
import { getCaptionLabel, getType } from "../../../utils/native/UploadUtils";
import useCanSetThumbnail from "../../media_channel/useCanSetThumbnail";
import useSetMediaPostThumbnail from "../../media_channel/native/useSetMediaPostThumbnail";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { BottomSheetScrollView } from "../../../_bundle/Module5245";
import { Stack } from "../../../design/components/Stack/native/Stack.native";
import { Text } from "../../../design/components/Text/native/Text";
import { isIOS } from "../../../utils/PlatformUtils";
import { VideoComponent } from "../../../components_native/common/Video";
import { Caption } from "../../media/native/Caption";
import { TableRowGroup } from "../../../design/components/TableRow/native/TableRowGroup.native";
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
import { ImageFileIcon } from "../../../design/components/Icon/native/redesign/generated/ImageFileIcon";
import AddImageDescriptionModalActionCreators from "../../image_upload/native/AddImageDescriptionModalActionCreators";
import { intl, t } from "../../../intl/index.native";
import { TableCheckboxRow } from "../../../design/components/TableRow/native/TableCheckboxRow.native";
import { SpoilerIcon } from "../../../design/components/Icon/native/redesign/generated/SpoilerIcon";
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
import { ImageIcon } from "../../../design/components/Icon/native/redesign/generated/ImageIcon";
import { PencilSparkleIcon } from "../../../design/components/Icon/native/redesign/generated/PencilSparkleIcon";
import { Button } from "../../../design/components/Button/native/Button.native";
import { TrashIcon } from "../../../design/components/Icon/native/redesign/generated/TrashIcon";
const useStyles = createStyles({
contentContainer: {
padding: 16
},
imageWrap: {
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
padding: Module712.space.PX_8,
borderRadius: Module712.radii.md,
width: "100%"
},
imageContainer: {
overflow: "hidden",
alignSelf: "center",
borderRadius: Module712.radii.md - Module712.space.PX_4
}
});
export default function UploadPreviewActionSheet(props) {
let r163;
let setState;
const { onAdd, onEdit, onRemove, channelId, onClose, disableAddDescription = false, disableSpoiler, upload } = props;
setState = void 0;
const styles = useStyles();
const { id, isVideo } = upload;
let isImage = upload.isImage;
const { isThumbnail: checked = false, item, spoiler } = upload;
Module38(item.platform === UploadPlatform.REACT_NATIVE, "Upload must be a React Native upload item.");
const width = useWindowDimensions_native().width;
const bottom = useSafeAreaInsets_native().bottom;
useMountEffect(() => () => {
if (onClose != null) {
onClose();
}
});
const memo2 = useMemo(() => {
const { height, width: width2 } = item;
const width3 = Math.min(width, ACTION_SHEET_MAX_WIDTH) - 2 * styles.contentContainer.padding - 2 * styles.imageWrap.padding;
if (height != null && width2 != null) {
if (height !== 0 && width2 !== 0) {
const r27 = width3 / Math.max(width2, height);
return {
width: width2 * r27,
height: height * r27
};
}
return {
width: 300,
height: 300
};
}
return {
width: width3,
height: width3
};
}, [width, item, styles]);
const callback2 = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
if (onRemove != null) {
onRemove(id);
}
}, [onRemove, id]);
const callback3 = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
if (onAdd != null) {
onAdd();
}
}, [onAdd]);
const callback = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
const { uri, width: width2, height } = item;
ImagePicker.launchCropper({
uri,
freeStyleCropEnabled: true,
width: width2 !== 0 ? width2 : void 0,
height: height !== 0 ? height : void 0
}).then((result) => {
if (onEdit != null) {
onEdit(cropResultToUploadItem(result));
}
}).catch((error) => {
if (error.code !== "E_PICKER_CANCELLED") {
ToastActionCreators.open({
key: "CROP_ERROR",
IconComponent: CircleErrorIcon,
content: error.message
});
}
});
}, [onEdit, item]);
const memo = useMemo(() => getCaptionLabel(getType(item.uri), isVideo, item), [isVideo, item]);
const r23 = isImage ? !disableAddDescription : isImage;
const r76 = checked ? !checked : !disableSpoiler;
let r24 = useCanSetThumbnail(channelId, upload);
const setMediaPostThumbnail = useSetMediaPostThumbnail(channelId, upload);
let state;
[state, setState] = useState(void 0);
const startHeight = state != null ? state + bottom + Module712.space.PX_32 + Module712.space.PX_16 : void 0;
if (isImage) {
isImage = onEdit != null;
}
const props2 = {
scrollable: true,
startHeight,
children: null
};
const props3 = {
contentContainerStyle: {
padding: Module712.space.PX_16,
paddingBottom: bottom
},
children: null
};
const props4 = {
spacing: 16,
onLayout: (a0) => {
setState(a0.nativeEvent.layout.height);
},
children: null
};
const children = [<Text variant="text-md/semibold">{item.filename}</Text>, , , ,];
const props5 = {
style: styles.imageWrap,
children: null
};
const props6 = {
style: [styles.imageContainer, {
width: memo2.width,
height: memo2.height
}],
children: null
};
const children2 = [isIOS() && (isVideo && item.uri.startsWith("file://")) ? <VideoComponent style={{
width: memo2.width,
height: memo2.height
}} source={{
uri: item.uri
}} muted paused preventsDisplaySleepDuringVideoPlayback={false} /> : <Image2 style={{
width: memo2.width,
height: memo2.height
}} source={item} />, ,];
const r155 = memo != null && memo !== "" && <Caption label={memo} />;
L34: {
children2[1] = r155;
props6.children = children2;
props5.children = <View {...props6} />;
children[1] = <View {...props5} />;
if (!r23 && !r76 && !r24) {
r163 = null;
if (!isImage) {
break L34;
}
}
const r187 = [r23 ? <TableRow icon={<ImageFileIcon />} onPress={() => AddImageDescriptionModalActionCreators.open({
source: item,
channelId,
id
})} label={intl.string(t["5S2AK+"])} arrow /> : null, r76 ? <TableCheckboxRow icon={<SpoilerIcon />} onPress={function onPress() {
ActionSheetActionCreators.hideActionSheet();
UploadAttachmentActionCreators.update(channelId, id, DraftType.ChannelMessage, {
spoiler: !spoiler
});
}} label={intl.string(t["gsI+xC"])} checked={spoiler} /> : null, , ,];
if (r24) {
r24 = <TableCheckboxRow icon={<ImageIcon />} label={intl.string(t.ews2pj)} onPress={setMediaPostThumbnail} checked={checked} />;
}
r187[2] = r24;
r187[3] = isImage ? <TableRow icon={<PencilSparkleIcon />} onPress={callback} label={intl.string(t.b0y3DL)} arrow /> : null;
r163 = <TableRowGroup hasIcons>{r187}</TableRowGroup>;
}
children[2] = r163;
children[3] = onRemove != null ? <Button icon={<TrashIcon size="sm" color="control-primary-text-default" />} text={intl.string(t["40jBO/"])} onPress={callback2} variant="destructive" /> : onAdd != null ? <Button icon={<ImageFileIcon size="sm" color="control-primary-text-default" />} text={intl.string(t.s7oPyG)} onPress={callback3} /> : null;
props4.children = children;
props3.children = <Stack {...props4} />;
props2.children = <BottomSheetScrollView {...props3} />;
return <BottomSheet {...props2} />;
};
@@ -0,0 +1,182 @@
// Metro module 4754 (f4755).
import { VideoCompressionQuality } from "../../user_settings/UnsyncedUserSettingsStore";
import Logger from "../../debug/Logger";
let c2907_1 = new Logger("VideoUploadUtils.tsx");
class VideoQualityTarget {
constructor(a0, a1, a2) {
this.value = a0;
this.targetResolution = a1;
this.targetBitrate = a2;
}
toString() {
return this.value;
}
}
const VERY_LOW = {
__proto__: VideoQualityTarget.prototype
};
VERY_LOW.value = "very_low";
VERY_LOW.targetResolution = 360;
VERY_LOW.targetBitrate = 800000;
VideoQualityTarget.VERY_LOW = VERY_LOW;
const LOW = {
__proto__: VideoQualityTarget.prototype
};
LOW.value = "low";
LOW.targetResolution = 360;
LOW.targetBitrate = 1200000;
VideoQualityTarget.LOW = LOW;
const MEDIUM = {
__proto__: VideoQualityTarget.prototype
};
MEDIUM.value = "medium";
MEDIUM.targetResolution = 480;
MEDIUM.targetBitrate = 1800000;
VideoQualityTarget.MEDIUM = MEDIUM;
const HIGH = {
__proto__: VideoQualityTarget.prototype
};
HIGH.value = "high";
HIGH.targetResolution = 720;
HIGH.targetBitrate = 2250000;
VideoQualityTarget.HIGH = HIGH;
const VERY_HIGH = {
__proto__: VideoQualityTarget.prototype
};
VERY_HIGH.value = "very_high";
VERY_HIGH.targetResolution = 1080;
VERY_HIGH.targetBitrate = 7000000;
VideoQualityTarget.VERY_HIGH = VERY_HIGH;
VideoQualityTarget.fromCompressionQuality = function fromCompressionQuality(a0) {
let VERY_LOW;
if (VideoCompressionQuality.VERY_LOW === a0) {
VERY_LOW = VideoQualityTarget.VERY_LOW;
} else if (VideoCompressionQuality.LOW === a0) {
VERY_LOW = VideoQualityTarget.LOW;
} else if (VideoCompressionQuality.MEDIUM === a0) {
VERY_LOW = VideoQualityTarget.MEDIUM;
} else if (VideoCompressionQuality.HIGH === a0) {
VERY_LOW = VideoQualityTarget.HIGH;
} else {
if (VideoCompressionQuality.VERY_HIGH !== a0) {
throw new Error(`Unknown compression quality: ${a0}`);
}
VERY_LOW = VideoQualityTarget.VERY_HIGH;
}
return VERY_LOW;
};
const r56 = {
bitrateFloor: 300000,
createHDR: false,
frameRate: 30,
keyFrameIntervalSeconds: 2,
rotationDegrees: 0,
skipVideoTranscode: false,
targetBitrate: VideoQualityTarget.MEDIUM.targetBitrate,
targetHeight: 480,
targetWidth: 640,
useHEVC: false,
videoQuality: VideoQualityTarget.MEDIUM,
hevcIsSupported: false,
useTranscodedVideoForMovSources: true,
transmuxLivePhotos: true,
progressUpdateGranularity: 10
};
export { VideoQualityTarget };
export { r56 as DEFAULT_VIDEO_ENCODING_CONFIG };
export function calculateTargetDimensions(a0, a1) {
let r15, r19;
const r11 = a0.width / a0.height;
if (a0.width > a0.height) {
const r23 = Math.min(a1, a0.height);
r15 = Math.round(r23 * r11);
r19 = r23;
} else {
r15 = Math.min(a1, a0.width);
r19 = Math.round(r15 / r11);
}
return {
width: r15 % 2 !== 0 ? r15 + 1 : r15,
height: r19 % 2 !== 0 ? r19 + 1 : r19
};
}
export function canSkipVideoTranscode(a0, a1, a2, a3) {
let r23, r27;
if (a2 != null && a3 != null && a2 > a3) {
return false;
}
const targetResolution = a0.targetResolution;
const r11 = a1.width / a1.height;
if (a1.width > a1.height) {
const r30 = Math.min(targetResolution, a1.height);
r23 = Math.round(r30 * r11);
r27 = r30;
} else {
r23 = Math.min(targetResolution, a1.width);
r27 = Math.round(r23 / r11);
}
const r34 = r23 % 2 !== 0 ? r23 + 1 : r23;
const r37 = r27 % 2 !== 0 ? r27 + 1 : r27;
const r43 = Math.round(a1.width);
const r47 = Math.round(a1.height);
const r4 = r43 <= r34 && r47 <= r37;
const r6 = a1.bitRate <= a0.targetBitrate;
return !((r4 ? !r6 : !r4) || a1.format == null || a1.format.match(/(avc1|hvc1|video\/(avc|hevc))/i) === null);
}
export function logSourceMetadata(a0) {
const r1 = a0.format != null;
let r8 = "unknown";
if (r1) {
let r12 = ({
hvc1: "hvc1 (HEVC)",
avc1: "avc1 (H.264)"
})[a0.format];
if (r12 == null) {
r12 = a0.format;
}
r8 = r12;
}
c2907_1.info("Video Source Metadata:");
c2907_1.info(`- Codec: ${r8}`);
c2907_1.info(`- Dimensions: ${a0.width}x${a0.height}`);
c2907_1.info(`- Bitrate: ${a0.bitRate} bps`);
c2907_1.info(`- Frame Rate: ${a0.frameRate} fps`);
c2907_1.info("- HDR: " + (a0.isHDRContent ? "Yes" : "No"));
c2907_1.info(`- Rotation Degrees: ${a0.rotationDegrees}`);
c2907_1.info(`- Profile: ${a0.sourceProfile}`);
c2907_1.info(`- Level: ${a0.sourceLevel}`);
c2907_1.info(`- Duration: ${a0.durationMs} ms`);
}
export function logEncoderSettings(a0) {
c2907_1.info("Encoder Video Quality Settings:");
const videoQuality = a0.videoQuality;
c2907_1.info(`- Compression Quality: ${videoQuality == null ? void 0 : videoQuality.toString()}`);
c2907_1.info(`- Compression Quality Target Resolution: ${a0.videoQuality?.targetResolution}p`);
c2907_1.info(`- Compression Quality Max Bitrate: ${a0.videoQuality?.targetBitrate} bps`);
c2907_1.info("Encoder Video Transcoding Settings:");
if (a0.skipVideoTranscode) {
c2907_1.info("- Skip Video Transcode: Yes");
} else {
c2907_1.info("- Codec: " + (a0.useHEVC ? "hvc1 (HEVC)" : "avc1 (H.264)"));
c2907_1.info(`- Dimensions: ${a0.targetWidth}x${a0.targetHeight}`);
c2907_1.info(`- Bitrate: ${a0.targetBitrate} bps`);
c2907_1.info(`- Frame Rate: ${a0.frameRate} fps`);
c2907_1.info(`- Key Frame Interval: ${a0.keyFrameIntervalSeconds} seconds`);
const createHDR = a0.createHDR;
let r83 = "No";
c2907_1.info("- Create HDR: " + (createHDR ? "Yes" : "No"));
c2907_1.info(`- Rotation Degrees: ${a0.rotationDegrees}`);
if (a0.hevcIsSupported) {
r83 = "Yes";
}
c2907_1.info("- HEVC Supported: " + r83);
c2907_1.info(`- Progress Update Granularity: ${a0.progressUpdateGranularity}`);
}
}
export function calculateOptimalBitrate(a0, a1, a2) {
return Math.min(Math.max(a0.bitRate, a2), a1.targetBitrate);
}
export function shouldUseHEVC(a0, a1, a2, a3, a4) {
const r1 = a1 ? !a2 : !a1;
return r1 ? !r1 : !((a3 ? a0.rotationDegrees !== 0 : a3) && !a4);
}
@@ -0,0 +1,130 @@
// Metro module 6188 (f6189).
import UnsyncedUserSettingsStore from "../../user_settings/UnsyncedUserSettingsStore";
import UserStore from "../../../stores/UserStore";
import { AnalyticEvents, AnalyticsSections } from "../../../Constants";
import { FileUploadErrorTypes } from "../../messages/MessageConstants";
import { PremiumTypes, PremiumUpsellTypes, PremiumUserLimits } from "../../premium/PremiumConstants";
import * as _PremiumTypeUtils from "../../../utils/PremiumTypeUtils";
import { getAttachmentMimeTypes } from "../../messages/logMessageSendFailure";
import { getKestrelConfig, getKestrelVariantName } from "../experiments/KestrelExperiment";
import { trackWithMetadata } from "../../app_analytics/AppAnalyticsUtils";
import { buildFileSizeLimitEventProperties } from "../buildFileSizeLimitEventProperties";
import { getUploaderChannelId } from "../getUploaderFileSizeMetrics";
import { MAX_TOTAL_ATTACHMENT_SIZE } from "../../../utils/UploadUtils";
import { getImageCompressionQuality } from "../../../utils/native/UploadUtils";
import PremiumUpsellUtils from "../../../utils/native/PremiumUpsellUtils";
import { UpsellTypes } from "../../../ConstantsIOS";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import { intl, t } from "../../../intl/index.native";
import { formatSize, BYTE_IN_KB } from "../../../utils/FileSizeUtils";
import AlertActionCreators from "../../../actions/AlertActionCreators";
let c3928_11 = {
NITRO_UPSELL: "Nitro Upsell",
OVER_MAX_SIZE: "Over Max Size"
};
export default function showUploadFileSizeError({ file, maxSize, baseMaxSize, guildId, analyticsLocations, errorReason }) {
let body, title;
const isPremiumExactly = _PremiumTypeUtils.isPremiumExactly(UserStore.getCurrentUser(), PremiumTypes.TIER_2);
const attachmentMimeTypes = file.items != null ? getAttachmentMimeTypes(file.items) : [];
const postCompressionFileSizes = [];
let c15567_0 = postCompressionFileSizes;
let preCompressionFileSizes = [];
let c15567_1 = preCompressionFileSizes;
if (file.items != null) {
file.items.forEach((item) => {
let postCompressionSize = item.postCompressionSize;
if (postCompressionSize == null) {
postCompressionSize = 0;
}
c15567_0.push(postCompressionSize);
c15567_1.push(item.preCompressionSize);
});
}
const kestrelConfig = getKestrelConfig({
location: "native.showUploadFileSizeError"
});
const FILE_SIZE_LIMIT_EXCEEDED = AnalyticEvents.FILE_SIZE_LIMIT_EXCEEDED;
const r55 = {
guildId,
channelId: getUploaderChannelId(file),
userIndividualFileSizeLimit: baseMaxSize,
numAttachments: file.attachmentsCount,
preCompressionFileSizes,
preCompressionAggregateSize: file.totalPreCompressionSize,
postCompressionFileSizes,
postCompressionAggregateSize: file.totalPostCompressionSize,
attachmentMimeTypes,
errorType: null,
kestrelVariant: null
};
let errorType = errorReason;
if (errorType == null) {
errorType = FileUploadErrorTypes.ERROR_SOURCE_UNKNOWN;
}
r55.errorType = errorType;
r55.kestrelVariant = getKestrelVariantName(kestrelConfig);
trackWithMetadata(FILE_SIZE_LIMIT_EXCEEDED, buildFileSizeLimitEventProperties(r55));
let largestFileSize = 0;
if (!isPremiumExactly) {
const items = file.items;
let r72 = maxSize;
if (items != null) {
const ERROR_SOURCE_UNKNOWN = FileUploadErrorTypes.ERROR_SOURCE_UNKNOWN;
r72 = maxSize;
if (errorReason !== ERROR_SOURCE_UNKNOWN) {
const r76 = Math;
const max = r76.max;
if (errorReason === FileUploadErrorTypes.POSTCOMPRESSION_INDIVIDUAL_FILE_TOO_LARGE) {
preCompressionFileSizes = postCompressionFileSizes;
}
r72 = max.apply(r76, [...preCompressionFileSizes]);
}
}
largestFileSize = r72;
}
const r85 = errorReason === FileUploadErrorTypes.POSTCOMPRESSION_SUM_TOO_LARGE || errorReason === FileUploadErrorTypes.PRECOMPRESSION_SUM_TOO_LARGE;
const r87 = isPremiumExactly || largestFileSize > PremiumUserLimits[PremiumTypes.TIER_2].fileSize || largestFileSize > MAX_TOTAL_ATTACHMENT_SIZE || r85 || errorReason === FileUploadErrorTypes.ERROR_SOURCE_UNKNOWN;
trackWithMetadata(AnalyticEvents.FILE_UPLOAD_ALERT_VIEWED, {
alert_type: r87 ? c3928_11.OVER_MAX_SIZE : c3928_11.NITRO_UPSELL,
num_attachments: file.attachmentsCount,
total_attachment_size: file.currentSize,
has_image: file.hasImage,
has_video: file.hasVideo,
is_premium: isPremiumExactly,
image_compression_quality: getImageCompressionQuality(),
image_compression_setting_enabled: UnsyncedUserSettingsStore.dataSavingMode
});
if (r87) {
if (errorReason === FileUploadErrorTypes.ERROR_SOURCE_UNKNOWN) {
title = intl.string(t.B3vFdU);
body = intl.string(t.zMEjJg);
} else {
title = kestrelConfig.enabled ? intl.string(t.bRYgjH) : intl.string(t["/tGlcj"]);
body = r85 ? intl.formatToPlainString(t.tUOJdH, {
maxSize: formatSize(MAX_TOTAL_ATTACHMENT_SIZE / BYTE_IN_KB, {
useKibibytes: true
})
}) : intl.formatToPlainString(t.fxEKdS, {
maxSize: formatSize(maxSize / BYTE_IN_KB, {
useKibibytes: true
})
});
}
AlertActionCreators.show({
title,
body
});
} else {
PremiumUpsellUtils.handleShowUpsellAlert({
initialUpsellKey: UpsellTypes.UPLOAD,
analyticsLocation: {
section: AnalyticsSections.FILE_UPLOAD_POPOUT
},
analyticsLocations: [...analyticsLocations, AnalyticsLocation.FILE_UPLOAD_POPOUT],
analyticsProperties: {
type: PremiumUpsellTypes.UPLOAD_ERROR_UPSELL
},
largestFileSize
});
}
};
@@ -0,0 +1,5 @@
// Metro module 9670 (f9671).
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
export default function showUploadPreviewActionSheet(a0) {
ActionSheetActionCreators.openLazy(import("./UploadPreviewActionSheet"), "UploadPreviewActionSheet", a0);
};
@@ -0,0 +1,141 @@
// Metro module 6148 (f6149).
import UploadStore from "../../stores/UploadStore";
import CloudUploader from "../../lib/uploader/native/CloudUploader";
import { createMessageRecord } from "../messages/MessageRecordUtils";
import Dispatcher from "../../Dispatcher";
function $mk114870($env) {
return (a0) => {
const r4 = $env;
c3890_5.add(r4[2]);
Dispatcher.dispatch({
type: "UPLOAD_START",
channelId: r4[0],
file: a0,
uploader: r4[5],
message: r4[7]
});
};
}
function $mk114871($env) {
return (a0) => {
Dispatcher.dispatch({
type: "UPLOAD_COMPRESSION_PROGRESS",
channelId: $env[0],
file: a0
});
};
}
function $mk114872($env) {
return (a0) => {
Dispatcher.dispatch({
type: "UPLOAD_PROGRESS",
channelId: $env[0],
file: a0
});
};
}
function $mk114873($env) {
return (a0) => {
const r4 = $env;
c3890_5.delete(r4[2]);
r4[5].cancel();
Dispatcher.dispatch({
type: "UPLOAD_FAIL",
channelId: r4[0],
file: a0,
messageId: r4[7].id,
shouldSendNotification: r4[4]
});
};
}
function $mk114874($env) {
return (a0) => {
const r4 = $env;
let env31392 = {
$parent: $env
};
env31392[0] = a0;
c3890_5.delete(r4[2]);
const messageForFile = UploadStore.getMessageForFile(a0.id);
if (messageForFile != null && messageForFile.content === "" && r4[5]._aborted) {
let nonce = messageForFile.nonce;
if (nonce == null) {
nonce = messageForFile.id;
}
Dispatcher.dispatch({
type: "MESSAGE_DELETE",
id: nonce,
channelId: messageForFile.channel_id
});
}
if (r4[5]._aborted) {
setTimeout(() => {
const r1 = env31392.$parent.$parent;
(0, r1[1])(r1[2][4]).dispatch({
type: "UPLOAD_COMPLETE",
channelId: env31392.$parent[0],
file: env31392[0],
aborted: true
});
}, 0);
}
};
}
function $mk114875($env) {
return (a0) => {
Dispatcher.dispatch({
type: "UPLOAD_FILE_UPDATE",
file: a0,
channelId: $env[0]
});
};
}
let env3890 = {};
const c3890_5 = new Set();
export async function uploadMessageAttachments(c25718_0) {
let value, c25718_2, c25718_3;
L14: {
let env29671;
const r29 = env3890;
c25718_3 = r29;
const r10 = env29671 = {
$parent: r29
};
c25718_2 = r10;
env29671[0] = void 0;
env29671[1] = void 0;
env29671[2] = void 0;
env29671[3] = void 0;
env29671[4] = void 0;
env29671[0] = c25718_0.channelId;
env29671[1] = c25718_0.message;
env29671[2] = c25718_0.nonce;
env29671[3] = c25718_0.items;
env29671[4] = c25718_0.shouldUploadFailureSendNotification;
env29671[5] = void 0;
env29671[6] = void 0;
env29671[7] = void 0;
await void 0;
if (c3890_5.has(env29671[2])) {
break L14;
}
const r55 = c25718_2;
env29671[5] = new CloudUploader();
env29671[6] = `pending-upload-${env29671[5]._file.id}`;
env29671[7] = createMessageRecord({
...env29671[1],
key: env29671[6]
});
env29671[5].on("start", $mk114870(r55));
env29671[5].on("compression-progress", $mk114871(r55));
env29671[5].on("progress", $mk114872(r55));
env29671[5].on("error", $mk114873(r55));
env29671[5].on("complete", $mk114874(r55));
env29671[5].on("cancel-upload-item", $mk114875(r55));
value = {};
const attachments = await env29671[5].uploadFiles(env29671[3]);
value.attachments = attachments;
value.uploader = env29671[5];
return value;
}
}