213 lines
6.2 KiB
TypeScript
213 lines
6.2 KiB
TypeScript
// Metro module 4028 (f4029).
|
|
import StreamerModeStore from "../stores/StreamerModeStore";
|
|
import UserStore from "../stores/UserStore";
|
|
import { NON_USER_BOT_DISCRIMINATOR, StatusTypes } from "../Constants";
|
|
import { useStateFromStores } from "../_bundle/Module589";
|
|
import { intl, t } from "../intl/index.native";
|
|
let c2306_6, c2306_7, c2306_8, presentUserTag;
|
|
const nameFromUser = function nameFromUser(a0) {
|
|
let global_name2;
|
|
const global_name = a0.global_name;
|
|
if (global_name != null && global_name.length > 0) {
|
|
global_name2 = a0.global_name;
|
|
} else {
|
|
const globalName = a0.globalName;
|
|
if (globalName != null && globalName.length > 0) {
|
|
global_name2 = a0.globalName;
|
|
} else {
|
|
const username = a0.username;
|
|
global_name2 = username != null && username.length > 0 ? a0.username : c2306_7;
|
|
}
|
|
}
|
|
return global_name2;
|
|
};
|
|
export function getName(a0) {
|
|
if (a0 != null) {
|
|
let hidePersonalInformation = StreamerModeStore.hidePersonalInformation;
|
|
const r12 = nameFromUser(a0);
|
|
if (hidePersonalInformation) {
|
|
const r6 = r12.toLocaleLowerCase();
|
|
const username = a0.username;
|
|
hidePersonalInformation = r6 === (username == null ? void 0 : username.toLocaleLowerCase());
|
|
}
|
|
if (hidePersonalInformation) {
|
|
hidePersonalInformation = a0.discriminator === "0";
|
|
}
|
|
return hidePersonalInformation ? `${r12[0]}…` : r12;
|
|
}
|
|
}
|
|
export function useName(a0) {
|
|
let r13 = useStateFromStores([StreamerModeStore], () => StreamerModeStore.hidePersonalInformation);
|
|
if (a0 != null) {
|
|
const r15 = nameFromUser(a0);
|
|
if (r13) {
|
|
const r17 = r15.toLocaleLowerCase();
|
|
const username = a0.username;
|
|
r13 = r17 === (username == null ? void 0 : username.toLocaleLowerCase());
|
|
}
|
|
if (r13) {
|
|
r13 = a0.discriminator === "0";
|
|
}
|
|
return r13 ? `${r15[0]}…` : r15;
|
|
}
|
|
}
|
|
export function getGlobalName(a0) {
|
|
let globalName2;
|
|
if (a0 != null) {
|
|
const globalName = a0.globalName;
|
|
if (globalName != null && globalName.length > 0) {
|
|
globalName2 = a0.globalName;
|
|
} else {
|
|
const global_name = a0.global_name;
|
|
globalName2 = global_name != null && global_name.length > 0 ? a0.global_name : void 0;
|
|
}
|
|
return globalName2;
|
|
}
|
|
}
|
|
export function getFormattedName(a0, r6 = false) {
|
|
let r12, globalName2;
|
|
if (a0 == null) {
|
|
return c2306_7;
|
|
}
|
|
const r1 = a0 != null;
|
|
let r13 = void 0;
|
|
if (r1) {
|
|
const globalName = a0.globalName;
|
|
if (globalName != null && globalName.length > 0) {
|
|
globalName2 = a0.globalName;
|
|
} else {
|
|
const global_name = a0.global_name;
|
|
globalName2 = global_name != null && global_name.length > 0 ? a0.global_name : void 0;
|
|
}
|
|
r13 = globalName2;
|
|
}
|
|
if (r6) {
|
|
const r8 = {
|
|
...c2306_8,
|
|
...void 0
|
|
};
|
|
r12 = presentUserTag(a0, r8, r8.identifiable !== "auto" || StreamerModeStore.hidePersonalInformation);
|
|
} else {
|
|
r12 = a0.username;
|
|
if (r12 == null) {
|
|
r12 = c2306_7;
|
|
}
|
|
}
|
|
let r39 = r13;
|
|
if (r39 !== r12) {
|
|
r39 = r13 != null ? `${r13} (${r12})` : r12;
|
|
}
|
|
return r39;
|
|
}
|
|
export function humanizeStatus(a0, r3 = {}) {
|
|
const { isMobile = false, isVR = false } = r3;
|
|
if (StatusTypes.ONLINE === a0) {
|
|
return isVR ? intl.string(t.SWnU0R) : isMobile ? intl.string(t["9hghLD"]) : intl.string(t.WbGtnH);
|
|
}
|
|
if (StatusTypes.OFFLINE === a0) {
|
|
return intl.string(t.Vv0abJ);
|
|
}
|
|
if (StatusTypes.IDLE === a0) {
|
|
return intl.string(t.qWbtVU);
|
|
}
|
|
if (StatusTypes.DND === a0) {
|
|
return intl.string(t.jaNpQH);
|
|
}
|
|
if (StatusTypes.INVISIBLE === a0) {
|
|
return intl.string(t.bg24HO);
|
|
}
|
|
if (StatusTypes.STREAMING === a0) {
|
|
return intl.string(t.XKYej5);
|
|
}
|
|
StatusTypes.UNKNOWN;
|
|
return null;
|
|
}
|
|
presentUserTag = function presentUserTag(a0, a1, a2) {
|
|
if (a0 == null) {
|
|
return intl.string(t.sKdZ6U);
|
|
}
|
|
const username = a0.username;
|
|
if (username != null && username.length > 0) {
|
|
const r17 = a1.identifiable !== "always" ? a1.identifiable === "never" ? true : a2 : false;
|
|
if (a0.discriminator !== "0" && a0.discriminator !== NON_USER_BOT_DISCRIMINATOR) {
|
|
return a1.mode !== "username" && !r17 ? `${a0.username}#${a0.discriminator}` : a0.username;
|
|
}
|
|
const username2 = a0.username;
|
|
const r10 = r17 ? `${username2[0]}…` : username2;
|
|
return a1.decoration !== "never" ? `@${r10}` : r10;
|
|
}
|
|
return c2306_7;
|
|
};
|
|
export function getUserTag(a0, a1) {
|
|
const r4 = {
|
|
...c2306_8,
|
|
...a1
|
|
};
|
|
return presentUserTag(a0, r4, r4.identifiable !== "auto" || StreamerModeStore.hidePersonalInformation);
|
|
}
|
|
export function useUserTag(a0, a1) {
|
|
return presentUserTag(a0, {
|
|
...c2306_8,
|
|
...a1
|
|
}, useStateFromStores([StreamerModeStore], () => StreamerModeStore.hidePersonalInformation));
|
|
}
|
|
export function useDirectMessageRecipient(c13791_0) {
|
|
return useStateFromStores([UserStore], () => {
|
|
if (c13791_0 != null) {
|
|
return c13791_0.isPrivate() ? c13791_0.isDM() ? UserStore.getUser(c13791_0.getRecipientId()) : null : null;
|
|
}
|
|
});
|
|
}
|
|
export function getUserIsStaff() {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
return currentUser != null && currentUser.isStaff();
|
|
}
|
|
c2306_6 = 86400000;
|
|
c2306_7 = "???";
|
|
c2306_8 = {
|
|
mode: "full",
|
|
decoration: "never",
|
|
identifiable: "auto"
|
|
};
|
|
const r35 = {
|
|
getName,
|
|
useName,
|
|
isNameConcealed: function isNameConcealed(a0) {
|
|
return a0.length === 2 && a0.endsWith("…");
|
|
},
|
|
getUserTag,
|
|
useUserTag,
|
|
getUserIsStaff,
|
|
getFormattedName,
|
|
getGlobalName,
|
|
humanizeStatus,
|
|
useDirectMessageRecipient
|
|
};
|
|
export default r35;
|
|
export { nameFromUser };
|
|
export function accountAgeInRange(a0, { maxDaysOld, minDaysOld = 0 }) {
|
|
if (a0 == null) {
|
|
return false;
|
|
}
|
|
const r16 = Date.now() - a0.createdAt.getTime();
|
|
return (maxDaysOld == null || r16 <= c2306_6 * maxDaysOld) && r16 >= c2306_6 * minDaysOld;
|
|
}
|
|
export function ageEligibleForPremiumUpsell(a0) {
|
|
const r2 = a0 == null;
|
|
let r8 = false;
|
|
if (!r2) {
|
|
const r14 = Date.now() - a0.createdAt.getTime();
|
|
r8 = r14 <= c2306_6 * 30 && r14 >= c2306_6 * 0;
|
|
}
|
|
return !r8;
|
|
}
|
|
export function isNewUser(a0) {
|
|
const r2 = a0 == null;
|
|
let r8 = false;
|
|
if (!r2) {
|
|
const r14 = Date.now() - a0.createdAt.getTime();
|
|
r8 = r14 <= c2306_6 * 7 && r14 >= c2306_6 * 0;
|
|
}
|
|
return r8;
|
|
}
|