Files
discord-decomp/modules/emojis/UnicodeEmojis.tsx
T
2026-11-01 12:12:55 +02:00

348 lines
12 KiB
TypeScript

// Metro module 3830 (f3831).
import defaultImageSrcGenerator from "../../_bundle/defaultImageSrcGenerator";
import * as _Module3832 from "../../_bundle/Module3832";
import { surrogateToEmoji, emojis, emojisByCategory, nameToEmoji } from "../../_bundle/Module3832";
import { EmojiTypes } from "./EmojiTypes";
import EmojiUtils from "../../utils/EmojiUtils";
import Module12 from "../../_bundle/Module12";
import * as _Module13122 from "../../_bundle/Module13122";
let c2166_4, c2166_5, _excluded, c2166_7, c2166_8, c2166_9, c2166_12, c2166_13, c2166_14, c2166_15, findInlineEmojisFromSurrogates;
const parseRawEmojiObject = function parseRawEmojiObject(a0) {
const r9 = c2166_5.get(a0);
if (r9 != null) {
return r9;
}
const emoji = new Emoji(a0);
c2166_5.set(a0, emoji);
return emoji;
};
findInlineEmojisFromSurrogates = function findInlineEmojisFromSurrogates(a0, a1) {
let r3, r19, r38, length, surrogate3;
if (a1 !== true && !c2166_8.test(a0)) {
return [{
type: "text",
text: a0
}];
}
let r18 = a0.match(c2166_9);
if (r18 == null) {
r18 = [];
}
const r35 = [];
const r7 = 0 < r18.length;
let r0 = 0;
let r14 = "";
let surrogate = "";
if (r7) {
do {
L34: {
L22: {
const r21 = r18[r0];
r3 = r0;
const surrogate2 = r14;
if (surrogate2 != null && surrogate2 !== "") {
if (r21 === c2166_13) {
surrogate3 = surrogate2 + r21;
r38 = "";
break L22;
}
if (c2166_15.test(r21)) {
r19 = surrogate2 + r21;
break L34;
}
const r26 = surrogateToEmoji[surrogate2];
const r47 = r26 == null ? null : emojis[r26];
const r52 = r47 == null ? void 0 : r47.names[0];
r35.push(r52 != null ? {
type: "emoji",
surrogate: surrogate2,
emojiName: `:${r52}:`
} : {
type: "text",
text: surrogate2
});
surrogate3 = r21;
r38 = "";
} else {
surrogate3 = r21;
r38 = surrogate2;
r19 = surrogate3;
if (r19 === c2166_14) {
break L34;
}
}
}
const r65 = surrogateToEmoji[surrogate3];
const r67 = r65 == null ? null : emojis[r65];
const r72 = r67 == null ? void 0 : r67.names[0];
const r74 = r72 != null ? {
type: "emoji",
surrogate: surrogate3,
emojiName: `:${r72}:`
} : {
type: "text",
text: surrogate3
};
if (r35.length > 0) {
const r81 = r35[r35.length - 1];
if (r74.type === "text" && r81.type === "text") {
r81.text = r81.text + r74.text;
r19 = r38;
} else {
r35.push(r74);
r19 = r38;
}
} else {
r35.push(r74);
r19 = r38;
}
}
r0 = r3 + 1;
length = r18.length;
r14 = r19;
surrogate = r14;
} while (r0 < length);
}
if (surrogate != null && surrogate !== "") {
const r97 = surrogateToEmoji[surrogate];
const r99 = r97 == null ? null : emojis[r97];
const r104 = r99 == null ? void 0 : r99.names[0];
r35.push(r104 != null ? {
type: "emoji",
surrogate,
emojiName: `:${r104}:`
} : {
type: "text",
text: surrogate
});
}
return r35;
};
c2166_4 = null;
c2166_5 = new WeakMap();
_excluded = ["🏻", "🏼", "🏽", "🏾", "🏿"];
c2166_7 = /^:([^\s:]+?(?:::skin-tone-\d)?):/;
c2166_8 = /[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f\u270b\u2b50\u2728\u26a1\u26c5\u26c4\u2614\u2615\u26bd\u26be\u26f3\u26f5\u2693\u26fd\u26f2\u26fa\u26ea\u231a\u23f0\u231b\u23f3\u26ce\u2648\u2649\u264a\u264b\u264c\u264d\u264e\u264f\u2650\u2651\u2652\u2653\u270a\u274c\u2b55\u26d4\u2757\u2755\u2753\u2754\u2705\u274e\u267f\u23e9\u23ea\u23eb\u23ec\u2795\u2796\u2797\u27b0\u27bf\u26aa\u26ab\u25fe\u25fd\u2b1b\u2b1c\u26a7]/;
c2166_9 = /\ud83c[\udffb-\udfff](?=\ud83c[\udffb-\udfff])|(?:[^\ud800-\udfff][\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]?|[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g;
class Emoji {
constructor(a0) {
this.emojiObject = a0;
this.type = EmojiTypes.UNICODE;
this.uniqueName = a0.names[0];
this.surrogates = a0.surrogates;
this.diversityChildren = {};
if (a0.diversityChildren != null) {
for (const item of a0.diversityChildren) {
const r45 = emojis[item];
if (r45.diversity != null) {
this.diversityChildren[r45.diversity.join("-")] = new Emoji(r45);
}
}
}
}
get names() {
return this.emojiObject.names;
}
get allNamesString() {
return this.names.length > 1 ? `:${this.names.join(": :")}:` : `:${this.uniqueName}:`;
}
get unicodeVersion() {
let unicodeVersion2 = this.emojiObject.unicodeVersion;
if (unicodeVersion2 == null) {
unicodeVersion2 = 0;
}
return unicodeVersion2;
}
get hasDiversity() {
return this.emojiObject.hasDiversity;
}
get hasMultiDiversity() {
return this.emojiObject.hasMultiDiversity;
}
get hasDiversityParent() {
return this.emojiObject.hasDiversityParent;
}
get hasMultiDiversityParent() {
return this.emojiObject.hasMultiDiversityParent;
}
get managed() {
return true;
}
get animated() {
return false;
}
get defaultDiversityChild() {
if (this.hasDiversity && c2166_4 != null) {
let r10 = defaultImageSrcGenerator.convert.toCodePoint(c2166_4);
if (r10 == null) {
r10 = "";
}
return this.diversityChildren[r10];
}
return null;
}
get url() {
const defaultDiversityChild2 = this.defaultDiversityChild;
return defaultDiversityChild2 != null ? EmojiUtils.getURL(defaultDiversityChild2.surrogates) : EmojiUtils.getURL(this.surrogates);
}
get name() {
let r10;
if (this.hasDiversity && c2166_4 != null) {
const uniqueName = this.uniqueName;
const r15 = surrogateToEmoji[c2166_4];
const r16 = r15 == null ? null : emojis[r15];
r10 = `${uniqueName}::${r16 == null ? void 0 : r16.names[0]}`;
} else {
r10 = this.uniqueName;
}
return r10;
}
get optionallyDiverseSequence() {
const defaultDiversityChild2 = this.defaultDiversityChild;
return defaultDiversityChild2 != null ? defaultDiversityChild2.surrogates : this.surrogates;
}
forEachDiversity(a0) {
if (this.diversityChildren != null) {
Module12.each(this.diversityChildren, a0);
}
}
forEachName(a0) {
Module12.each(this.names, a0);
}
}
c2166_12 = new Map();
c2166_13 = String.fromCodePoint(917631);
c2166_14 = String.fromCodePoint(127988);
c2166_15 = /^(?:\uDB40[\uDC61-\uDC7A])$/;
const r77 = {
getDefaultDiversitySurrogate: function getDefaultDiversitySurrogate() {
return c2166_4;
},
setDefaultDiversitySurrogate: function setDefaultDiversitySurrogate(a0) {
c2166_4 = a0 != null ? a0 !== "" ? a0 : null : null;
},
getCategories: function getCategories() {
return Object.keys(emojisByCategory);
},
getByName: function getByName(a0) {
const r14 = nameToEmoji[a0];
const r8 = r14 == null ? null : emojis[r14];
const r18 = r8 != null;
let r19 = null;
if (r18) {
let r22 = c2166_5.get(r8);
if (r22 == null) {
const emoji = new Emoji(r8);
c2166_5.set(r8, emoji);
r22 = emoji;
}
r19 = r22;
}
return r19;
},
getByCategory: function getByCategory(a0) {
let r11 = c2166_12.get(a0);
if (r11 == null) {
const r15 = emojisByCategory[a0];
const r27 = EmojiUtils.filterUnsupportedEmojis(emojis.slice(r15[0], r15[1])).map(parseRawEmojiObject);
c2166_12.set(a0, r27);
r11 = r27;
}
return r11;
},
contentHasUnicodeOrEmoji: function contentHasUnicodeOrEmoji(a0) {
return c2166_8.test(a0);
},
translateInlineEmojiToSurrogates: function translateInlineEmojiToSurrogates(a0) {
return a0.replace(c2166_7, (a0, a1) => {
const r4 = a0 === void 0 ? "" : a0;
const r11 = nameToEmoji[a1];
let r17 = (r11 == null ? null : emojis[r11])?.surrogates;
if (r17 == null) {
r17 = r4;
}
return r17;
});
},
maybeTranslateSurrogatesToInlineEmoji: function maybeTranslateSurrogatesToInlineEmoji(a0) {
if (c2166_8.test(a0)) {
const r15 = findInlineEmojisFromSurrogates(a0, true).map((item) => item.type === "text" ? item.text : item.emojiName).join("");
return r15 !== a0 ? r15 : null;
}
return null;
},
findInlineEmojisFromSurrogates,
translateSurrogatesToInlineEmoji: function translateSurrogatesToInlineEmoji(a0) {
return findInlineEmojisFromSurrogates(a0).map((item) => item.type === "text" ? item.text : item.emojiName).join("");
},
convertNameToSurrogate: function convertNameToSurrogate(a0, r4 = "") {
const r11 = nameToEmoji[a0];
let r17 = (r11 == null ? null : emojis[r11])?.surrogates;
if (r17 == null) {
r17 = r4;
}
return r17;
},
convertSurrogateToName: function convertSurrogateToName(a0, r4 = true, r3 = "") {
const r12 = surrogateToEmoji[a0];
const r13 = r12 == null ? null : emojis[r12];
let r18 = r13 == null ? void 0 : r13.names[0];
if (r18 == null) {
r18 = r3;
}
return r4 ? `:${r18}:` : r18;
},
convertShortcutToName: function convertShortcutToName(a0, r4 = true, r5 = "") {
if (Object.prototype.hasOwnProperty.call(_Module13122, a0)) {
r5 = _Module13122[a0];
}
return r4 ? `:${r5}:` : r5;
},
convertSurrogateToBase: function convertSurrogateToBase(a0) {
const r8 = surrogateToEmoji[_excluded.reduce((acc, item) => acc.replace(item, ""), a0)];
const r18 = r8 == null ? null : emojis[r8];
let r23 = r18 == null ? void 0 : r18.names[0];
if (r23 == null) {
r23 = "";
}
const r28 = nameToEmoji[r23];
const r30 = r28 == null ? null : emojis[r28];
const r34 = r30 != null;
let r35 = null;
if (r34) {
let r38 = c2166_5.get(r30);
if (r38 == null) {
const emoji = new Emoji(r30);
c2166_5.set(r30, emoji);
r38 = emoji;
}
r35 = r38;
}
return r35;
},
forEach: (a0) => {
for (const emoji of emojis) {
if (!(emoji.hasDiversityParent || emoji.hasMultiDiversityParent)) {
a0(parseRawEmojiObject(emoji));
}
}
},
numDiversitySprites: _Module3832.numDiversitySprites,
numNonDiversitySprites: _Module3832.numNonDiversitySprites,
EMOJI_NAME_RE: /^:([^\s:]+?(?:::skin-tone-\d)?):/,
EMOJI_NAME_AND_DIVERSITY_RE: c2166_7,
EMOJI_SHORTCUT_RE: /^(>:\(|>:\-\(|>=\(|>=\-\(|:"\)|:\-"\)|="\)|=\-"\)|<\/3|<\\3|:\-\\|:\-\/|=\-\\|=\-\/|:'\(|:'\-\(|:,\(|:,\-\(|='\(|='\-\(|=,\(|=,\-\(|:\(|:\-\(|=\(|=\-\(|<3|♡|\]:\(|\]:\-\(|\]=\(|\]=\-\(|o:\)|O:\)|o:\-\)|O:\-\)|0:\)|0:\-\)|o=\)|O=\)|o=\-\)|O=\-\)|0=\)|0=\-\)|:'D|:'\-D|:,D|:,\-D|='D|='\-D|=,D|=,\-D|:\*|:\-\*|=\*|=\-\*|x\-\)|X\-\)|:\||:\-\||=\||=\-\||:o|:\-o|:O|:\-O|=o|=\-o|=O|=\-O|:@|:\-@|=@|=\-@|:D|:\-D|=D|=\-D|:'\)|:'\-\)|:,\)|:,\-\)|='\)|='\-\)|=,\)|=,\-\)|:\)|:\-\)|=\)|=\-\)|\]:\)|\]:\-\)|\]=\)|\]=\-\)|:,'\(|:,'\-\(|;\(|;\-\(|=,'\(|=,'\-\(|:P|:\-P|=P|=\-P|8\-\)|B\-\)|,:\(|,:\-\(|,=\(|,=\-\(|,:\)|,:\-\)|,=\)|,=\-\)|:s|:\-S|:z|:\-Z|:\$|:\-\$|=s|=\-S|=z|=\-Z|=\$|=\-\$|;\)|;\-\))/,
hasSurrogates: function hasSurrogates(a0) {
return Module12.toArray(a0).some((item) => surrogateToEmoji[item] != null);
}
};
export default r77;
export { _excluded as DIVERSITY_SURROGATES };
export { Emoji };
export function asUnicodeEmoji(a0) {
return a0.id == null ? a0.name != null ? a0.name.length > 0 ? {
name: a0.name,
id: null
} : null : null : null;
}