decord/alpha/source/modules/parent_tools/FamilyCenterUtils.tsx

211 lines
7.8 KiB
TypeScript
Raw Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 7742
// Function ID: 7743
// Name: FamilyCenterUtils
2026-10-12 06:59:38 +00:00
// Dependencies: [7259, 7260, 1126, 2568, 4702, 7261, 2]
// Exports: formatLinkTimestamp, formatTotalTime, formatUserActivityTimestamp, getActivityTypeTextConfigs, getActivityWindowTimestampFormatter, getEmptyActivityFormatter, getFailureCodeForAPIError, getOrFetchLinkedUsers, getSortedActivityTypeConfigs, getTopUserOrGuildDescription, hasActiveParentLinks, isGift, isGuildAction, isParentallyControlled, isPurchase, isUserAction
2026-07-20 16:05:17 +00:00
2026-10-12 06:59:38 +00:00
// Module 7742 (FamilyCenterUtils)
2026-10-03 08:58:59 +00:00
import intl5 from "intl" /* 1126 */;
2026-10-10 08:08:14 +00:00
import _modDef2568 from "module_2568" /* 2568 */;
import _modDef4702 from "module_4702" /* 4702 */;
2026-10-12 06:59:38 +00:00
import FamilyCenterActionCreatorsDefault from "FamilyCenterActionCreators" /* 7261 */;
import FamilyCenterStore from "FamilyCenterStore" /* 7259 */;
import FamilyCenterConstants from "FamilyCenterConstants" /* 7260 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let map;
let c9;
let closure_4;
let hasOwnProperty;
let metroImportAll;
let metroImportDefault;
let metroRequire;
2026-10-12 06:59:38 +00:00
const f97326 = (link_status) => link_status.link_status === constants.ACTIVE && link_status.link_type === constants2.PARENT;
2026-10-03 08:58:59 +00:00
({ ACTION_TO_TEXT: closure_4, FAMILY_CENTER_ERROR_CODE_TO_FAILURE: hasOwnProperty, FamilyCenterFailureCode: metroRequire, TeenActionDisplayType: metroImportDefault, UserLinkStatus: metroImportAll, UserLinkType: c9 } = FamilyCenterConstants);
2026-07-29 08:29:29 +00:00
let c10 = 86400;
let c11 = 172800;
let result = size.fileFinishedImporting("modules/parent_tools/FamilyCenterUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getEmptyActivityFormatter = function getEmptyActivityFormatter() {
2026-10-03 08:58:59 +00:00
let intl;
let intl2;
2026-10-10 08:08:14 +00:00
const obj = { today: intl.string(_modDef2568.VjIAQQ), yesterday: intl2.string(_modDef2568["2a8xHY"]), days: _modDef2568.Xt6oND };
2026-10-03 08:58:59 +00:00
intl = intl5.intl;
intl2 = intl5.intl;
2026-07-20 16:05:17 +00:00
return obj;
};
export const getActivityWindowTimestampFormatter = function getActivityWindowTimestampFormatter(arg0) {
2026-10-03 08:58:59 +00:00
let tmp6;
2026-07-29 08:29:29 +00:00
const obj = { today: null, yesterday: null, days: null };
2026-10-03 08:58:59 +00:00
const intl = intl5.intl;
2026-07-20 16:05:17 +00:00
const string = intl.string;
2026-10-10 08:08:14 +00:00
const tmp4 = _modDef2568;
2026-10-03 08:58:59 +00:00
const tmp5 = arg0;
if (tmp5) {
obj.today = string(tmp4["2AtcIs"]);
2026-10-03 08:58:59 +00:00
const intl3 = tmp(1126).intl;
2026-10-10 08:08:14 +00:00
obj.yesterday = intl3.string(_modDef2568.stOECr);
obj.days = _modDef2568.n8n5Ba;
2026-10-03 08:58:59 +00:00
tmp6 = obj;
2026-07-20 16:05:17 +00:00
} else {
obj.today = string(tmp4.g1ZX6m);
2026-10-03 08:58:59 +00:00
const intl2 = tmp(1126).intl;
2026-10-10 08:08:14 +00:00
obj.yesterday = intl2.string(_modDef2568.s3qSVt);
obj.days = _modDef2568.f1UJiC;
2026-10-03 08:58:59 +00:00
tmp6 = obj;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
return tmp6;
2026-07-20 16:05:17 +00:00
};
export const formatUserActivityTimestamp = function formatUserActivityTimestamp(time, timestampFormatter, arg2) {
2026-10-03 08:58:59 +00:00
let yesterday;
2026-10-10 08:08:14 +00:00
const obj = _modDef4702();
const diffResult = obj.diff(_modDef4702(time), "s");
2026-07-29 08:29:29 +00:00
const tmp3 = timestampFormatter();
2026-10-10 08:08:14 +00:00
const obj2 = _modDef4702(time);
2026-10-03 08:58:59 +00:00
obj2.format("LL");
2026-07-29 08:29:29 +00:00
if (diffResult < c10) {
2026-10-03 08:58:59 +00:00
yesterday = tmp3.today;
2026-07-29 08:29:29 +00:00
} else if (diffResult < c11) {
yesterday = tmp3.yesterday;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let num = arg2;
2026-10-03 08:58:59 +00:00
const intl = intl5.intl;
const _Math2 = Math;
const formatToPlainString = intl.formatToPlainString;
const days = tmp3.days;
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-07-29 08:29:29 +00:00
const rounded = Math.floor(diffResult / tmp5);
if (arg2 == null) {
num = 999;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const obj3 = { days: min(rounded, num) };
yesterday = formatToPlainString(days, obj3);
2026-07-20 16:05:17 +00:00
}
return yesterday;
};
export const formatLinkTimestamp = function formatLinkTimestamp(arg0, SENT_TIMESTAMP_FORMATTER) {
2026-10-03 08:58:59 +00:00
let yesterday;
2026-10-10 08:08:14 +00:00
const obj = _modDef4702();
const diffResult = obj.diff(_modDef4702(arg0), "s");
const time = SENT_TIMESTAMP_FORMATTER();
2026-10-10 08:08:14 +00:00
_modDef4702(arg0);
2026-07-20 16:05:17 +00:00
if (diffResult < 60) {
2026-10-03 08:58:59 +00:00
yesterday = time.seconds;
2026-07-20 16:05:17 +00:00
} else if (diffResult < 3600) {
2026-10-03 08:58:59 +00:00
const intl4 = intl5.intl;
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
2026-10-03 08:58:59 +00:00
const formatToPlainString3 = intl4.formatToPlainString;
const minutes = time.minutes;
const obj2 = { count: Math.floor(diffResult / 60) };
yesterday = formatToPlainString3(minutes, obj2);
2026-07-29 08:29:29 +00:00
} else if (diffResult < c10) {
2026-10-03 08:58:59 +00:00
const intl3 = intl5.intl;
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
2026-10-03 08:58:59 +00:00
const formatToPlainString2 = intl3.formatToPlainString;
const hours = time.hours;
const obj3 = { count: Math.floor(diffResult / 3600) };
yesterday = formatToPlainString2(hours, obj3);
2026-07-29 08:29:29 +00:00
} else if (diffResult < c11) {
yesterday = time.yesterday;
2026-07-20 16:05:17 +00:00
} else if (diffResult < 604800) {
2026-10-03 08:58:59 +00:00
const intl2 = intl5.intl;
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-10-03 08:58:59 +00:00
const formatToPlainString = intl2.formatToPlainString;
const days = time.days;
const obj4 = { count: Math.floor(diffResult / tmp12) };
yesterday = formatToPlainString(days, obj4);
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
const intl = intl5.intl;
const obj5 = { date: tmp4 };
yesterday = intl.formatToPlainString(time.date, obj5);
2026-07-20 16:05:17 +00:00
}
return yesterday;
};
export const isUserAction = function isUserAction(action) {
2026-10-03 08:58:59 +00:00
return action.display_type === metroImportDefault.USER_ADD || action.display_type === metroImportDefault.USER_INTERACTION || action.display_type === metroImportDefault.USER_CALLED;
2026-07-20 16:05:17 +00:00
};
export const isGuildAction = function isGuildAction(action) {
2026-10-03 08:58:59 +00:00
return action.display_type === metroImportDefault.GUILD_ADD || action.display_type === tmp.GUILD_INTERACTION;
2026-07-20 16:05:17 +00:00
};
export const isPurchase = function isPurchase(action) {
2026-10-03 08:58:59 +00:00
return action.display_type === metroImportDefault.PURCHASES;
2026-07-20 16:05:17 +00:00
};
export const isGift = function isGift(action) {
2026-10-03 08:58:59 +00:00
return action.display_type === metroImportDefault.GIFTS;
2026-07-20 16:05:17 +00:00
};
export const getFailureCodeForAPIError = function getFailureCodeForAPIError(arg0) {
let GENERIC_ERROR = hasOwnProperty[arg0.code];
2026-07-29 08:29:29 +00:00
if (GENERIC_ERROR == null) {
2026-10-03 08:58:59 +00:00
GENERIC_ERROR = metroRequire.GENERIC_ERROR;
2026-07-20 16:05:17 +00:00
}
return GENERIC_ERROR;
};
export const getSortedActivityTypeConfigs = function getSortedActivityTypeConfigs() {
2026-10-03 08:58:59 +00:00
let items;
map = new Map(React3);
2026-07-29 08:29:29 +00:00
if (0 === map.size) {
2026-10-03 08:58:59 +00:00
items = [];
2026-07-20 16:05:17 +00:00
} else {
const _Array = Array;
2026-07-29 08:29:29 +00:00
const arr = Array.from(map.entries());
2026-10-03 08:58:59 +00:00
items = arr.sort((arg0, arg1) => arg0[1].priority - arg1[1].priority);
2026-07-20 16:05:17 +00:00
}
return items;
};
2026-07-29 08:29:29 +00:00
export const getActivityTypeTextConfigs = function getActivityTypeTextConfigs() {
2026-10-03 08:58:59 +00:00
map = new Map(React3);
return map;
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const formatTotalTime = function formatTotalTime(arg0) {
2026-10-03 08:58:59 +00:00
let combined;
2026-07-20 16:05:17 +00:00
const rounded = Math.floor(arg0 / 60);
const result = arg0 % 60;
if (rounded > 0) {
const _HermesInternal2 = HermesInternal;
2026-10-03 08:58:59 +00:00
combined = "" + rounded + "h " + result + "m";
2026-07-20 16:05:17 +00:00
} else {
const _HermesInternal = HermesInternal;
combined = "" + result + "m";
}
return combined;
};
export const getOrFetchLinkedUsers = function getOrFetchLinkedUsers() {
2026-10-03 08:58:59 +00:00
const obj = FamilyCenterStore;
if (FamilyCenterStore.getAreLinkedUsersProcessed()) {
2026-07-29 08:29:29 +00:00
return obj.getLinkedUsers();
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
const obj2 = FamilyCenterActionCreatorsDefault;
const linkedUsers = obj2.fetchLinkedUsers();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
export const hasActiveParentLinks = function hasActiveParentLinks() {
const values = Object.values(FamilyCenterStore.getLinkedUsers());
2026-10-12 06:59:38 +00:00
return values.some(f97326);
2026-07-20 16:05:17 +00:00
};
export const isParentallyControlled = function isParentallyControlled() {
const values = Object.values(FamilyCenterStore.getLinkedUsers());
2026-10-12 06:59:38 +00:00
return values.some(f97326);
2026-07-20 16:05:17 +00:00
};
export const getTopUserOrGuildDescription = function getTopUserOrGuildDescription(dms_sent, call_count) {
2026-10-03 08:58:59 +00:00
let formatToPlainStringResult;
2026-07-20 16:05:17 +00:00
if (call_count > 0) {
if (0 === dms_sent) {
2026-10-03 08:58:59 +00:00
const intl3 = intl5.intl;
const obj2 = { callCount: call_count };
2026-10-10 08:08:14 +00:00
formatToPlainStringResult = intl3.formatToPlainString(_modDef2568["L/Cj7S"], obj2);
2026-07-20 16:05:17 +00:00
}
return formatToPlainStringResult;
}
if (dms_sent > 0) {
if (0 === call_count) {
2026-10-03 08:58:59 +00:00
const intl2 = intl5.intl;
const obj3 = { messageCount: dms_sent };
2026-10-10 08:08:14 +00:00
formatToPlainStringResult = intl2.formatToPlainString(_modDef2568["6X1F0i"], obj3);
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
const intl = intl5.intl;
const obj = { messageCount: dms_sent, callCount: call_count };
2026-10-10 08:08:14 +00:00
formatToPlainStringResult = intl.formatToPlainString(_modDef2568.IYqGMG, obj);
2026-07-20 16:05:17 +00:00
};