Files
discord-decomp/_bundle/Image.jsx
T
2026-11-01 12:12:55 +02:00

212 lines
6.9 KiB
React

// Metro module 328 (f329).
import { use } from "react";
import Module329 from "./Module329";
import { getImageSourcesFromImageProps } from "./Module331";
import resolveAssetSource from "./resolveAssetSource";
import flattenStyle from "./flattenStyle";
import { convertObjectFitToResizeMode } from "./Module332";
import { useWrapRefWithImageAttachedCallbacks, unstable_getImageComponentDecorator } from "./Module333";
import Module336 from "./Module336";
import Module337 from "./Module337";
import Module254 from "./Module254";
let styles;
let c344_6 = 1;
const source = {
uri: void 0,
width: void 0,
height: void 0
};
const _BaseImage = (a0) => {
const { ref, alt, accessible, "aria-labelledby": _aria_labelledby, "aria-busy": _aria_busy, "aria-checked": _aria_checked, "aria-disabled": _aria_disabled, "aria-expanded": _aria_expanded, "aria-hidden": _aria_hidden, "aria-label": _aria_label, "aria-selected": _aria_selected, accessibilityLabel, accessibilityLabelledBy, accessibilityState, defaultSource, loadingIndicatorSource, children, source: source2, src, style, crossOrigin, referrerPolicy, srcSet, onLoadStart, onLoad, onLoadEnd, onError, width, height, resizeMode, ...props } = a0;
const accessibilityLabelledBy2 = a0["aria-labelledby"];
let busy = a0["aria-busy"];
let checked = a0["aria-checked"];
let disabled = a0["aria-disabled"];
let expanded = a0["aria-expanded"];
const r8 = a0["aria-hidden"];
const accessibilityLabel2 = a0["aria-label"];
let selected = a0["aria-selected"];
const source3 = getImageSourcesFromImageProps({
crossOrigin,
referrerPolicy,
src,
srcSet,
width,
height,
source: source2
}) || source;
const defaultSource2 = resolveAssetSource(defaultSource);
const loadingIndicatorSrc = resolveAssetSource(loadingIndicatorSource);
if (children != null) {
throw new Error("The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.");
}
if (defaultSource != null && loadingIndicatorSource != null) {
throw new Error("The <Image> component cannot have defaultSource and loadingIndicatorSource at the same time. Please use either defaultSource or loadingIndicatorSource.");
}
if (Array.isArray(source3)) {
const r73 = source3[0];
const { headers, width: width3, height: height3 } = r73;
if (headers != null) {
props.headers = headers;
}
props.style = [source3.length === 1 && {
width: width3,
height: height3
}, styles.base, style];
props.source = source3;
} else {
const uri = source3.uri;
let width2 = source3.width;
let height2 = source3.height;
if (uri === "") {
console.warn("source.uri should not be an empty string");
}
if (width2 == null) {
width2 = width;
}
if (height2 == null) {
height2 = height;
}
props.style = [{
width: width2,
height: height2
}, styles.base, style];
props.source = [source3];
}
if (onLoadStart != null) {
props.shouldNotifyLoadEvents = true;
props.onLoadStart = onLoadStart;
}
if (onLoad != null) {
props.shouldNotifyLoadEvents = true;
props.onLoad = onLoad;
}
if (onLoadEnd != null) {
props.shouldNotifyLoadEvents = true;
props.onLoadEnd = onLoadEnd;
}
if (onError != null) {
props.shouldNotifyLoadEvents = true;
props.onError = onError;
}
if (defaultSource2 != null && defaultSource2.uri != null) {
props.defaultSource = defaultSource2;
}
if (loadingIndicatorSrc != null && loadingIndicatorSrc.uri != null) {
props.loadingIndicatorSrc = loadingIndicatorSrc;
}
if (accessibilityLabel2 != null) {
props.accessibilityLabel = accessibilityLabel2;
} else if (accessibilityLabel != null) {
props.accessibilityLabel = accessibilityLabel;
} else if (alt != null) {
props.accessibilityLabel = alt;
}
if (accessibilityLabelledBy2 != null) {
props.accessibilityLabelledBy = accessibilityLabelledBy2;
} else if (accessibilityLabelledBy != null) {
props.accessibilityLabelledBy = accessibilityLabelledBy;
}
if (alt != null) {
props.accessible = true;
} else if (accessible != null) {
props.accessible = accessible;
}
if (!(accessibilityState == null && busy == null && checked == null && disabled == null && expanded == null && selected == null)) {
if (busy == null) {
busy = accessibilityState?.busy;
}
if (checked == null) {
checked = accessibilityState?.checked;
}
if (disabled == null) {
disabled = accessibilityState?.disabled;
}
if (expanded == null) {
expanded = accessibilityState?.expanded;
}
if (selected == null) {
selected = accessibilityState?.selected;
}
props.accessibilityState = {
busy,
checked,
disabled,
expanded,
selected
};
}
if (r8 === true) {
props.importantForAccessibility = "no-hide-descendants";
}
const r107 = flattenStyle(style);
props.resizeMode = convertObjectFitToResizeMode(r107?.objectFit) || resizeMode || r107?.resizeMode || "cover";
const wrapRefWithImageAttachedCallbacks = useWrapRefWithImageAttachedCallbacks(ref);
const internal_analyticTag = use(Module336);
if (internal_analyticTag !== null) {
props.internal_analyticTag = internal_analyticTag;
}
return <Module337 {...props} ref={wrapRefWithImageAttachedCallbacks} />;
};
const r31 = unstable_getImageComponentDecorator();
const r32 = r31 != null ? r31(_BaseImage) : _BaseImage;
const prefetch = function prefetch(a0, a1) {
const r4 = +c344_6;
c344_6 = r4 + 1;
if (a1) {
a1(r4);
}
return Module329.prefetchImage(a0, r4);
};
r32.displayName = "Image";
r32.getSize = function getSize(a0, a1, a2) {
const size = Module329.getSize(a0);
if (typeof a1 !== "function") {
return size;
}
let r11 = a2;
const r14 = size.then((result) => a1(result.width, result.height));
if (!a2) {
r11 = function() {
console.warn("Failed to get size for image: " + a0);
};
}
r14.catch(r11);
};
r32.getSizeWithHeaders = function getSizeWithHeaders(a0, a1, a2, a3) {
const sizeWithHeaders = Module329.getSizeWithHeaders(a0, a1);
if (typeof a2 !== "function") {
return sizeWithHeaders;
}
let r12 = a3;
const r15 = sizeWithHeaders.then((result) => a2(result.width, result.height));
if (!a3) {
r12 = function() {
console.warn("Failed to get size for image: " + a0);
};
}
r15.catch(r12);
};
r32.prefetch = prefetch;
r32.prefetchWithMetadata = function prefetchWithMetadata(a0, a1, a2, a3) {
const r4 = +c344_6;
c344_6 = r4 + 1;
if (a3) {
a3(r4);
}
return Module329.prefetchImage(a0, r4);
};
r32.abortPrefetch = function abortPrefetch(a0) {
Module329.abortRequest(a0);
};
r32.queryCache = async function queryCache(c23663_0) {
return Module329.queryCache(c23663_0);
};
r32.resolveAssetSource = resolveAssetSource;
styles = Module254.create({
base: {
overflow: "hidden"
}
});
export default r32;