decord/alpha/source/modules/user_profile/UserProfilePersonalWidget.tsx

433 lines
14 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 7320
// Function ID: 7321
// Name: UserProfilePersonalWidget
2026-10-09 10:00:15 +00:00
// Dependencies: [1390, 1392, 7321, 4899, 2049, 1388, 1355, 7315, 1989, 2]
2026-08-24 06:08:38 +00:00
// Exports: createDefaultCoverSection, createDefaultField, createDefaultPersonalWidget, isPersonalWidgetNew, parsePersonalWidgetSections
2026-07-28 08:39:19 +00:00
2026-10-09 10:00:15 +00:00
// Module 7320 (UserProfilePersonalWidget)
import _modDef1355 from "module_1355" /* 1355 */;
import GlobalUtils from "GlobalUtils" /* 1388 */;
import PremiumConstants from "PremiumConstants" /* 1392 */;
import PremiumTypeUtils from "PremiumTypeUtils" /* 1989 */;
import dismissible_content from "dismissible_content" /* 2049 */;
import DismissibleContentUnsafeUtils from "DismissibleContentUnsafeUtils" /* 4899 */;
import WidgetType from "WidgetType" /* 7315 */;
import PersonalWidgetSectionType from "PersonalWidgetSectionType" /* 7321 */;
import UserStore from "UserStore" /* 1390 */;
2026-10-03 08:58:59 +00:00
import size_mod from "module_2" /* 2 */;
2026-08-11 06:20:06 +00:00
2026-08-24 06:08:38 +00:00
function createDefaultFieldsSection() {
2026-10-03 08:58:59 +00:00
let items;
2026-08-24 06:08:38 +00:00
const sum = tmp + 1;
2026-10-03 08:58:59 +00:00
const obj2 = { key: `field-${+closure_5}`, title: "", description: "" };
const obj = { type: PersonalWidgetSectionType.PersonalWidgetSectionType.FIELDS, fields: items };
items = [obj2, , , ];
2026-08-24 06:08:38 +00:00
const sum1 = tmp3 + 1;
2026-10-03 08:58:59 +00:00
const obj3 = { key: `field-${+sum}`, title: "", description: "" };
items[1] = obj3;
2026-08-24 06:08:38 +00:00
const sum2 = tmp5 + 1;
2026-10-03 08:58:59 +00:00
const obj4 = { key: `field-${+sum1}`, title: "", description: "" };
items[2] = obj4;
2026-08-24 06:08:38 +00:00
closure_5 = tmp7 + 1;
2026-10-03 08:58:59 +00:00
const obj5 = { key: `field-${+sum2}`, title: "", description: "" };
items[3] = obj5;
2026-08-24 06:08:38 +00:00
return obj;
}
2026-07-31 08:44:05 +00:00
function isFieldEmpty(title) {
2026-10-03 08:58:59 +00:00
const str = title.title;
let tmp = "" === str.trim();
2026-07-31 08:44:05 +00:00
if (tmp) {
2026-10-03 08:58:59 +00:00
const str2 = title.description;
tmp = "" === str2.trim();
2026-07-31 08:44:05 +00:00
}
if (tmp) {
tmp = null == title.image;
}
return tmp;
}
function isSectionEmpty(type) {
type = type.type;
2026-08-24 06:08:38 +00:00
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
2026-10-03 08:58:59 +00:00
const str = type.title;
let tmp4 = "" === str.trim();
2026-07-31 08:44:05 +00:00
if (tmp4) {
2026-10-03 08:58:59 +00:00
const str3 = type.subtitle;
tmp4 = "" === str3.trim();
2026-07-31 08:44:05 +00:00
}
if (tmp4) {
tmp4 = null == type.image;
}
return tmp4;
2026-08-24 06:08:38 +00:00
} else if (PersonalWidgetSectionType.PersonalWidgetSectionType.FIELDS === type) {
2026-07-31 08:44:05 +00:00
const fields = type.fields;
return fields.every(isFieldEmpty);
}
}
function parseField(image) {
2026-10-03 08:58:59 +00:00
let is_animated;
let str2;
let str3;
2026-07-31 08:44:05 +00:00
image = image.image;
let tmp;
if (null != image) {
if ("file_id" in image) {
2026-10-03 08:58:59 +00:00
size = { fileId: null, width: null, height: null, isAnimated: is_animated };
({ file_id: obj.fileId, width: obj.width, height: obj.height, is_animated } = image);
2026-08-14 17:33:39 +00:00
if (is_animated == null) {
is_animated = false;
}
tmp = size;
2026-07-31 08:44:05 +00:00
}
}
2026-10-03 08:58:59 +00:00
const obj2 = { key: `field-${+closure_5}`, title: str2, description: str3, image: tmp, hideImage: null == tmp || undefined };
2026-08-24 06:08:38 +00:00
closure_5 = tmp2 + 1;
2026-10-03 08:58:59 +00:00
str2 = image.title;
2026-07-31 08:44:05 +00:00
if (str2 == null) {
str2 = "";
}
2026-10-03 08:58:59 +00:00
str3 = image.description;
2026-07-31 08:44:05 +00:00
if (str3 == null) {
str3 = "";
}
return obj2;
2026-07-31 08:44:05 +00:00
}
function serializeSection(type) {
2026-10-03 08:58:59 +00:00
let image;
let tmp4;
2026-07-31 08:44:05 +00:00
type = type.type;
2026-10-03 08:58:59 +00:00
let tmp = require;
2026-08-24 06:08:38 +00:00
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
2026-10-03 08:58:59 +00:00
const obj6 = { type: null, title: null, subtitle: null, image: tmp4 };
({ type: obj2.type, title: obj2.title, subtitle: obj2.subtitle, image } = type);
tmp4 = undefined;
if (null != image) {
let str = "localDataUri";
if ("localDataUri" in image) {
const obj7 = { filename: null, original_hash: null };
({ filename: obj4.filename, originalHash: obj4.original_hash } = image);
size = obj7;
} else {
size = { file_id: null, width: null, height: null, is_animated: null };
({ fileId: obj3.file_id, width: obj3.width, height: obj3.height, isAnimated: obj3.is_animated } = image);
}
tmp4 = size;
2026-07-31 08:44:05 +00:00
}
2026-10-03 08:58:59 +00:00
return obj6;
2026-08-24 06:08:38 +00:00
} else if (PersonalWidgetSectionType.PersonalWidgetSectionType.FIELDS === type) {
2026-07-31 08:44:05 +00:00
const fields = type.fields;
const found = fields.filter((title) => {
2026-10-03 08:58:59 +00:00
const str = title.title;
let tmp = "" === str.trim();
2026-07-31 08:44:05 +00:00
if (tmp) {
2026-10-03 08:58:59 +00:00
const str2 = title.description;
tmp = "" === str2.trim();
2026-07-31 08:44:05 +00:00
}
if (tmp) {
tmp = null == title.image;
}
return !tmp;
});
let obj = {
type: type.type,
fields: found.map((title) => {
2026-10-03 08:58:59 +00:00
let tmp;
const image = title.image;
const obj = { title: title.title, description: title.description, image: tmp };
tmp = undefined;
if (null != image) {
if ("localDataUri" in image) {
const obj4 = { filename: null, original_hash: null };
({ filename: obj3.filename, originalHash: obj3.original_hash } = image);
size = obj4;
} else {
size = { file_id: null, width: null, height: null, is_animated: null };
({ fileId: obj2.file_id, width: obj2.width, height: obj2.height, isAnimated: obj2.is_animated } = image);
}
tmp = size;
}
2026-10-03 08:58:59 +00:00
return obj;
})
};
2026-07-31 08:44:05 +00:00
return obj;
} else {
return type;
}
}
2026-10-03 08:58:59 +00:00
const PremiumTypes = PremiumConstants.PremiumTypes;
let closure_5 = 0;
2026-07-29 08:29:29 +00:00
class UserProfilePersonalWidget {
2026-10-03 08:58:59 +00:00
constructor(sections) {
let header;
let id;
sections = sections.sections;
({ id, header } = sections);
const obj = Object.create(new.target.prototype);
2026-08-25 06:04:03 +00:00
obj.id = id;
2026-10-03 08:58:59 +00:00
obj.type = WidgetType.WidgetType.PERSONAL;
2026-07-29 08:29:29 +00:00
obj.header = header;
2026-07-31 08:44:05 +00:00
if (sections == null) {
sections = [];
2026-07-29 08:29:29 +00:00
}
2026-07-31 08:44:05 +00:00
obj.sections = sections;
2026-07-29 08:29:29 +00:00
return obj;
}
2026-10-03 08:58:59 +00:00
toSubmission() {
let mapped;
let obj2;
const obj = { id: this.id, data: obj2 };
2026-08-25 06:04:03 +00:00
const sections = this.sections;
2026-10-03 08:58:59 +00:00
obj2 = { type: this.type, header: this.header, sections: mapped.filter(GlobalUtils.isNotNullish) };
const found = sections.filter((type) => {
let everyResult;
2026-08-25 06:04:03 +00:00
type = type.type;
2026-10-03 08:58:59 +00:00
const tmp = require;
const tmp2 = dependencyMap;
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
2026-10-03 08:58:59 +00:00
const str = type.title;
let tmp5 = "" === str.trim();
2026-08-25 06:04:03 +00:00
if (tmp5) {
2026-10-03 08:58:59 +00:00
const str3 = type.subtitle;
tmp5 = "" === str3.trim();
2026-08-25 06:04:03 +00:00
}
if (tmp5) {
tmp5 = null == type.image;
}
2026-10-03 08:58:59 +00:00
everyResult = tmp5;
} else if (tmp(tmp2[2]).PersonalWidgetSectionType.FIELDS === type) {
2026-08-25 06:04:03 +00:00
const fields = type.fields;
everyResult = fields.every(isFieldEmpty);
2026-08-04 08:36:32 +00:00
}
2026-08-25 06:04:03 +00:00
return !everyResult;
});
2026-10-03 08:58:59 +00:00
mapped = found.map(serializeSection);
return obj;
2026-08-25 06:04:03 +00:00
}
2026-10-03 08:58:59 +00:00
isDiscardable() {
const sections = this.sections;
return sections.every(isSectionEmpty);
}
isValid() {
let str = this.header;
let someResult = "" !== str.trim();
if (someResult) {
const sections = this.sections;
someResult = sections.some((type) => {
let everyResult;
type = type.type;
const tmp = require;
const tmp2 = dependencyMap;
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
const str = type.title;
let tmp5 = "" === str.trim();
if (tmp5) {
const str3 = type.subtitle;
tmp5 = "" === str3.trim();
}
if (tmp5) {
tmp5 = null == type.image;
2026-08-03 11:20:01 +00:00
}
2026-10-03 08:58:59 +00:00
everyResult = tmp5;
} else if (tmp(tmp2[2]).PersonalWidgetSectionType.FIELDS === type) {
const fields = type.fields;
everyResult = fields.every(isFieldEmpty);
2026-08-03 11:20:01 +00:00
}
2026-10-03 08:58:59 +00:00
return !everyResult;
});
}
return someResult;
}
isUpdatable() {
const obj = PremiumTypeUtils;
return obj.isPremium(UserStore.getCurrentUser(), PremiumTypes.TIER_2);
}
isEqual(header) {
let tmp = header instanceof UserProfilePersonalWidget;
if (tmp) {
let tmp2 = this.header === header.header;
if (tmp2) {
const sections = this.sections;
const sections1 = header.sections;
let flag = false;
if (sections.length === sections1.length) {
let num2 = 0;
flag = true;
if (0 < sections.length) {
flag = false;
while (sections[num2].type === sections1[num2].type) {
let type = tmp3.type;
let tmp17 = require;
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
let tmp14 = tmp3.title === tmp4.title && tmp3.subtitle === tmp4.subtitle;
if (tmp14) {
2026-10-09 10:00:15 +00:00
tmp14 = _modDef1355(tmp3.image, tmp4.image);
2026-10-03 08:58:59 +00:00
}
flag = false;
if (!tmp14) {
break;
}
2026-10-09 10:00:15 +00:00
} else if (tmp17(7321).PersonalWidgetSectionType.FIELDS === type) {
2026-10-03 08:58:59 +00:00
let flag2 = false;
if (tmp3.fields.length === tmp4.fields.length) {
let num = 0;
flag2 = true;
if (0 < tmp3.fields.length) {
while (true) {
let tmp7 = tmp3.fields[num];
let tmp8 = tmp4.fields[num];
let tmp9 = tmp7.title === tmp8.title;
if (tmp9) {
tmp9 = tmp7.description === tmp8.description;
}
if (tmp9) {
2026-10-09 10:00:15 +00:00
tmp9 = _modDef1355(tmp7.image, tmp8.image);
2026-10-03 08:58:59 +00:00
}
flag2 = false;
if (!tmp9) {
break;
} else {
let sum = num + 1;
num = sum;
flag2 = true;
if (sum >= tmp3.fields.length) {
break;
}
}
}
}
}
flag = false;
if (!flag2) {
break;
}
2026-08-03 11:20:01 +00:00
break;
} else {
2026-10-03 08:58:59 +00:00
flag = false;
2026-10-09 10:00:15 +00:00
if (!_modDef1355(tmp3, tmp4)) {
2026-08-03 11:20:01 +00:00
break;
}
2026-10-03 08:58:59 +00:00
break;
}
let sum1 = num2 + 1;
num2 = sum1;
flag = true;
if (sum1 >= sections.length) {
break;
2026-08-03 11:20:01 +00:00
}
}
}
}
2026-10-03 08:58:59 +00:00
tmp2 = flag;
2026-08-03 11:20:01 +00:00
}
2026-10-03 08:58:59 +00:00
tmp = tmp2;
2026-08-03 11:20:01 +00:00
}
2026-10-03 08:58:59 +00:00
return tmp;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
getUniqueKey() {
return this.type;
}
getProfileAnalyticsOptions() {
return { widgetType: this.type };
}
getProfileEditAnalyticsOptions() {
return { widgetEdited: this.type };
}
}
const prototype = UserProfilePersonalWidget.prototype;
let size = size_mod;
const result = size.fileFinishedImporting("modules/user_profile/UserProfilePersonalWidget.tsx");
2026-07-28 08:39:19 +00:00
2026-07-31 08:44:05 +00:00
export const createDefaultCoverSection = function createDefaultCoverSection() {
2026-10-03 08:58:59 +00:00
const obj = { type: PersonalWidgetSectionType.PersonalWidgetSectionType.COVER, title: "", subtitle: "" };
return obj;
2026-08-03 11:20:01 +00:00
};
export const createDefaultField = function createDefaultField() {
2026-10-03 08:58:59 +00:00
const obj = { key: `field-${+closure_5}`, title: "", description: "" };
2026-08-24 06:08:38 +00:00
closure_5 = tmp + 1;
return obj;
2026-07-31 08:44:05 +00:00
};
2026-08-24 06:08:38 +00:00
export { createDefaultFieldsSection };
2026-07-31 08:44:05 +00:00
export const createDefaultPersonalWidget = function createDefaultPersonalWidget() {
2026-10-03 08:58:59 +00:00
let header;
let id;
let items;
let sections;
const obj = { header: "", sections: items };
items = [{ type: PersonalWidgetSectionType.PersonalWidgetSectionType.COVER, title: "", subtitle: "" }, ];
({ type: PersonalWidgetSectionType.PersonalWidgetSectionType.COVER, title: "", subtitle: "" });
items[1] = createDefaultFieldsSection();
const tmp = UserProfilePersonalWidget;
if (typeof UserProfilePersonalWidget === "function") {
({ sections, id, header } = obj);
const obj4 = Object.create(tmp.prototype);
obj4.id = id;
obj4.type = WidgetType.WidgetType.PERSONAL;
obj4.header = header;
if (sections == null) {
sections = [];
}
obj4.sections = sections;
return obj4;
} else {
throw new TypeError("Trying to call a non-function");
2026-07-31 08:44:05 +00:00
}
2026-08-24 06:08:38 +00:00
};
export const isPersonalWidgetNew = function isPersonalWidgetNew() {
2026-10-03 08:58:59 +00:00
const obj = DismissibleContentUnsafeUtils;
return !obj.UNSAFE_isDismissibleContentDismissed(dismissible_content.DismissibleContent.USER_PROFILE_PERSONAL_WIDGET_NEW_BADGE);
2026-07-31 08:44:05 +00:00
};
export const parsePersonalWidgetSections = function parsePersonalWidgetSections(sections) {
2026-10-03 08:58:59 +00:00
let items;
2026-07-31 08:44:05 +00:00
if (null == sections) {
2026-10-03 08:58:59 +00:00
items = [];
2026-07-31 08:44:05 +00:00
} else {
const mapped = sections.map((type) => {
2026-10-03 08:58:59 +00:00
let fields;
let is_animated;
let str;
let title;
let tmp5;
2026-07-31 08:44:05 +00:00
type = type.type;
2026-10-03 08:58:59 +00:00
const tmp = require;
const tmp2 = dependencyMap;
if (PersonalWidgetSectionType.PersonalWidgetSectionType.COVER === type) {
2026-10-03 08:58:59 +00:00
const obj4 = { type: null, title, subtitle: str, image: tmp5 };
({ type: obj2.type, title } = type);
2026-07-31 08:44:05 +00:00
if (title == null) {
title = "";
}
2026-10-03 08:58:59 +00:00
str = type.subtitle;
2026-07-31 08:44:05 +00:00
if (str == null) {
str = "";
}
const image = type.image;
2026-10-03 08:58:59 +00:00
tmp5 = undefined;
2026-07-31 08:44:05 +00:00
if (null != image) {
if ("file_id" in image) {
2026-10-03 08:58:59 +00:00
size = { fileId: null, width: null, height: null, isAnimated: is_animated };
({ file_id: obj3.fileId, width: obj3.width, height: obj3.height, is_animated } = image);
2026-08-14 17:33:39 +00:00
if (is_animated == null) {
is_animated = false;
}
tmp5 = size;
2026-07-31 08:44:05 +00:00
}
}
return obj4;
2026-10-03 08:58:59 +00:00
} else if (tmp(tmp2[2]).PersonalWidgetSectionType.FIELDS === type) {
const obj = { type: null, fields: fields.map(parseField) };
({ type: obj.type, fields } = type);
2026-07-31 08:44:05 +00:00
return obj;
}
});
2026-10-03 08:58:59 +00:00
let tmp = require;
let tmp2 = dependencyMap;
items = mapped.filter(GlobalUtils.isNotNullish);
2026-07-31 08:44:05 +00:00
}
if (!items.some((type) => type.type === PersonalWidgetSectionType.PersonalWidgetSectionType.FIELDS)) {
let obj = { type: PersonalWidgetSectionType.PersonalWidgetSectionType.FIELDS, fields: [] };
2026-10-03 08:58:59 +00:00
const push = items.push;
push(obj);
2026-08-04 08:36:32 +00:00
}
2026-07-31 08:44:05 +00:00
return items;
};
2026-07-29 08:29:29 +00:00
export { UserProfilePersonalWidget };